Skip to content

Commit 6f583d2

Browse files
committed
PEP 12: Recommend and further explain using RST links, not footnotes
1 parent 670de66 commit 6f583d2

File tree

3 files changed

+75
-25
lines changed

3 files changed

+75
-25
lines changed

pep-0001.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,8 @@ Each PEP should have the following parts/sections:
510510
ready for consideration are complete and reduces people duplicating
511511
prior discussion.
512512

513-
12. References -- A collection of URLs used as references through the PEP.
513+
12. References -- A collection of footnotes referenced in the PEP, and
514+
a central place to list non-inline hyperlink targets.
514515

515516
13. Copyright/license -- Each new PEP must be placed under a dual license of
516517
public domain and CC0-1.0-Universal_ (see this PEP for an example).

pep-0012.rst

Lines changed: 72 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -137,13 +137,8 @@ directions below.
137137
prohibition of tab characters and the indentation requirements.
138138
See "Suggested Sections" below for a template of sections to include.
139139

140-
- Update your References and Copyright section. Usually you'll place
141-
your PEP into the public domain, in which case just leave the
142-
Copyright section alone. Alternatively, you can use the `Open
143-
Publication License`__, but public domain is still strongly
144-
preferred.
145-
146-
__ http://www.opencontent.org/openpub/
140+
- Update your References section, listing any footnotes and
141+
non-inline link targets referenced by the text.
147142

148143
- Leave the Emacs stanza at the end of this file alone, including the
149144
formfeed character ("^L", or ``\f``).
@@ -438,43 +433,92 @@ Hyperlinks
438433
----------
439434

440435
When referencing an external web page in the body of a PEP, you should
441-
include the title of the page in the text, with either an inline
442-
hyperlink reference to the URL or a footnote reference (see
443-
`Footnotes`_ below). Do not include the URL in the body text of the
444-
PEP.
436+
include the title of the page or a suitable description in the text, with
437+
either an inline hyperlink or a separate explicit target with the URL.
438+
Do not include bare URLs in the body text of the PEP, and use HTTPS
439+
links wherever available.
445440

446441
Hyperlink references use backquotes and a trailing underscore to mark
447442
up the reference text; backquotes are optional if the reference text
448-
is a single word. For example::
443+
is a single word. For example, to reference a hyperlink target named
444+
``Python web site``, you would write:
445+
446+
.. code-block:: rst
447+
448+
In this paragraph, we refer to the `Python web site`_.
449+
450+
which renders as:
449451

450452
In this paragraph, we refer to the `Python web site`_.
451453

452-
An explicit target provides the URL. Put targets in a References
453-
section at the end of the PEP, or immediately after the reference.
454+
.. _Python web site: https://www.python.org/
455+
456+
If you intend to only reference a link once, and want to define it inline
457+
with the text, insert the link into angle brackets (``<>``) after the text
458+
you want to link, but before the closing backtick, with a space between the
459+
text and the opening backtick. You should also use a double-underscore after
460+
the closing backtick instead of a single one, which makes it an anonymous
461+
reference to avoid conflicting with other target names. For example:
462+
463+
.. code-block:: rst
464+
465+
Visit the `website <https://www.python.org/>`__ for more.
466+
467+
which displays as:
468+
469+
Visit the `website <https://www.python.org/>`__ for more.
470+
471+
.. _Python web site: https://www.python.org/
472+
473+
If you want to use one link multiple places with different linked text,
474+
or want to ensure you don't have to update your link target names when
475+
changing the linked text, include the target name within angle brackets
476+
following the text to link, *with an underscore after the target name
477+
but before the closing angle bracket* (or the link **will not work**).
478+
479+
For example:
480+
481+
.. code-block:: rst
482+
483+
For further examples, see the `documentation <pydocs_>`_.
484+
485+
which like the above, renders as:
486+
487+
For further examples, see the `documentation <pydocs_>`_.
488+
489+
.. _pydocs: https://docs.python.org/
490+
491+
An explicit target provides the URL. Put targets in a References section
492+
at the end of the PEP, or immediately after the paragraph with the reference.
454493
Hyperlink targets begin with two periods and a space (the "explicit
455494
markup start"), followed by a leading underscore, the reference text,
456-
a colon, and the URL (absolute or relative)::
495+
a colon, and the URL.
457496

458-
.. _Python web site: http://www.python.org/
497+
.. code-block:: rst
498+
499+
.. _Python web site: https://www.python.org/
500+
.. _pydocs: https://docs.python.org/
459501
460502
The reference text and the target text must match (although the match
461503
is case-insensitive and ignores differences in whitespace). Note that
462504
the underscore trails the reference text but precedes the target text.
463505
If you think of the underscore as a right-pointing arrow, it points
464506
*away* from the reference and *toward* the target.
465507

466-
The same mechanism can be used for internal references. Every unique
467-
section title implicitly defines an internal hyperlink target. We can
468-
make a link to the Abstract section like this::
508+
509+
Internal and PEP/RFC Links
510+
--------------------------
511+
512+
The same mechanism as hyperlinks can be used for internal references.
513+
Every unique section title implicitly defines an internal hyperlink target.
514+
We can make a link to the Abstract section like this:
515+
516+
.. code-block:: rst
469517
470518
Here is a hyperlink reference to the `Abstract`_ section. The
471519
backquotes are optional since the reference text is a single word;
472520
we can also just write: Abstract_.
473521
474-
Footnotes containing the URLs from external targets will be generated
475-
automatically at the end of the References section of the PEP, along
476-
with footnote references linking the reference text to the footnotes.
477-
478522
To refer to PEPs or RFCs, always use the ``:pep:`` and ``:rfc:`` roles,
479523
never hardcoded URLs.
480524
For example:
@@ -507,6 +551,11 @@ right square bracket, and a trailing underscore:
507551
Whitespace must precede the footnote reference. Leave a space between
508552
the footnote reference and the preceding word.
509553

554+
Use footnotes for additional notes, explanations and caveats, as well as
555+
for references to books and other sources not readily available online.
556+
Native reST hyperlink targets or inline hyperlinks in the text should be
557+
used in preference to footnotes for including URLs to online resources.
558+
510559
Footnotes begin with ".. " (the explicit
511560
markup start), followed by the footnote marker (no underscores),
512561
followed by the footnote body. For example:

pep-0012/pep-NNNN.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Open Issues
7878
References
7979
==========
8080

81-
[A collection of URLs used as references through the PEP.]
81+
[A collection of footnotes referenced in the PEP, and a central place to list non-inline hyperlink targets.]
8282

8383

8484
Copyright

0 commit comments

Comments
 (0)