From 6fe464f24ab9639167569bebefbb31cc6675531e Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com> Date: Tue, 24 Sep 2024 08:07:18 -0700 Subject: [PATCH] Infra: move numerical index to own page --- .../pep_zero_generator/pep_index_generator.py | 3 +++ .../pep_zero_generator/writer.py | 27 +++++++++++++------ peps/contents.rst | 3 ++- 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/pep_sphinx_extensions/pep_zero_generator/pep_index_generator.py b/pep_sphinx_extensions/pep_zero_generator/pep_index_generator.py index 8fbf5cc7e65..2dc3e7ff52d 100644 --- a/pep_sphinx_extensions/pep_zero_generator/pep_index_generator.py +++ b/pep_sphinx_extensions/pep_zero_generator/pep_index_generator.py @@ -63,6 +63,9 @@ def write_peps_json(peps: list[parser.PEP], path: Path) -> None: def create_pep_zero(app: Sphinx, env: BuildEnvironment, docnames: list[str]) -> None: peps = _parse_peps(Path(app.srcdir)) + numerical_index_text = writer.PEPZeroWriter().write_numerical_index(peps) + subindices.update_sphinx("numerical", numerical_index_text, docnames, env) + 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)) diff --git a/pep_sphinx_extensions/pep_zero_generator/writer.py b/pep_sphinx_extensions/pep_zero_generator/writer.py index e0507cc7f29..123d42a243d 100644 --- a/pep_sphinx_extensions/pep_zero_generator/writer.py +++ b/pep_sphinx_extensions/pep_zero_generator/writer.py @@ -132,6 +132,17 @@ def emit_pep_category(self, category: str, peps: list[PEP]) -> None: self.emit_text(" -") self.emit_newline() + def write_numerical_index(self, peps: list[PEP]) -> str: + self.emit_text(".. _numerical-index:") + self.emit_newline() + + self.emit_title("Numerical Index") + self.emit_table(peps) + self.emit_newline() + + numerical_index_string = "\n".join(self.output) + return numerical_index_string + def write_pep0( self, peps: list[PEP], @@ -139,7 +150,7 @@ def write_pep0( intro: str = INTRO, is_pep0: bool = True, builder: str = None, - ): + ) -> str: if len(peps) == 0: return "" @@ -176,6 +187,12 @@ def write_pep0( ) self.emit_newline() + # PEPs by number + if is_pep0: + self.emit_title("Numerical Index") + self.emit_text("All PEPs :ref:`sorted by number `.") + self.emit_newline() + # PEPs by category self.emit_title("Index by Category") meta, info, provisional, accepted, open_, finished, historical, deferred, dead = _classify_peps(peps) @@ -203,12 +220,6 @@ def write_pep0( self.emit_newline() - # PEPs by number - self.emit_title("Numerical Index") - self.emit_table(peps) - - self.emit_newline() - # Reserved PEP numbers if is_pep0: self.emit_title("Reserved PEP Numbers") @@ -264,7 +275,7 @@ def write_pep0( self.emit_newline() self.emit_newline() - pep0_string = "\n".join(map(str, self.output)) + pep0_string = "\n".join(self.output) return pep0_string diff --git a/peps/contents.rst b/peps/contents.rst index 5d5c23ee3a6..1878d5db990 100644 --- a/peps/contents.rst +++ b/peps/contents.rst @@ -14,6 +14,7 @@ This is an internal Sphinx page; please go to the :doc:`PEP Index `. :glob: :caption: PEP Table of Contents (needed for Sphinx): - pep-* api/* + numerical + pep-* topic/*