Skip to content

Commit

Permalink
Infra: move numerical index to own page
Browse files Browse the repository at this point in the history
  • Loading branch information
hugovk committed Sep 24, 2024
1 parent 680c8b1 commit 6fe464f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check warning on line 67 in pep_sphinx_extensions/pep_zero_generator/pep_index_generator.py

View check run for this annotation

Codecov / codecov/patch

pep_sphinx_extensions/pep_zero_generator/pep_index_generator.py#L66-L67

Added lines #L66 - L67 were not covered by tests

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))
Expand Down
27 changes: 19 additions & 8 deletions pep_sphinx_extensions/pep_zero_generator/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,25 @@ 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()

Check warning on line 137 in pep_sphinx_extensions/pep_zero_generator/writer.py

View check run for this annotation

Codecov / codecov/patch

pep_sphinx_extensions/pep_zero_generator/writer.py#L136-L137

Added lines #L136 - L137 were not covered by tests

self.emit_title("Numerical Index")
self.emit_table(peps)
self.emit_newline()

Check warning on line 141 in pep_sphinx_extensions/pep_zero_generator/writer.py

View check run for this annotation

Codecov / codecov/patch

pep_sphinx_extensions/pep_zero_generator/writer.py#L139-L141

Added lines #L139 - L141 were not covered by tests

numerical_index_string = "\n".join(self.output)
return numerical_index_string

Check warning on line 144 in pep_sphinx_extensions/pep_zero_generator/writer.py

View check run for this annotation

Codecov / codecov/patch

pep_sphinx_extensions/pep_zero_generator/writer.py#L143-L144

Added lines #L143 - L144 were not covered by tests

def write_pep0(
self,
peps: list[PEP],
header: str = HEADER,
intro: str = INTRO,
is_pep0: bool = True,
builder: str = None,
):
) -> str:
if len(peps) == 0:
return ""

Expand Down Expand Up @@ -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 <numerical-index>`.")
self.emit_newline()

Check warning on line 194 in pep_sphinx_extensions/pep_zero_generator/writer.py

View check run for this annotation

Codecov / codecov/patch

pep_sphinx_extensions/pep_zero_generator/writer.py#L191-L194

Added lines #L191 - L194 were not covered by tests

# PEPs by category
self.emit_title("Index by Category")
meta, info, provisional, accepted, open_, finished, historical, deferred, dead = _classify_peps(peps)
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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)

Check warning on line 278 in pep_sphinx_extensions/pep_zero_generator/writer.py

View check run for this annotation

Codecov / codecov/patch

pep_sphinx_extensions/pep_zero_generator/writer.py#L278

Added line #L278 was not covered by tests
return pep0_string


Expand Down
3 changes: 2 additions & 1 deletion peps/contents.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This is an internal Sphinx page; please go to the :doc:`PEP Index <pep-0000>`.
:glob:
:caption: PEP Table of Contents (needed for Sphinx):

pep-*
api/*
numerical
pep-*
topic/*

0 comments on commit 6fe464f

Please sign in to comment.