Add :issue: directive for easy linking to bugs.python.org.

This commit is contained in:
Georg Brandl 2008-04-09 17:58:56 +00:00
parent 99bb5f3fef
commit c305192196
2 changed files with 25 additions and 1 deletions

View File

@ -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.

View File

@ -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)