Skip to content

Indirect reference targets fails to consider directive names #171

Open
@fmigneault

Description

@fmigneault

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions