mkdocstrings / python

A Python handler for mkdocstrings.
https://mkdocstrings.github.io/python
ISC License
184 stars 33 forks source link

change: unique source code span and codeline IDs #200

Open brynpickering opened 2 hours ago

brynpickering commented 2 hours ago

Is your change request related to a problem? Please describe.

When using show_source the code snippet has a span and codelineno ID per line, e.g. </span><span id="__span-0-35"><a id="__codelineno-0-35" name="__codelineno-0-35"></a>.

If referencing the same line in two different code snippets (e.g. the same line from two different modules given on the same page or the same method being referenced as it is inherited from the parent abstract base class in a module), there are duplicate instances of the same spand and codeline ID. Accessibility checkers complain about this, and with good reason!

Describe the solution you'd like

Ideally, each source code snippet would have some kind of unique code (maybe a random hash?) that is added to the IDs.

Describe alternatives you've considered

For now, I've simply ignored these types of IDs in my Accessibility checker, but it is non-ideal...

Additional context

pawamoy commented 2 hours ago

Hi @brynpickering, thanks for the change request.

Can you share your config, particularly pymdownx's?