alex-rudakov / sphinx-argparse

Sphinx extension that automatically document argparse commands and options
MIT License
49 stars 40 forks source link

Section numbers wrong when multiple argparse directives used in single page #127

Open djhoese opened 4 years ago

djhoese commented 4 years ago

I have a documentation page that lists a series of utility scripts like:

Utility Scripts
===============

Stuff about utility scripts.

Util Script 1
-------------

.. argparse::
    :module: mypkg.utilscript1
    :func: get_parser
    :prog: util_script1.sh
    :nodefaultconst:

Example:

Some more stuff

Util Script 2
-------------

.. argparse::
    :module: mypkg.utilscript2
    :func: get_parser
    :prog: util_script2.sh
    :nodefaultconst:

Example:

Some more stuff

But when I render this, Sphinx can't tell the difference between the two "Positional Arguments" and "Named Arguments" section so it chooses the section numbers based on the last sections with those titles. So if "Utility Scripts" page is number 7, then "Util Script 1" is 7.1 and "Util Script 2" is 7.2, but the first "Positional Arguments" is 7.2.1, the first "Named Arguments" is 7.2.2, and but so are the second "Positional Arguments" and "Named Arguments" sections (7.2.1, 7.2.2). Any idea how I can get around this?