Skip to content

doc8 emits false positives for link targets defined in rst_prolog #125

Open
@Julian

Description

Given a conf.py containing:

project = "foo"
copyright = "2022, Julian Berman"
author = "Julian Berman"

rst_prolog = """
.. _example: https://example.com
"""

with an example link defined in the rst_prolog, and a simple index.rst using the target:

Foo
===

This is an `example`_.

doc8 emits:

~/Desktop/foo/docs is a git repository on main 
⊙  doc8 .                                                                                                                         julian@Airm ●
Scanning...
Validating...
./index.rst:4: D000 Unknown target name: "example".
/Users/julian/.dotfiles/.local/share/virtualenvs/doc8/lib/python3.10/site-packages/doc8/parser.py:69: DeprecationWarning: The frontend.OptionParser class will be replaced by a subclass of argparse.ArgumentParser in Docutils 0.21 or later.
  opt = frontend.OptionParser(components=[parser], defaults=defaults)
/opt/homebrew/Cellar/[email protected]/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/optparse.py:1000: DeprecationWarning: The frontend.Option class will be removed in Docutils 0.21 or later.
  option = self.option_class(*args, **kwargs)
========
Total files scanned = 1
Total files ignored = 0
Total accumulated errors = 1
Detailed error counts:
    - doc8.checks.CheckCarriageReturn = 0
    - doc8.checks.CheckIndentationNoTab = 0
    - doc8.checks.CheckMaxLineLength = 0
    - doc8.checks.CheckNewlineEndOfFile = 0
    - doc8.checks.CheckTrailingWhitespace = 0
    - doc8.checks.CheckValidity = 1

~/Desktop/foo/docs is a git repository on main 
⊙  doc8 --version                                                                                                                 julian@Airm ●
1.0.0

flagging the link as an error, but this is incorrect, and make html will succeed just fine (and produce a page linking to the correct link target).

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