diff options
author | Georg Brandl <georg@python.org> | 2010-11-06 07:19:35 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-11-06 07:19:35 (GMT) |
commit | 6881886389ca422395a4c8156ae8aa6394904ea3 (patch) | |
tree | 4a5cb5731cec3bd7b842c28ced9b0de7b65f5f04 /Doc/tools/sphinxext/pyspecific.py | |
parent | 1cb25aa2e3d2df110b0a9ba6861537849b11e95a (diff) | |
download | cpython-6881886389ca422395a4c8156ae8aa6394904ea3.zip cpython-6881886389ca422395a4c8156ae8aa6394904ea3.tar.gz cpython-6881886389ca422395a4c8156ae8aa6394904ea3.tar.bz2 |
#10334: add a role to refer to Python source files in SVN.
Diffstat (limited to 'Doc/tools/sphinxext/pyspecific.py')
-rw-r--r-- | Doc/tools/sphinxext/pyspecific.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/Doc/tools/sphinxext/pyspecific.py b/Doc/tools/sphinxext/pyspecific.py index 0a5df83..2d9b359 100644 --- a/Doc/tools/sphinxext/pyspecific.py +++ b/Doc/tools/sphinxext/pyspecific.py @@ -10,8 +10,10 @@ """ ISSUE_URI = 'http://bugs.python.org/issue%s' +SOURCE_URI = 'http://svn.python.org/view/python/branches/py3k/%s?view=markup' from docutils import nodes, utils +from sphinx.util.nodes import split_explicit_title # monkey-patch reST parser to disable alphabetic and roman enumerated lists from docutils.parsers.rst.states import Body @@ -44,6 +46,16 @@ def issue_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): return [refnode], [] +# Support for linking to Python source files easily + +def source_role(typ, rawtext, text, lineno, inliner, options={}, content=[]): + has_t, title, target = split_explicit_title(text) + title = utils.unescape(title) + target = utils.unescape(target) + refnode = nodes.reference(title, title, refuri=SOURCE_URI % target) + return [refnode], [] + + # Support for marking up implementation details from sphinx.util.compat import Directive @@ -214,6 +226,7 @@ def parse_pdb_command(env, sig, signode): def setup(app): app.add_role('issue', issue_role) + app.add_role('source', source_role) app.add_directive('impl-detail', ImplementationDetail) app.add_builder(PydocTopicsBuilder) app.add_builder(suspicious.CheckSuspiciousMarkupBuilder) |