diff --git a/sphinx/roles.py b/sphinx/roles.py index c36ed2613..c77feeb62 100644 --- a/sphinx/roles.py +++ b/sphinx/roles.py @@ -277,11 +277,11 @@ class PEP(ReferenceRole): def build_uri(self): # type: () -> str base_url = self.inliner.document.settings.pep_base_url - target, anchor = self.target.split('#', 1) - if anchor: - return base_url + 'pep-%04d#%s' % (int(target), anchor) + ret = self.target.split('#', 1) + if len(ret) == 2: + return base_url + 'pep-%04d#%s' % (int(ret[0]), ret[1]) else: - return base_url + 'pep-%04d' % int(target) + return base_url + 'pep-%04d' % int(ret[0]) class RFC(ReferenceRole): @@ -312,13 +312,12 @@ class RFC(ReferenceRole): def build_uri(self): # type: () -> str - target, anchor = self.target.split('#', 1) - base_url = (self.inliner.document.settings.rfc_base_url + - self.inliner.rfc_url % int(target)) - if anchor: - return base_url + '#' + anchor + base_url = self.inliner.document.settings.rfc_base_url + ret = self.target.split('#', 1) + if len(ret) == 2: + return base_url + self.inliner.rfc_url % int(ret[0]) + '#' + ret[1] else: - return base_url + return base_url + self.inliner.rfc_url % int(ret[0]) _amp_re = re.compile(r'(?PEP 8
'), + ('\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}' + '!PEP 8@\\spxentry{PEP 8}}\\sphinxhref{http://www.python.org/dev/peps/pep-0008}' + '{\\sphinxstylestrong{PEP 8}}') + ), + ( + # pep role with anchor + 'verify', + ':pep:`8#id1`', + (''), + ('\\index{Python Enhancement Proposals@\\spxentry{Python Enhancement Proposals}' + '!PEP 8\\#id1@\\spxentry{PEP 8\\#id1}}\\sphinxhref' + '{http://www.python.org/dev/peps/pep-0008\\#id1}' + '{\\sphinxstylestrong{PEP 8\\#id1}}') + ), + ( + # rfc role + 'verify', + ':rfc:`2324`', + (''), + ('\\index{RFC@\\spxentry{RFC}!RFC 2324@\\spxentry{RFC 2324}}' + '\\sphinxhref{http://tools.ietf.org/html/rfc2324.html}' + '{\\sphinxstylestrong{RFC 2324}}') + ), + ( + # rfc role with anchor + 'verify', + ':rfc:`2324#id1`', + (''), + ('\\index{RFC@\\spxentry{RFC}!RFC 2324\\#id1@\\spxentry{RFC 2324\\#id1}}' + '\\sphinxhref{http://tools.ietf.org/html/rfc2324.html\\#id1}' + '{\\sphinxstylestrong{RFC 2324\\#id1}}') + ), ( # correct interpretation of code with whitespace 'verify_re',