summaryrefslogtreecommitdiff
path: root/doc/conf.py
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2022-01-08 07:12:33 +0100
committerMartin Fischer <martin@push-f.com>2022-01-08 15:57:16 +0100
commiteab7efc33331d3ca5ced5f3d0caee7a99a01381e (patch)
tree0f2529a1f50c76eb62c26008acc3c11411a55592 /doc/conf.py
parentb5ef0996cae9ee5bb0d6b340737e9acaec7a8d50 (diff)
downloadsphinx-git-eab7efc33331d3ca5ced5f3d0caee7a99a01381e.tar.gz
doc: Linkify issue numbers in changelog to GitHub
Diffstat (limited to 'doc/conf.py')
-rw-r--r--doc/conf.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/doc/conf.py b/doc/conf.py
index 3b39aa6d5..ccc2788f0 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -1,5 +1,6 @@
# Sphinx documentation build configuration file
+import os
import re
import sphinx
@@ -139,10 +140,33 @@ def parse_event(env, sig, signode):
return name
+def linkify_issues_in_changelog(app, docname, source):
+ """ Linkify issue references like #123 in changelog to GitHub. """
+
+ if docname == 'changes':
+ changelog_path = os.path.join(os.path.dirname(__file__), "../CHANGES")
+ # this path trickery is needed because this script can
+ # be invoked with different working directories:
+ # * running make in docs/
+ # * running python setup.py build_sphinx in the repo root dir
+
+ with open(changelog_path) as f:
+ changelog = f.read()
+
+ def linkify(match):
+ url = 'https://github.com/sphinx-doc/sphinx/issues/' + match[1]
+ return '`{} <{}>`_'.format(match[0], url)
+
+ linkified_changelog = re.sub(r'(?:PR)?#([0-9]+)\b', linkify, changelog)
+
+ source[0] = source[0].replace('.. include:: ../CHANGES', linkified_changelog)
+
+
def setup(app):
from sphinx.ext.autodoc import cut_lines
from sphinx.util.docfields import GroupedField
app.connect('autodoc-process-docstring', cut_lines(4, what=['module']))
+ app.connect('source-read', linkify_issues_in_changelog)
app.add_object_type('confval', 'confval',
objname='configuration value',
indextemplate='pair: %s; configuration value')