docs: fix broken :ref: references in man pages, fixes #7239

This commit is contained in:
Mrityunjay Raj 2026-02-16 22:36:07 +05:30
parent eb7502ee50
commit f1ed09965f
2 changed files with 7 additions and 0 deletions

View file

@ -178,6 +178,7 @@ Other changes:
- fix S3 url description, #9249
- add a note that you need to install boto3 if you want to use S3/B2 URLs
- man pages: fix broken :ref: references (e.g. borg_patterns), #7239
Version 2.0.0b20 (2025-12-24)

View file

@ -485,11 +485,17 @@ class BuildMan:
from docutils.core import publish_string
from docutils.nodes import inline
from docutils.parsers.rst import roles
from borg.archiver._common import rst_plain_text_references
def issue(name, rawtext, text, lineno, inliner, options={}, content=[]):
return [inline(rawtext, "#" + text)], []
def ref_role(name, rawtext, text, lineno, inliner, options={}, content=[]):
replacement = rst_plain_text_references.get(text, text)
return [inline(rawtext, replacement)], []
roles.register_local_role("issue", issue)
roles.register_local_role("ref", ref_role)
# We give the source_path so that docutils can find relative includes
# as-if the document where located in the docs/ directory.
man_page = publish_string(source=rst, source_path="docs/%s.rst" % name, writer=manpage.Writer())