alex-rudakov / sphinx-argparse

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

Prepend prefix to all ids to guarantee that they are unique #125

Open wlupton opened 4 years ago

wlupton commented 4 years ago

I was including documentation for more than one python problem in the same file, and found that the ids were not unique, e.g.:

<div class="section" id="Named Arguments">

The suggested fix derives a prefix from func, ref etc. and passes it to ensureUniqueIDs(), which then unconditionally prefixes it to all ids to give, e.g.:

<div class="section" id="module-bin.onusim.argparser Named Arguments">

I realise it might be better to use a separate (new) function for doing this rather than overloading ensureUniqueIDs(), and would be happy to make this change.

laf0rge commented 3 years ago

Is there any news about this/ Patch has been around for 9 months without any positive or negative feedback.

I would definitely find it useful to have uinique ids/labels as I'm getting the following when documenting many Argparse instances in one .rst document:

/space/home/laforge/projects/git/pysim/docs/shell.rst:94: WARNING: duplicate label positional arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:94: WARNING: duplicate label named arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:101: WARNING: duplicate label positional arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:101: WARNING: duplicate label named arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:108: WARNING: duplicate label positional arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:108: WARNING: duplicate label named arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:115: WARNING: duplicate label positional arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:115: WARNING: duplicate label named arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:139: WARNING: duplicate label named arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:146: WARNING: duplicate label named arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:168: WARNING: duplicate label positional arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:168: WARNING: duplicate label named arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:175: WARNING: duplicate label positional arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:182: WARNING: duplicate label positional arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst
/space/home/laforge/projects/git/pysim/docs/shell.rst:190: WARNING: duplicate label positional arguments, other instance in /space/home/laforge/projects/git/pysim/docs/shell.rst