Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Infra: Move numerical index to own page #3992

Merged
merged 6 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pep_sphinx_extensions/pep_theme/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h1>Python Enhancement Proposals</h1>
<h2>Contents</h2>
{{ toc }}
<br>
{%- if not pagename.startswith(("pep-0000", "topic")) %}
{%- if not pagename.startswith(("numerical", "pep-0000", "topic")) %}
<a id="source" href="https://github.com/python/peps/blob/main/peps/{{pagename}}.rst">Page Source (GitHub)</a>
{%- endif %}
</nav>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
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
31 changes: 23 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,26 @@
self.emit_text(" -")
self.emit_newline()

def write_numerical_index(self, peps: list[PEP]) -> str:
hugovk marked this conversation as resolved.
Show resolved Hide resolved
"""Write PEPs by number."""
self.emit_text(".. _numerical-index:")
self.emit_newline()

Check warning on line 138 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#L137-L138

Added lines #L137 - L138 were not covered by tests

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

Check warning on line 142 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#L140-L142

Added lines #L140 - L142 were not covered by tests

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

Check warning on line 145 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#L144-L145

Added lines #L144 - L145 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 +188,15 @@
)
self.emit_newline()

# PEPs by number
if is_pep0:
self.emit_title("Numerical Index")
self.emit_text(

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#L192-L194

Added lines #L192 - L194 were not covered by tests
"The :doc:`numerical index </numerical>` contains "
"a table of all PEPs, ordered by number."
)
self.emit_newline()

Check warning on line 198 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#L198

Added line #L198 was 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 +224,6 @@

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 +279,7 @@
self.emit_newline()
self.emit_newline()

pep0_string = "\n".join(map(str, self.output))
pep0_string = "\n".join(self.output)

Check warning on line 282 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#L282

Added line #L282 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/*
topic/*
numerical
pep-*