Infra: Only add Topics index to PEP 0, not topic indices (#3037)

This commit is contained in:
Hugo van Kemenade 2023-03-04 14:10:39 +02:00 committed by GitHub
parent 9fa3f36d90
commit 40f579646e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 27 additions and 12 deletions

View File

@ -35,6 +35,10 @@ ACTIVE_ALLOWED = {TYPE_PROCESS, TYPE_INFO}
# map of topic -> additional description
SUBINDICES_BY_TOPIC = {
"governance": """\
These PEPs detail Python's governance, including governance model proposals
and selection, and the results of the annual steering council elections.
""",
"packaging": """\
Packaging PEPs follow the `PyPA specification update process`_.
They are used to propose major additions or changes to the PyPA specifications.
@ -55,9 +59,5 @@ See the `developer's guide`_ for more information.
Many recent PEPs propose changes to Python's static type system
or otherwise relate to type annotations.
They are listed here for reference.
""",
"governance": """\
These PEPs detail Python's governance, including governance model proposals
and selection, and the results of the annual steering council elections.
""",
}

View File

@ -55,7 +55,7 @@ def create_pep_json(peps: list[parser.PEP]) -> str:
def create_pep_zero(app: Sphinx, env: BuildEnvironment, docnames: list[str]) -> None:
peps = _parse_peps()
pep0_text = writer.PEPZeroWriter().write_pep0(peps)
pep0_text = writer.PEPZeroWriter().write_pep0(peps, builder=env.settings["builder"])
pep0_path = subindices.update_sphinx("pep-0000", pep0_text, docnames, env)
peps.append(parser.PEP(pep0_path))

View File

@ -118,7 +118,14 @@ class PEPZeroWriter:
self.emit_text(" -")
self.emit_newline()
def write_pep0(self, peps: list[PEP], header: str = HEADER, intro: str = INTRO, is_pep0: bool = True):
def write_pep0(
self,
peps: list[PEP],
header: str = HEADER,
intro: str = INTRO,
is_pep0: bool = True,
builder: str = None,
):
if len(peps) == 0:
return ""
@ -132,11 +139,19 @@ class PEPZeroWriter:
self.emit_newline()
# PEPs by topic
if is_pep0:
self.emit_title("Topics")
self.emit_text("PEPs for specialist subjects are :doc:`indexed by topic <topic/index>`.")
self.emit_text(
"PEPs for specialist subjects are :doc:`indexed by topic <topic/index>`."
)
self.emit_newline()
for subindex in SUBINDICES_BY_TOPIC:
self.emit_text(f"* `{subindex.title()} PEPs <topic/{subindex}>`_")
target = (
f"topic/{subindex}.html"
if builder == "html"
else f"topic/{subindex}"
)
self.emit_text(f"* `{subindex.title()} PEPs <{target}>`_")
self.emit_newline()
self.emit_newline()