Skip to content

Commit 686562b

Browse files
authored
Infra: Use a list of authors in peps.json (#4226)
1 parent 2ee1c5e commit 686562b

File tree

2 files changed

+64
-43
lines changed

2 files changed

+64
-43
lines changed

pep_sphinx_extensions/pep_zero_generator/parser.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from __future__ import annotations
44

55
import dataclasses
6+
from collections.abc import Iterable, Sequence
67
from email.parser import HeaderParser
78
from pathlib import Path
89

@@ -121,6 +122,11 @@ def __lt__(self, other: PEP) -> bool:
121122
def __eq__(self, other):
122123
return self.number == other.number
123124

125+
@property
126+
def _author_names(self) -> Iterable[str]:
127+
"""An iterator of the authors' full names."""
128+
return (author.full_name for author in self.authors)
129+
124130
@property
125131
def shorthand(self) -> str:
126132
"""Return reStructuredText tooltip for the PEP type and status."""
@@ -138,19 +144,19 @@ def details(self) -> dict[str, str | int]:
138144
"title": self.title,
139145
# a tooltip representing the type and status
140146
"shorthand": self.shorthand,
141-
# the author list as a comma-separated with only last names
142-
"authors": ", ".join(author.full_name for author in self.authors),
147+
# the comma-separated list of authors
148+
"authors": ", ".join(self._author_names),
143149
# The targeted Python-Version (if present) or the empty string
144150
"python_version": self.python_version or "",
145151
}
146152

147153
@property
148-
def full_details(self) -> dict[str, str | int]:
154+
def full_details(self) -> dict[str, str | int | Sequence[str]]:
149155
"""Returns all headers of the PEP as a dict."""
150156
return {
151157
"number": self.number,
152158
"title": self.title,
153-
"authors": ", ".join(author.full_name for author in self.authors),
159+
"authors": ", ".join(self._author_names),
154160
"discussions_to": self.discussions_to,
155161
"status": self.status,
156162
"type": self.pep_type,
@@ -162,6 +168,8 @@ def full_details(self) -> dict[str, str | int]:
162168
"requires": self.requires,
163169
"replaces": self.replaces,
164170
"superseded_by": self.superseded_by,
171+
# extra non-header keys for use in ``peps.json``
172+
"author_names": tuple(self._author_names),
165173
"url": f"https://peps.python.org/pep-{self.number:0>4}/",
166174
}
167175

peps/api/index.rst

+52-39
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
PEPs API
22
========
33

4-
There is a read-only API of published PEPs available at:
4+
There is a read-only JSON document of every published PEP available at
5+
https://peps.python.org/api/peps.json.
56

6-
* https://peps.python.org/api/peps.json
7+
Each PEP is represented as a JSON object, keyed by the PEP number.
8+
The structure of each JSON object is as follows:
79

8-
The structure is like:
9-
10-
.. code-block:: javascript
10+
.. code-block:: typescript
1111
1212
{
1313
"<PEP number>": {
14-
"number": integer,
14+
"number": integer, // always identical to <PEP number>
1515
"title": string,
1616
"authors": string,
1717
"discussions_to": string | null,
@@ -25,67 +25,80 @@ The structure is like:
2525
"requires": string | null,
2626
"replaces": string | null,
2727
"superseded_by": string | null,
28+
"author_names": Array<string>,
2829
"url": string
2930
},
3031
}
3132
3233
Date values are formatted as DD-MMM-YYYY,
3334
and multiple dates are combined in a comma-separated list.
3435

35-
For example:
36+
A selection of example PEPs are shown here,
37+
illustrating some of the possible values for each field:
3638

3739
.. code-block:: json
3840
3941
{
40-
"8": {
41-
"number": 8,
42-
"title": "Style Guide for Python Code",
43-
"authors": "Guido van Rossum, Barry Warsaw, Alyssa Coghlan",
42+
"12": {
43+
"number": 12,
44+
"title": "Sample reStructuredText PEP Template",
45+
"authors": "David Goodger, Barry Warsaw, Brett Cannon",
4446
"discussions_to": null,
4547
"status": "Active",
4648
"type": "Process",
4749
"topic": "",
48-
"created": "05-Jul-2001",
50+
"created": "05-Aug-2002",
4951
"python_version": null,
50-
"post_history": "05-Jul-2001, 01-Aug-2013",
52+
"post_history": "`30-Aug-2002 <https://mail.python.org/archives/list/python-dev@python.org/thread/KX3AS7QAY26QH3WIUAEOCCNXQ4V2TGGV/>`__",
5153
"resolution": null,
5254
"requires": null,
5355
"replaces": null,
5456
"superseded_by": null,
55-
"url": "https://peps.python.org/pep-0008/"
57+
"author_names": [
58+
"David Goodger",
59+
"Barry Warsaw",
60+
"Brett Cannon"
61+
],
62+
"url": "https://peps.python.org/pep-0012/"
5663
},
57-
"484": {
58-
"number": 484,
59-
"title": "Type Hints",
60-
"authors": "Guido van Rossum, Jukka Lehtosalo, Łukasz Langa",
61-
"discussions_to": "python-dev@python.org",
64+
"160": {
65+
"number": 160,
66+
"title": "Python 1.6 Release Schedule",
67+
"authors": "Fred L. Drake, Jr.",
68+
"discussions_to": null,
6269
"status": "Final",
63-
"type": "Standards Track",
64-
"topic": "typing",
65-
"created": "29-Sep-2014",
66-
"python_version": "3.5",
67-
"post_history": "16-Jan-2015, 20-Mar-2015, 17-Apr-2015, 20-May-2015, 22-May-2015",
68-
"resolution": "https://mail.python.org/pipermail/python-dev/2015-May/140104.html",
70+
"type": "Informational",
71+
"topic": "release",
72+
"created": "25-Jul-2000",
73+
"python_version": "1.6",
74+
"post_history": null,
75+
"resolution": null,
6976
"requires": null,
7077
"replaces": null,
7178
"superseded_by": null,
72-
"url": "https://peps.python.org/pep-0484/"
79+
"author_names": [
80+
"Fred L. Drake, Jr."
81+
],
82+
"url": "https://peps.python.org/pep-0160/"
7383
},
74-
"622": {
75-
"number": 622,
76-
"title": "Structural Pattern Matching",
77-
"authors": "Brandt Bucher, Daniel F Moisset, Tobias Kohn, Ivan Levkivskyi, Guido van Rossum, Talin",
78-
"discussions_to": "python-dev@python.org",
79-
"status": "Superseded",
84+
"3124": {
85+
"number": 3124,
86+
"title": "Overloading, Generic Functions, Interfaces, and Adaptation",
87+
"authors": "Phillip J. Eby",
88+
"discussions_to": "python-3000@python.org",
89+
"status": "Deferred",
8090
"type": "Standards Track",
8191
"topic": "",
82-
"created": "23-Jun-2020",
83-
"python_version": "3.10",
84-
"post_history": "23-Jun-2020, 08-Jul-2020",
92+
"created": "28-Apr-2007",
93+
"python_version": null,
94+
"post_history": "30-Apr-2007",
8595
"resolution": null,
86-
"requires": null,
87-
"replaces": null,
88-
"superseded_by": "634",
89-
"url": "https://peps.python.org/pep-0622/"
96+
"requires": "3107, 3115, 3119",
97+
"replaces": "245, 246",
98+
"superseded_by": null,
99+
"author_names": [
100+
"Phillip J. Eby"
101+
],
102+
"url": "https://peps.python.org/pep-3124/"
90103
}
91104
}

0 commit comments

Comments
 (0)