mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-25 13:06:08 +00:00

Github links in release notes are often invalid rST, clutter the release notes and are annoying to write. This introduces a sphynx plugin that rewrites `#GH<NUMBER>` to a link to the corresponding issue.
20 lines
511 B
Python
20 lines
511 B
Python
#!/usr/bin/env python3
|
|
|
|
from sphinx.application import Sphinx
|
|
import re
|
|
|
|
__version__ = "1.0"
|
|
|
|
|
|
def subst_gh_links(app: Sphinx, docname, source):
|
|
regex = re.compile("#GH([0-9]+)")
|
|
out_pattern = r"`#\1 <https://github.com/llvm/llvm-project/issues/\1>`_"
|
|
result = source[0]
|
|
result = regex.sub(out_pattern, result)
|
|
source[0] = result
|
|
|
|
|
|
def setup(app: Sphinx):
|
|
app.connect("source-read", subst_gh_links)
|
|
return dict(version=__version__, parallel_read_safe=True, parallel_write_safe=True)
|