Closed djhoese closed 1 day ago
So the primary issue stems from the ID of the section being based on the section title:
But those section titles are always the same:
So I see a couple solutions:
id_prefix
. Another option for something so small and low-level seems annoying. Could also be the user can specify the ID in its entirety.ext.py
to make them depend on the uniqueness of something outside of sphinx-argparse.Ah option 2 wouldn't work if we're just using the parent node information as you could technically have two .. argparse::
directives in the same parent section.
I have a similar request: I would like to not have the headings Positional Arguments
and Named Arguments
at all (or have them not as headers). These headers give a messy TOC in the sidebar, e.g.:
One could have an option :noheaders:
, e.g.:
.. argparse::
:module: foo
:func: _bar_parser
:prog: bar
:noheaders:
Yeah I thought I about adding something like that in my PR for fixing my need in https://github.com/ashb/sphinx-argparse/pull/44. Or rather letting the user specify each header. Like :posheader: ""
and :namedheader: ""
would remove the section titles. Actually maybe they should be referred to as titles, not headers.
That said, your request brings up a harder question to answer. At least it makes me scratch my head. What does a section without a title look like? See this code in my PR for what I mean:
It's creating a section node then a title for that section. The docutils docs say that a section has a title: https://docutils.sourceforge.io/docs/ref/doctree.html#section. I'm not sure it is possible to have a section without a title. So then to make your request work you'd be talking about no sections at all...I suppose that might work. Might be some ugly if-statements, but could work.
Sorry, just brainstorming.
This is a rewrite of https://github.com/alex-rudakov/sphinx-argparse/issues/127 from the old project, but I've made it into a smaller reproducible example. The summary of the issue is that Named Arguments and Options sections in a single restructuredtext document (~or maybe a single sphinx project~) that has a
:numbered:
TOC tree will always use the section number from the last.. argparse::
directive.myproj.py
index.rst
utils.rst
Then generate the docs with:
And open
built/utils.html
in a browser. You'll see something like:Notice how the "Named Arguments" sections have the same section number. They should be 1.1.1 and 1.2.1.