Skip to content

Conversation

@leslierichardson95
Copy link

This pull request introduces a new, more granular exit code system for the Docfx CLI, making it easier to diagnose build failures and integrate with CI/CD pipelines. It adds command-line options to control exit code behavior, implements logic to categorize errors, and updates documentation to explain the changes.

Exit Code System and CLI Options:

  • Added a new ExitCode enum (src/docfx/Models/ExitCode.cs) defining specific exit codes for different error categories (e.g., config, input, metadata, template, user-cancelled, etc.), replacing the previous binary success/failure model.
  • Introduced new CLI flags in LogOptions (src/docfx/Models/LogOptions.cs): --strict (returns exit code 1 if warnings are present) and --legacy-exit-codes (returns 0 for success, -1 for any error, for backward compatibility).

Error Categorization and Exit Code Logic:

  • Implemented ExitCodeHelper (src/docfx/Models/ExitCodeHelper.cs) to determine the appropriate exit code based on the type of error encountered, strict mode, legacy mode, and cancellation state. It also maps exceptions to exit codes and resets state for each command.
  • Enhanced the Logger class (src/Docfx.Common/Loggers/Logger.cs) to track error categories (config, build, metadata, template, input) and reset their state between runs. Errors are now categorized using the error code pattern. [1] [2] [3]
  • Updated command execution logic (src/docfx/Models/CommandHelper.cs, src/docfx/Program.cs) to use the new exit code system, handle cancellation (Ctrl+C), and ensure proper exit code is returned in all cases. [1] [2] [3] [4]

Documentation:

  • Added a new section to docs/docs/config.md explaining the exit codes, command-line options, and usage examples for CI/CD pipelines.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant