Skip to content

Commit ea07c7f

Browse files
authored
docs(cli) Custom argparse documentation engine with syntax highlighting (#1009)
Replace external `sphinx-argparse` dependency with custom `sphinx_argparse_neo` extensions, ported from vcspull project. Adds comprehensive documentation infrastructure for CLI commands. ## Changes ### New Extensions - `docs/_ext/sphinx_argparse_neo/` - Complete argparse documentation engine - `docs/_ext/argparse_exemplar.py` - Transforms epilog examples into TOC sections - `docs/_ext/argparse_lexer.py` - Pygments lexers for CLI syntax highlighting - `docs/_ext/argparse_roles.py` - RST roles for inline CLI formatting - `docs/_static/css/argparse-highlight.css` - Styling for usage blocks and code ### Bug Fixes - Use slice assignment for docutils node children manipulation (fixes parent tracking) - Add type annotation to fix mypy `no-any-return` error - Escape asterisks in glob patterns to prevent RST emphasis warnings - Add ID prefix to avoid duplicate section IDs across subcommand pages ### Documentation - Restructure CLI command pages to match vcspull pattern - Add doctest exceptions to AGENTS.md for Sphinx visitor patterns - Add doctests to `_create_example_section()` and `_extract_mutex_groups()` ### Removed - `pretty_argparse.py` (replaced by new extensions) - `sphinx-argparse` dependency
2 parents 917dcd5 + 2d80f70 commit ea07c7f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+8603
-998
lines changed

AGENTS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,14 @@ windows:
156156
3. **Keep doctests simple and focused** on demonstrating usage
157157
4. **Add blank lines between test sections** for improved readability
158158

159+
**Doctest exceptions** (patterns where doctests are not required):
160+
161+
1. **Sphinx/docutils `visit_*`/`depart_*` methods** - tested via integration tests; 0 examples across docutils (851 methods), Sphinx (800+), and CPython's `ast.NodeVisitor`
162+
2. **Sphinx `setup()` functions** - entry points not testable in isolation
163+
3. **Complex recursive traversal functions** - extract helper predicates instead
164+
165+
**Best practice for node processing**: Extract testable helper functions (like `_is_usage_block()`) and doctest those. Keep complex visitor logic in integration tests.
166+
159167
## Documentation Standards
160168

161169
### Code Blocks in Documentation

CHANGES

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,28 @@ $ pipx install --suffix=@next 'tmuxp' --pip-args '\--pre' --force
3131

3232
<!-- To maintainers and contributors: Please add notes for the forthcoming version below -->
3333

34-
_Notes on the upcoming release will go here._
34+
### Documentation
35+
36+
#### CLI documentation overhaul with sphinx_argparse_neo (#1009)
37+
38+
Replaced the `pretty_argparse` extension with a new `sphinx_argparse_neo` package:
39+
40+
- **New argparse documentation engine**: Complete rewrite for cleaner, more maintainable CLI docs
41+
- **Syntax highlighting**: Custom Pygments lexers for CLI usage blocks and argparse output
42+
- **Examples transformation**: Automatically converts epilog "examples:" definition lists into proper documentation sections with TOC entries
43+
- **ANSI stripping**: Removes escape codes when `FORCE_COLOR` is set
44+
- **RST emphasis escaping**: Prevents warnings from glob patterns like `django-*`
45+
- **Restructured CLI pages**: Consistent layout matching vcspull documentation pattern
46+
47+
### Bug fixes
48+
49+
#### Docutils node.children protocol (#1009)
50+
51+
- Fixed direct `node.children` assignment that bypassed docutils' parent-child tracking mechanism
52+
53+
#### Mypy type annotation (#1009)
54+
55+
- Added missing type annotation to fix `no-any-return` error
3556

3657
## tmuxp 1.63.1 (2026-01-11)
3758

0 commit comments

Comments
 (0)