mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Allow references to PEPs and RFCs with explicit anchors.
This commit is contained in:
parent
279d025ffe
commit
92142bbdb6
2
CHANGES
2
CHANGES
@ -1,6 +1,8 @@
|
|||||||
Release 1.0.2 (in development)
|
Release 1.0.2 (in development)
|
||||||
==============================
|
==============================
|
||||||
|
|
||||||
|
* Allow references to PEPs and RFCs with explicit anchors.
|
||||||
|
|
||||||
* #471: Fix LaTeX references to figures.
|
* #471: Fix LaTeX references to figures.
|
||||||
|
|
||||||
* #482: When doing a non-exact search, match only the given type
|
* #482: When doing a non-exact search, match only the given type
|
||||||
|
@ -274,13 +274,15 @@ The following roles generate external links:
|
|||||||
|
|
||||||
A reference to a Python Enhancement Proposal. This generates appropriate
|
A reference to a Python Enhancement Proposal. This generates appropriate
|
||||||
index entries. The text "PEP *number*\ " is generated; in the HTML output,
|
index entries. The text "PEP *number*\ " is generated; in the HTML output,
|
||||||
this text is a hyperlink to an online copy of the specified PEP.
|
this text is a hyperlink to an online copy of the specified PEP. You can
|
||||||
|
link to a specific section by saying ``:pep:`number#anchor```.
|
||||||
|
|
||||||
.. rst:role:: rfc
|
.. rst:role:: rfc
|
||||||
|
|
||||||
A reference to an Internet Request for Comments. This generates appropriate
|
A reference to an Internet Request for Comments. This generates appropriate
|
||||||
index entries. The text "RFC *number*\ " is generated; in the HTML output,
|
index entries. The text "RFC *number*\ " is generated; in the HTML output,
|
||||||
this text is a hyperlink to an online copy of the specified RFC.
|
this text is a hyperlink to an online copy of the specified RFC. You can
|
||||||
|
link to a specific section by saying ``:rfc:`number#anchor```.
|
||||||
|
|
||||||
|
|
||||||
Note that there are no special roles for including hyperlinks as you can use
|
Note that there are no special roles for including hyperlinks as you can use
|
||||||
|
@ -173,6 +173,10 @@ def indexmarkup_role(typ, rawtext, etext, lineno, inliner,
|
|||||||
indexnode['entries'] = [
|
indexnode['entries'] = [
|
||||||
('single', _('Python Enhancement Proposals!PEP %s') % text,
|
('single', _('Python Enhancement Proposals!PEP %s') % text,
|
||||||
targetid, 'PEP %s' % text)]
|
targetid, 'PEP %s' % text)]
|
||||||
|
anchor = ''
|
||||||
|
anchorindex = text.find('#')
|
||||||
|
if anchorindex > 0:
|
||||||
|
text, anchor = text[:anchorindex], text[anchorindex:]
|
||||||
try:
|
try:
|
||||||
pepnum = int(text)
|
pepnum = int(text)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -182,12 +186,17 @@ def indexmarkup_role(typ, rawtext, etext, lineno, inliner,
|
|||||||
return [prb], [msg]
|
return [prb], [msg]
|
||||||
ref = inliner.document.settings.pep_base_url + 'pep-%04d' % pepnum
|
ref = inliner.document.settings.pep_base_url + 'pep-%04d' % pepnum
|
||||||
sn = nodes.strong('PEP '+text, 'PEP '+text)
|
sn = nodes.strong('PEP '+text, 'PEP '+text)
|
||||||
rn = nodes.reference('', '', internal=False, refuri=ref, classes=[typ])
|
rn = nodes.reference('', '', internal=False, refuri=ref+anchor,
|
||||||
|
classes=[typ])
|
||||||
rn += sn
|
rn += sn
|
||||||
return [indexnode, targetnode, rn], []
|
return [indexnode, targetnode, rn], []
|
||||||
elif typ == 'rfc':
|
elif typ == 'rfc':
|
||||||
indexnode['entries'] = [('single', 'RFC; RFC %s' % text,
|
indexnode['entries'] = [('single', 'RFC; RFC %s' % text,
|
||||||
targetid, 'RFC %s' % text)]
|
targetid, 'RFC %s' % text)]
|
||||||
|
anchor = ''
|
||||||
|
anchorindex = text.find('#')
|
||||||
|
if anchorindex > 0:
|
||||||
|
text, anchor = text[:anchorindex], text[anchorindex:]
|
||||||
try:
|
try:
|
||||||
rfcnum = int(text)
|
rfcnum = int(text)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -197,7 +206,8 @@ def indexmarkup_role(typ, rawtext, etext, lineno, inliner,
|
|||||||
return [prb], [msg]
|
return [prb], [msg]
|
||||||
ref = inliner.document.settings.rfc_base_url + inliner.rfc_url % rfcnum
|
ref = inliner.document.settings.rfc_base_url + inliner.rfc_url % rfcnum
|
||||||
sn = nodes.strong('RFC '+text, 'RFC '+text)
|
sn = nodes.strong('RFC '+text, 'RFC '+text)
|
||||||
rn = nodes.reference('', '', internal=False, refuri=ref, classes=[typ])
|
rn = nodes.reference('', '', internal=False, refuri=ref+anchor,
|
||||||
|
classes=[typ])
|
||||||
rn += sn
|
rn += sn
|
||||||
return [indexnode, targetnode, rn], []
|
return [indexnode, targetnode, rn], []
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user