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

Indirect reference targets fails to consider directive names #171

Open
fmigneault opened this issue Oct 9, 2024 · 0 comments
Open

Indirect reference targets fails to consider directive names #171

fmigneault opened this issue Oct 9, 2024 · 0 comments

Comments

@fmigneault
Copy link
Contributor

fmigneault commented Oct 9, 2024

Using the following combination:

.. |thing| replace:: *The Thing*
.. _thing: `thing-code`_

.. literalinclude:: code.py
    :language: python
    :caption: Code about |thing|
    :name: thing-code

See |thing|_.

Sphinx will correctly produce a "See The Thing.", where the link would anchor to the literal code. Note that this indirect link referencing is needed to add the style (italic) and alternate text simultaneously, since :ref: does not permit styling. In this specific case, it is also needed to avoid injecting the full caption (i.e.: Code about The Thing) each time a reference to |thing|_ is needed in the text.

However, doc8 will report something along the lines of:

D000 Indirect hyperlink target "thing" (id="thing") refers to target "thing-code", which does not exist.

This is a false positive from doc8, since this kind of resolution is supported.

This example only shows literalinclude, but there are many RST directives that provide similar :name: fields to allow cross-referencing.

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

1 participant