-
Notifications
You must be signed in to change notification settings - Fork 14
docs(_ext): Add Sphinx extensions for CLI documentation #496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
why: Enhanced CLI documentation with syntax highlighting and ANSI stripping what: - Add cli_usage_lexer.py: Pygments lexer for CLI usage patterns - Add pretty_argparse.py: Enhanced sphinx-argparse wrapper - Add comprehensive tests for both extensions (88 tests) - Update docs/conf.py to register pretty_argparse extension - Update pyproject.toml with mypy overrides and doctest config - Fix pre-existing doctest issue in config_reader.py
why: Type stubs for docutils and Pygments libraries used in docs extensions what: - Add types-docutils to dev and typings groups - Add types-Pygments to dev and typings groups
why: Sphinx extensions are documentation utilities, not core code what: - Add docs/_ext/* to coverage.run.omit
why: CLI examples from --help weren't appearing in generated docs what: - Remove :nodescription: from all CLI argparse directives - Allows sphinx-argparse to include description with examples - pretty_argparse transforms examples into proper sections
…ions
why: Asterisks in patterns like "django-*" trigger docutils emphasis
parsing warnings when sphinx-argparse renders help text as RST
what:
- Add escape_rst_emphasis() to escape asterisks preceded by delimiters
- Override _nested_parse_paragraph() to pre-escape descriptions
- Fixes "Inline emphasis start-string without end-string" warnings
why: Ensure RST emphasis escaping works correctly for argparse patterns what: - Add 13 parameterized test cases covering: - Glob patterns like "django-*" are escaped - Multiple patterns in one string - Already escaped patterns unchanged - Valid emphasis (*text*) unchanged - Various edge cases (empty, underscore, dot)
why: Documentation code blocks showing vcspull CLI output need semantic highlighting to match the colors used in the actual CLI. what: - Create vcspull_output_lexer.py with VcspullOutputLexer RegexLexer - Map semantic colors to Pygments tokens (SUCCESS→Generic.Inserted, WARNING→Name.Exception, ERROR→Generic.Error, INFO→Name.Function) - Handle list, status, sync, summary outputs and workspace headers - Register lexer with Sphinx in pretty_argparse.py setup() - Add 17 parameterized tests for all output patterns
… import why: mypy cannot resolve sibling module imports in docs/_ext/ directory. what: - Add type: ignore[import-not-found] to vcspull_output_lexer import
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #496 +/- ##
==========================================
+ Coverage 80.42% 80.52% +0.09%
==========================================
Files 16 16
Lines 2192 2192
Branches 454 454
==========================================
+ Hits 1763 1765 +2
+ Misses 278 277 -1
+ Partials 151 150 -1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
why: Console code blocks use BashSessionLexer which hardcodes output as Generic.Output, losing semantic highlighting for vcspull command output. what: - Create vcspull_console_lexer.py extending ShellSessionBaseLexer pattern - Delegate output lines to VcspullOutputLexer for semantic coloring - Register as 'vcspull-console' alias in pretty_argparse.py - Update docs/cli/list.md to use vcspull-console for output blocks - Add 8 tests for console session tokenization
why: mypy reports errors for missing type stubs and return type annotation. what: - Add type: ignore[attr-defined] for do_insertions and line_re imports - Add type: ignore[no-untyped-def] for generator method - Remove explicit type annotations that conflict with Pygments internals
why: Plain HTTPS URLs in parentheses were incorrectly tokenized as repo names, and interactive prompts like [y/N] had no special highlighting. what: - Add pattern for plain HTTPS/HTTP URLs (Name.Tag) - Add pattern for interactive prompt options [y/N] (Comment) - Add pattern for question mark prompt indicator (Generic.Prompt) - Add 3 tests for new patterns
Update CLI documentation to use vcspull-console lexer for code blocks that display vcspull command output with bullets, checkmarks, and other semantic symbols. Files updated: - discover.md: basic usage, unattended mode, dry run, warnings, existing entries - status.md: basic usage, filtering, detailed status - sync.md: dry run, error handling - search.md: basic usage, field-scoped queries
…highlighting why: Generic "name:" pattern matched false positives like "add:" in "Would add:" and "complete:" in "Dry run complete:". what: - Remove generic "name:" pattern that caused false positives - Add ":" to success symbol lookahead for "✓ repo:" status output - Add vcspull command and subcommand highlighting (Name.Builtin) - Add more labels: Remote:, Repository:, Note:, Usage: - Use vcspull-output for pure output blocks in discover.md
Code reviewFound 2 issues:
vcspull/docs/_ext/cli_usage_lexer.py Lines 8 to 18 in 50119d3
vcspull/docs/_ext/pretty_argparse.py Lines 137 to 193 in 50119d3
Generated with Claude Code - If this code review was useful, please react with a thumbs up. Otherwise, react with a thumbs down. |
|
Correction to issue #1: The import style concern was over-applied. The CLAUDE.md examples ( Issue #1 is withdrawn. Only issue #2 (duplicate Sphinx labels) remains valid. |
why: The namespace import guideline was being misapplied to third-party packages like pygments, where direct imports are idiomatic. what: - Clarify that namespace imports apply to standard library modules - Add explicit note that third-party packages use idiomatic styles - Reorganize section with clear headers for each rule
why: The make_section_id() function generated identical "examples" IDs across all CLI documentation pages, causing 6 Sphinx duplicate label warnings during docs build. what: - Add page_prefix parameter to make_section_id() for cross-page uniqueness - Thread page_prefix through _create_example_section(), transform_definition_list() - Extract docname in CleanArgParseDirective.run() and pass to process_node() - Section IDs now include page name: "sync-examples", "add-examples", etc. - Add test for page_prefix functionality
Summary
Changes
Commit 1: Sphinx extensions and tests
docs/_ext/cli_usage_lexer.py- Pygments lexer for CLI usage patternsdocs/_ext/pretty_argparse.py- Enhanced sphinx-argparse directivetests/docs/_ext/- Comprehensive test suite adapted for vcspullCommit 2: Type stubs
types-docutilsandtypes-Pygmentsto dependenciesCommit 3: Coverage config
docs/_ext/*from coverage reportingTest plan
uv run py.test --reruns 0 -vvv)