Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PEP 12: Update guidance on linking PEPs/RFCs per recent changes, and add check for it #2291

Merged
merged 2 commits into from
Feb 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,16 @@ repos:
args: ['--multiline']
files: '^pep-\d+\.(rst|txt)$'
types: [text]
- id: check-direct-pep-links
name: "Check that PEPs aren't linked directly"
language: pygrep
entry: 'dev/peps/pep-\d+'
files: '^pep-\d+\.(rst|txt)$'
exclude: '^pep-(0009|0287|8001)\.(rst|txt)$'
types: [text]
- id: check-direct-rfc-links
name: "Check that RFCs aren't linked directly"
language: pygrep
entry: '(rfc-editor\.org|ietf\.org)/[\.\-_\?\&\#\w/]*[Rr][Ff][Cc][\-_]?\d+'
files: '\.(rst|txt)$'
types: [text]
61 changes: 32 additions & 29 deletions pep-0012.rst
Original file line number Diff line number Diff line change
Expand Up @@ -475,68 +475,71 @@ Footnotes containing the URLs from external targets will be generated
automatically at the end of the References section of the PEP, along
with footnote references linking the reference text to the footnotes.

Text of the form "PEP x" or "RFC x" (where "x" is a number) will be
linked automatically to the appropriate URLs.
To refer to PEPs or RFCs, always use the ``:pep:`` and ``:rfc:`` roles,
never hardcoded URLs.
For example:

.. code-block:: rst

See :pep:`1` for more information on how to write a PEP,
and :pep:`the Hyperlink section of PEP 12 <12#hyperlinks>` for how to link.

This renders as:

See :pep:`1` for more information on how to write a PEP,
and :pep:`the Hyperlink section of PEP 12 <12#hyperlinks>` for how to link.

PEP numbers in the text are never padded, and there is a space (not a dash)
between "PEP" or "RFC" and the number; the above roles will take care of
that for you.


Footnotes
---------

Footnote references consist of a left square bracket, a number, a
right square bracket, and a trailing underscore::
right square bracket, and a trailing underscore:

.. code-block:: rst

This sentence ends with a footnote reference [1]_.

Whitespace must precede the footnote reference. Leave a space between
the footnote reference and the preceding word.

When referring to another PEP, include the PEP number in the body
text, such as "PEP 1". The title may optionally appear. Add a
footnote reference following the title. For example::

Refer to PEP 1 [2]_ for more information.

Add a footnote that includes the PEP's title and author. It may
optionally include the explicit URL on a separate line, but only in
the References section. Footnotes begin with ".. " (the explicit
Footnotes begin with ".. " (the explicit
markup start), followed by the footnote marker (no underscores),
followed by the footnote body. For example::
followed by the footnote body. For example:

.. code-block:: rst

References
==========

.. [2] PEP 1, "PEP Purpose and Guidelines", Warsaw, Hylton
(http://www.python.org/dev/peps/pep-0001)
.. [1] Note that the footnote reference is a numbered one.

If you decide to provide an explicit URL for a PEP, please use this as
the URL template::

http://www.python.org/dev/peps/pep-xxxx

PEP numbers in URLs must be padded with zeros from the left, so as to
be exactly 4 characters wide; however, PEP numbers in the text are
never padded.
.. [2] Donald Knuth's *The TeXbook*, pages 195 and 196.

During the course of developing your PEP, you may have to add, remove,
and rearrange footnote references, possibly resulting in mismatched
references, obsolete footnotes, and confusion. Auto-numbered
footnotes allow more freedom. Instead of a number, use a label of the
form "#word", where "word" is a mnemonic consisting of alphanumerics
plus internal hyphens, underscores, and periods (no whitespace or
other characters are allowed). For example::
other characters are allowed). For example:

.. code-block:: rst

Refer to PEP 1 [#PEP-1]_ for more information.
Refer to The TeXbook [#TeXbook]_ for more information.

References
==========

.. [#PEP-1] PEP 1, "PEP Purpose and Guidelines", Warsaw, Hylton
.. [#TeXbook] Donald Knuth's *The TeXbook*, pages 195 and 196.

http://www.python.org/dev/peps/pep-0001

Footnotes and footnote references will be numbered automatically, and
the numbers will always match. Once a PEP is finalized, auto-numbered
labels should be replaced by numbers for simplicity.
the numbers will always match.


Images
Expand Down
2 changes: 1 addition & 1 deletion pep-0340.txt
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ accepted, these can be changed to just "yield" of course.)
Used as follows::

block auto_retry(3, IOError):
f = urllib.urlopen("http://www.python.org/dev/peps/pep-0340/")
f = urllib.urlopen("https://www.example.com/")
print f.read()

5. It is possible to nest blocks and combine templates::
Expand Down
4 changes: 2 additions & 2 deletions pep-0427.txt
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,9 @@ checker only needs to establish that RECORD matches the signature.

See

- https://datatracker.ietf.org/doc/html/rfc7515
- :rfc:`7515`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only comment here (also, no clue if it matters or not but to give background) I kept this as a full link to go with the other two in this section and below, which are internet drafts and so don't have the nice RFC role.

Equally, this is a triviality.

A

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I see. To make them more closely match, we could just tweak the other two instead, to something like

- `Internet-Draft: JSON Private Key <https://datatracker.ietf.org/doc/html/draft-jones-jose-json-private-key.html>`

To note, I-Ds are intentionally made to not be too friendly to easily reference, since you really aren't "supposed" to outside the context of an explicit citation as a work in progress (and the two mentioned are now expired).

- https://datatracker.ietf.org/doc/html/draft-jones-jose-jws-json-serialization.html
- https://datatracker.ietf.org/doc/html/rfc7517
- :rfc:`7517`
- https://datatracker.ietf.org/doc/html/draft-jones-jose-json-private-key.html


Expand Down
4 changes: 2 additions & 2 deletions pep-0491.txt
Original file line number Diff line number Diff line change
Expand Up @@ -394,9 +394,9 @@ checker only needs to establish that RECORD matches the signature.

See

- https://datatracker.ietf.org/doc/html/rfc7515
- :rfc:`7515`
- https://datatracker.ietf.org/doc/html/draft-jones-jose-jws-json-serialization.html
- https://datatracker.ietf.org/doc/html/rfc7517
- :rfc:`7517`
- https://datatracker.ietf.org/doc/html/draft-jones-jose-json-private-key.html


Expand Down