Skip to content
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

Provide a way to specify a prefix for generated header references #11

Open
fmigneault opened this issue Feb 11, 2022 · 1 comment
Open

Comments

@fmigneault
Copy link

Given an argparse that produces an application with the following signature (I leave out the implementation details):

prog --opt command 

Using this extension, the generated documentation from the python definitions will have a structure similar to the following:

-------------------
Optional Arguments
-------------------

~~~~~
--opt
~~~~~

some description

-------------------
command
-------------------

Possible choices: cmd1, cmd2

~~~~~
cmd1
~~~~~

[...]

~~~~~
cmd2
~~~~~

[...]

Using extensions like sphinx.ext.autosectionlabel, the command header gets automatically attributed a label that can be referenced as :ref:`command`. The same #command anchor is also created in HTML for example.

If the page where the .. argparse:: directive is included already contained another section named command (with or without an explicit reference label), there is no way to tell Sphinx/RST how to distinguish between the already present command section and the one generated by sphinx-argparse. Since documentation often has to refer to the same concepts and the "command" offered by the CLI, it is not unlikely to have the same headers defined somewhere else.

It would be useful for this extension to provide some sort of :ref-prefix: parameter that would be applied to all sections generated by it.
For example, providing :ref-prefix: argparse_prog_ to .. argparse:: would generate the anchor reference as argparse_prog_command rather than command by itself, allowing documentation to refer to this section explicitly when needed and without conflict with any existing command section header.

@djhoese
Copy link

djhoese commented Jan 17, 2024

Related #44 and #43

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

No branches or pull requests

2 participants