Skip to content

Commit 6264eef

Browse files
committed
sphinx-autodoc-argparse(docs[domain]): document :argparse:* roles and indices
why: The argparse domain is live (E1-E5) and sits in Tier 2 (E6), but the package page has no user-facing documentation on how to use the new xref roles or the two auto-generated indices. Add a "Cross-reference roles" section covering the full role vocabulary, the target-syntax rules (whitespace-joined vs bare), and the intersphinx-compat contract — so readers know `:argparse:option:` is now the idiomatic form without losing `:option:` access for intersphinx consumers. what: - Add a "Cross-reference roles" section to docs/packages/sphinx-autodoc-argparse.md after "Inline roles" with: * A four-row table listing :argparse:program: / :argparse:option: / :argparse:subcommand: / :argparse:positional: with concrete example targets. * A short paragraph on target-syntax rules (whitespace-join splits into a (program, name) tuple key; bare form resolves when there's one match). * "Auto-generated indices" subsection naming argparse-programsindex and argparse-optionsindex with :ref: link examples. * "Intersphinx compatibility" note clarifying that :option: / std:cmdoption continues to resolve and appear in objects.inv for external consumers.
1 parent e24c9fd commit 6264eef

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

docs/packages/sphinx-autodoc-argparse.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,43 @@ The exemplar layer also registers live inline roles for CLI prose:
5151
{cli-command}`myapp`, {cli-option}`--verbose`, {cli-choice}`json`,
5252
{cli-metavar}`DIR`, and {cli-default}`text`.
5353

54+
## Cross-reference roles
55+
56+
Every `.. argparse::` block populates a dedicated `argparse` domain
57+
alongside the existing `std:cmdoption` entries. Use these roles to
58+
link to programs, options, subcommands, and positional arguments
59+
declared anywhere in the project:
60+
61+
| Role | Resolves to | Example |
62+
|------|-------------|---------|
63+
| `:argparse:program:` | A top-level program | `` :argparse:program:`myapp` `` |
64+
| `:argparse:option:` | An optional flag, scoped by program | `` :argparse:option:`myapp --verbose` `` or `` :argparse:option:`myapp sync --force` `` |
65+
| `:argparse:subcommand:` | A subcommand under a parent program | `` :argparse:subcommand:`myapp sync` `` |
66+
| `:argparse:positional:` | A positional argument, scoped by program | `` :argparse:positional:`myapp FILE` `` |
67+
68+
Whitespace-joined targets (`myapp sync --force`) are split on the final
69+
space to match the stored `(program, name)` tuple. Bare forms
70+
(`--verbose`) also resolve when only one registration matches, though
71+
the fully-qualified form is preferred for multi-program sites.
72+
73+
### Auto-generated indices
74+
75+
Two domain indices are built into every project that loads the
76+
extension:
77+
78+
- `argparse-programsindex` — alphabetised list of every registered
79+
program; link via `` :ref:`argparse-programsindex` ``.
80+
- `argparse-optionsindex` — options grouped by program, alphabetised
81+
within each group; link via `` :ref:`argparse-optionsindex` ``.
82+
83+
### Intersphinx compatibility
84+
85+
The classic `:option:` / `std:cmdoption` emission is preserved — both
86+
roles resolve and both appear in `objects.inv`. Downstream consumers
87+
linking via intersphinx continue to work; new authoring inside
88+
projects using this extension can prefer the `:argparse:*` namespace
89+
for program-scoped clarity.
90+
5491
## Configuration values
5592

5693
### Base extension

0 commit comments

Comments
 (0)