summaryrefslogtreecommitdiff
path: root/doc/conf.py
diff options
context:
space:
mode:
authorMartin Fischer <martin@push-f.com>2021-12-23 16:38:42 +0100
committerGitHub <noreply@github.com>2021-12-23 16:38:42 +0100
commit99f5bfa4ef66a6128f94a4d524135983b0e93225 (patch)
treecc2d8d290beaeb6aba0eb7603de419174f7bbadc /doc/conf.py
parent8630e033313647d9579e314f3e8e2882f4558933 (diff)
downloadpygments-git-99f5bfa4ef66a6128f94a4d524135983b0e93225.tar.gz
Linkify GitHub issue/PR numbers in changelog (#1998)
Diffstat (limited to 'doc/conf.py')
-rw-r--r--doc/conf.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/doc/conf.py b/doc/conf.py
index 3d127c70..264899be 100644
--- a/doc/conf.py
+++ b/doc/conf.py
@@ -2,7 +2,7 @@
# Pygments documentation build configuration file
#
-import sys, os, itertools
+import re, sys, os, itertools
# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
@@ -260,5 +260,22 @@ def pg_context(app, pagename, templatename, ctx, event_arg):
ctx['styles_sub_aa'].sort(key=lambda s: (-s['bg_luminance'], s['name']))
+def source_read(app, docname, source):
+ # linkify issue / PR numbers in changelog
+ if docname == 'docs/changelog':
+ with open('../CHANGES') as f:
+ changelog = f.read()
+
+ idx = changelog.find('\nVersion 2.4.2\n')
+
+ def linkify(match):
+ url = 'https://github.com/pygments/pygments/issues/' + match[1]
+ return '`{} <{}>`_'.format(match[0], url)
+
+ linkified = re.sub(r'(?:PR)?#([0-9]+)\b', linkify, changelog[:idx])
+ source[0] = linkified + changelog[idx:]
+
+
def setup(app):
app.connect('html-page-context', pg_context)
+ app.connect('source-read', source_read)