From c30519219627ddad24b3c60f419683183ae19c20 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Wed, 9 Apr 2008 17:58:56 +0000 Subject: [PATCH] Add :issue: directive for easy linking to bugs.python.org. --- Doc/conf.py | 2 +- Doc/tools/sphinxext/pyspecific.py | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 Doc/tools/sphinxext/pyspecific.py diff --git a/Doc/conf.py b/Doc/conf.py index f6c08c51786..6a452420fe3 100644 --- a/Doc/conf.py +++ b/Doc/conf.py @@ -14,7 +14,7 @@ sys.path.append('tools/sphinxext') # --------------------- extensions = ['sphinx.ext.refcounting', 'sphinx.ext.coverage', - 'sphinx.ext.doctest'] + 'sphinx.ext.doctest', 'pyspecific'] templates_path = ['tools/sphinxext'] # General substitutions. diff --git a/Doc/tools/sphinxext/pyspecific.py b/Doc/tools/sphinxext/pyspecific.py new file mode 100644 index 00000000000..f7c0daa1d9a --- /dev/null +++ b/Doc/tools/sphinxext/pyspecific.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +""" + pyspecific.py + ~~~~~~~~~~~~~ + + Sphinx extension with Python doc-specific markup. + + :copyright: 2008 by Georg Brandl. + :license: Python license. +""" + +ISSUE_URI = 'http://bugs.python.org/issue%s' + +from docutils import nodes, utils + +def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): + issue = utils.unescape(text) + text = 'issue ' + issue + refnode = nodes.reference(text, text, refuri=ISSUE_URI % issue) + return [refnode], [] + + +def setup(app): + app.add_role('issue', issue_role)