Infra: Add Python version to PEP 0 tables (#3434)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
This commit is contained in:
parent
a159a9ac58
commit
b794468df6
|
@ -232,14 +232,17 @@ table td + td {
|
||||||
}
|
}
|
||||||
/* Common column widths for PEP status tables */
|
/* Common column widths for PEP status tables */
|
||||||
table.pep-zero-table tr td:nth-child(1) {
|
table.pep-zero-table tr td:nth-child(1) {
|
||||||
width: 5.5%;
|
width: 5%;
|
||||||
}
|
}
|
||||||
table.pep-zero-table tr td:nth-child(2) {
|
table.pep-zero-table tr td:nth-child(2) {
|
||||||
width: 6.5%;
|
width: 7%;
|
||||||
}
|
}
|
||||||
table.pep-zero-table tr td:nth-child(3),
|
table.pep-zero-table tr td:nth-child(3),
|
||||||
table.pep-zero-table tr td:nth-child(4){
|
table.pep-zero-table tr td:nth-child(4){
|
||||||
width: 44%;
|
width: 41%;
|
||||||
|
}
|
||||||
|
table.pep-zero-table tr td:nth-child(5) {
|
||||||
|
width: 6%;
|
||||||
}
|
}
|
||||||
/* Authors & Sponsors table */
|
/* Authors & Sponsors table */
|
||||||
#authors-owners table td,
|
#authors-owners table td,
|
||||||
|
|
|
@ -140,6 +140,8 @@ class PEP:
|
||||||
"shorthand": self.shorthand,
|
"shorthand": self.shorthand,
|
||||||
# the author list as a comma-separated with only last names
|
# the author list as a comma-separated with only last names
|
||||||
"authors": ", ".join(author.full_name for author in self.authors),
|
"authors": ", ".join(author.full_name for author in self.authors),
|
||||||
|
# The targeted Python-Version (if present) or the empty string
|
||||||
|
"python_version": self.python_version or "",
|
||||||
}
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|
|
@ -74,14 +74,22 @@ class PEPZeroWriter:
|
||||||
self.output.append(author_table_separator)
|
self.output.append(author_table_separator)
|
||||||
|
|
||||||
def emit_pep_row(
|
def emit_pep_row(
|
||||||
self, *, shorthand: str, number: int, title: str, authors: str
|
self,
|
||||||
|
*,
|
||||||
|
shorthand: str,
|
||||||
|
number: int,
|
||||||
|
title: str,
|
||||||
|
authors: str,
|
||||||
|
python_version: str | None = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
self.emit_text(f" * - {shorthand}")
|
self.emit_text(f" * - {shorthand}")
|
||||||
self.emit_text(f" - :pep:`{number} <{number}>`")
|
self.emit_text(f" - :pep:`{number} <{number}>`")
|
||||||
self.emit_text(f" - :pep:`{title.replace('`', '')} <{number}>`")
|
self.emit_text(f" - :pep:`{title.replace('`', '')} <{number}>`")
|
||||||
self.emit_text(f" - {authors}")
|
self.emit_text(f" - {authors}")
|
||||||
|
if python_version is not None:
|
||||||
|
self.emit_text(f" - {python_version}")
|
||||||
|
|
||||||
def emit_column_headers(self) -> None:
|
def emit_column_headers(self, *, include_version=True) -> None:
|
||||||
"""Output the column headers for the PEP indices."""
|
"""Output the column headers for the PEP indices."""
|
||||||
self.emit_text(".. list-table::")
|
self.emit_text(".. list-table::")
|
||||||
self.emit_text(" :header-rows: 1")
|
self.emit_text(" :header-rows: 1")
|
||||||
|
@ -92,6 +100,8 @@ class PEPZeroWriter:
|
||||||
self.emit_text(" - PEP")
|
self.emit_text(" - PEP")
|
||||||
self.emit_text(" - Title")
|
self.emit_text(" - Title")
|
||||||
self.emit_text(" - Authors")
|
self.emit_text(" - Authors")
|
||||||
|
if include_version:
|
||||||
|
self.emit_text(" - ") # for Python-Version
|
||||||
|
|
||||||
def emit_title(self, text: str, *, symbol: str = "=") -> None:
|
def emit_title(self, text: str, *, symbol: str = "=") -> None:
|
||||||
self.output.append(text)
|
self.output.append(text)
|
||||||
|
@ -101,17 +111,25 @@ class PEPZeroWriter:
|
||||||
def emit_subtitle(self, text: str) -> None:
|
def emit_subtitle(self, text: str) -> None:
|
||||||
self.emit_title(text, symbol="-")
|
self.emit_title(text, symbol="-")
|
||||||
|
|
||||||
|
def emit_table(self, peps: list[PEP]) -> None:
|
||||||
|
include_version = any(pep.details["python_version"] for pep in peps)
|
||||||
|
self.emit_column_headers(include_version=include_version)
|
||||||
|
for pep in peps:
|
||||||
|
details = pep.details
|
||||||
|
if not include_version:
|
||||||
|
details.pop("python_version")
|
||||||
|
self.emit_pep_row(**details)
|
||||||
|
|
||||||
def emit_pep_category(self, category: str, peps: list[PEP]) -> None:
|
def emit_pep_category(self, category: str, peps: list[PEP]) -> None:
|
||||||
self.emit_subtitle(category)
|
self.emit_subtitle(category)
|
||||||
self.emit_column_headers()
|
self.emit_table(peps)
|
||||||
for pep in peps:
|
|
||||||
self.emit_pep_row(**pep.details)
|
|
||||||
# list-table must have at least one body row
|
# list-table must have at least one body row
|
||||||
if len(peps) == 0:
|
if len(peps) == 0:
|
||||||
self.emit_text(" * -")
|
self.emit_text(" * -")
|
||||||
self.emit_text(" -")
|
self.emit_text(" -")
|
||||||
self.emit_text(" -")
|
self.emit_text(" -")
|
||||||
self.emit_text(" -")
|
self.emit_text(" -")
|
||||||
|
self.emit_text(" -")
|
||||||
self.emit_newline()
|
self.emit_newline()
|
||||||
|
|
||||||
def write_pep0(
|
def write_pep0(
|
||||||
|
@ -180,19 +198,21 @@ class PEPZeroWriter:
|
||||||
|
|
||||||
# PEPs by number
|
# PEPs by number
|
||||||
self.emit_title("Numerical Index")
|
self.emit_title("Numerical Index")
|
||||||
self.emit_column_headers()
|
self.emit_table(peps)
|
||||||
for pep in peps:
|
|
||||||
self.emit_pep_row(**pep.details)
|
|
||||||
|
|
||||||
self.emit_newline()
|
self.emit_newline()
|
||||||
|
|
||||||
# Reserved PEP numbers
|
# Reserved PEP numbers
|
||||||
if is_pep0:
|
if is_pep0:
|
||||||
self.emit_title("Reserved PEP Numbers")
|
self.emit_title("Reserved PEP Numbers")
|
||||||
self.emit_column_headers()
|
self.emit_column_headers(include_version=False)
|
||||||
for number, claimants in sorted(self.RESERVED.items()):
|
for number, claimants in sorted(self.RESERVED.items()):
|
||||||
self.emit_pep_row(
|
self.emit_pep_row(
|
||||||
shorthand="", number=number, title="RESERVED", authors=claimants
|
shorthand="",
|
||||||
|
number=number,
|
||||||
|
title="RESERVED",
|
||||||
|
authors=claimants,
|
||||||
|
python_version=None,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.emit_newline()
|
self.emit_newline()
|
||||||
|
|
|
@ -40,15 +40,35 @@ def test_pep_equal():
|
||||||
assert pep_a == pep_b
|
assert pep_a == pep_b
|
||||||
|
|
||||||
|
|
||||||
def test_pep_details(monkeypatch):
|
@pytest.mark.parametrize(
|
||||||
pep8 = parser.PEP(PEP_ROOT / "pep-0008.rst")
|
("test_input", "expected"),
|
||||||
|
[
|
||||||
assert pep8.details == {
|
(
|
||||||
|
"pep-0008.rst",
|
||||||
|
{
|
||||||
"authors": "Guido van Rossum, Barry Warsaw, Nick Coghlan",
|
"authors": "Guido van Rossum, Barry Warsaw, Nick Coghlan",
|
||||||
"number": 8,
|
"number": 8,
|
||||||
"shorthand": ":abbr:`PA (Process, Active)`",
|
"shorthand": ":abbr:`PA (Process, Active)`",
|
||||||
"title": "Style Guide for Python Code",
|
"title": "Style Guide for Python Code",
|
||||||
}
|
"python_version": "",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
(
|
||||||
|
"pep-0719.rst",
|
||||||
|
{
|
||||||
|
"authors": "Thomas Wouters",
|
||||||
|
"number": 719,
|
||||||
|
"shorthand": ":abbr:`IA (Informational, Active)`",
|
||||||
|
"title": "Python 3.13 Release Schedule",
|
||||||
|
"python_version": "3.13",
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
def test_pep_details(test_input, expected):
|
||||||
|
pep = parser.PEP(PEP_ROOT / test_input)
|
||||||
|
|
||||||
|
assert pep.details == expected
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
|
|
Loading…
Reference in New Issue