Files
cleveragents-core/features/cli_docstring_example_validation.feature
T
HAL9000 3e5e5974c4 test(cli): validate docstring examples respect positional order
Implemented DocstringExampleValidator class in src/cleveragents/cli/docstring_validator.py that validates CLI command docstring examples to ensure positional arguments precede option flags and align with Typer signatures.

Added Behave feature file at features/cli_docstring_example_validation.feature containing scenarios for valid and invalid docstring examples and edge cases.

Added step definitions at features/steps/cli_docstring_example_validation_steps.py implementing Given/When/Then steps to drive validation and report mismatches.

Fixed the problematic docstring in src/cleveragents/cli/commands/plan.py (rollback_plan function) to reflect correct positional argument order and clearer usage.

The validator ensures that docstring examples have positional arguments before option flags, matching the actual Typer command signature.

ISSUES CLOSED: #9106
2026-06-02 14:01:58 -04:00

31 lines
1.5 KiB
Gherkin

Feature: CLI docstring example validation
As a documentation maintainer
I want to ensure CLI docstring examples respect positional argument order
So that published documentation accurately reflects the command signature
Scenario: Validator detects positional arguments before options
Given I have a CLI command with positional arguments and options
When I validate the command's docstring examples
Then the validation should pass for examples with positional args before options
Scenario: Validator rejects options before positional arguments
Given I have a CLI command with positional arguments and options
When I validate the command's docstring examples
Then the validation should fail for examples with options before positional args
Scenario: Validator handles commands without examples
Given I have a CLI command without docstring examples
When I validate the command's docstring examples
Then the validation should pass for commands without examples
Scenario: Validator parses example lines with shlex
Given I have a CLI command with quoted arguments in examples
When I validate the command's docstring examples
Then the validation should correctly parse quoted arguments
Scenario: Validator reports clear error messages
Given I have a CLI command with invalid docstring examples
When I validate the command's docstring examples
Then the error message should identify the command and example line
And the error message should explain the positional argument order requirement