diff options
author | tk0miya <i.tkomiya@gmail.com> | 2014-08-20 12:21:18 +0900 |
---|---|---|
committer | tk0miya <i.tkomiya@gmail.com> | 2014-08-20 12:21:18 +0900 |
commit | 3b6930d27d18b2fbedc198293f269f62fb46ed60 (patch) | |
tree | bf1360a90acb50f516707f3c569e098aa91e845e | |
parent | a3573bd3a654db53debba44740d4ba81b655090d (diff) | |
download | sphinx-3b6930d27d18b2fbedc198293f269f62fb46ed60.tar.gz |
Backed out changeset 177fce4ba59c
-rw-r--r-- | sphinx/roles.py | 34 | ||||
-rw-r--r-- | tests/root/markup.txt | 2 | ||||
-rw-r--r-- | tests/test_build_html.py | 4 |
3 files changed, 14 insertions, 26 deletions
diff --git a/sphinx/roles.py b/sphinx/roles.py index aaf6272b..122c5285 100644 --- a/sphinx/roles.py +++ b/sphinx/roles.py @@ -158,7 +158,7 @@ class XRefRole(object): return [node], [] -def indexmarkup_role(typ, rawtext, text, lineno, inliner, +def indexmarkup_role(typ, rawtext, etext, lineno, inliner, options={}, content=[]): """Role for PEP/RFC references that generate an index entry.""" env = inliner.document.settings.env @@ -166,53 +166,47 @@ def indexmarkup_role(typ, rawtext, text, lineno, inliner, typ = env.config.default_role else: typ = typ.lower() - has_explicit_title, title, target = split_explicit_title(text) - title = utils.unescape(title) - target = utils.unescape(target) + text = utils.unescape(etext) targetid = 'index-%s' % env.new_serialno('index') indexnode = addnodes.index() targetnode = nodes.target('', '', ids=[targetid]) inliner.document.note_explicit_target(targetnode) if typ == 'pep': indexnode['entries'] = [ - ('single', _('Python Enhancement Proposals; PEP %s') % target, + ('single', _('Python Enhancement Proposals; PEP %s') % text, targetid, '')] anchor = '' - anchorindex = target.find('#') + anchorindex = text.find('#') if anchorindex > 0: - target, anchor = target[:anchorindex], target[anchorindex:] - if not has_explicit_title: - title = "PEP " + utils.unescape(title) + text, anchor = text[:anchorindex], text[anchorindex:] try: - pepnum = int(target) + pepnum = int(text) except ValueError: - msg = inliner.reporter.error('invalid PEP number %s' % target, + msg = inliner.reporter.error('invalid PEP number %s' % text, line=lineno) prb = inliner.problematic(rawtext, rawtext, msg) return [prb], [msg] ref = inliner.document.settings.pep_base_url + 'pep-%04d' % pepnum - sn = nodes.strong(title, title) + sn = nodes.strong('PEP '+text, 'PEP '+text) rn = nodes.reference('', '', internal=False, refuri=ref+anchor, classes=[typ]) rn += sn return [indexnode, targetnode, rn], [] elif typ == 'rfc': - indexnode['entries'] = [('single', 'RFC; RFC %s' % target, targetid, '')] + indexnode['entries'] = [('single', 'RFC; RFC %s' % text, targetid, '')] anchor = '' - anchorindex = target.find('#') + anchorindex = text.find('#') if anchorindex > 0: - target, anchor = target[:anchorindex], target[anchorindex:] - if not has_explicit_title: - title = "RFC " + utils.unescape(title) + text, anchor = text[:anchorindex], text[anchorindex:] try: - rfcnum = int(target) + rfcnum = int(text) except ValueError: - msg = inliner.reporter.error('invalid RFC number %s' % target, + msg = inliner.reporter.error('invalid RFC number %s' % text, line=lineno) prb = inliner.problematic(rawtext, rawtext, msg) return [prb], [msg] ref = inliner.document.settings.rfc_base_url + inliner.rfc_url % rfcnum - sn = nodes.strong(title, title) + sn = nodes.strong('RFC '+text, 'RFC '+text) rn = nodes.reference('', '', internal=False, refuri=ref+anchor, classes=[typ]) rn += sn diff --git a/tests/root/markup.txt b/tests/root/markup.txt index f6f955e2..7ce721ba 100644 --- a/tests/root/markup.txt +++ b/tests/root/markup.txt @@ -132,9 +132,7 @@ Adding \n to test unescaping. *Linking inline markup* * :pep:`8` -* :pep:`Python Enhancement Proposal #8 <8>` * :rfc:`1` -* :rfc:`Request for Comments #1 <1>` * :envvar:`HOME` * :keyword:`with` * :token:`try statement <try_stmt>` diff --git a/tests/test_build_html.py b/tests/test_build_html.py index 17a09eae..d13c7ac6 100644 --- a/tests/test_build_html.py +++ b/tests/test_build_html.py @@ -129,12 +129,8 @@ HTML_XPATH = { (".//li/code/em/span[@class='pre']", '^i$'), (".//a[@href='http://www.python.org/dev/peps/pep-0008']" "[@class='pep reference external']/strong", 'PEP 8'), - (".//a[@href='http://www.python.org/dev/peps/pep-0008']" - "[@class='pep reference external']/strong", 'Python Enhancement Proposal #8'), (".//a[@href='http://tools.ietf.org/html/rfc1.html']" "[@class='rfc reference external']/strong", 'RFC 1'), - (".//a[@href='http://tools.ietf.org/html/rfc1.html']" - "[@class='rfc reference external']/strong", 'Request for Comments #1'), (".//a[@href='objects.html#envvar-HOME']" "[@class='reference internal']/code/span[@class='pre']", 'HOME'), (".//a[@href='#with']" |