mirror of
https://github.com/python/cpython.git
synced 2025-11-01 10:45:30 +00:00
#10334: add a role to refer to Python source files in SVN.
This commit is contained in:
parent
1cb25aa2e3
commit
6881886389
1 changed files with 13 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue