Skip to content

Commit

Permalink
Infra: Move numerical index to own page (#3992)
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Turner <[email protected]>
  • Loading branch information
hugovk and AA-Turner authored Sep 26, 2024
1 parent 55cf374 commit 24552ca
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
7 changes: 7 additions & 0 deletions pep_sphinx_extensions/pep_theme/static/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,13 @@ table.pep-zero-table tr td:nth-child(5) {
width: 50%;
}

/* Numerical index */
article:has(> section#numerical-index) {
float: unset !important;
width: 90% !important;
max-width: 90% !important;
}

/* Breadcrumbs rules */
section#pep-page-section > header {
border-bottom: 1px solid var(--colour-rule-light);
Expand Down
4 changes: 3 additions & 1 deletion pep_sphinx_extensions/pep_theme/templates/page.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ <h1>Python Enhancement Proposals</h1>
<article>
{{ body }}
</article>
{%- if not pagename == "numerical" %}
<nav id="pep-sidebar">
<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>
{%- endif %}
</section>
<script src="{{ pathto('_static/colour_scheme.js', resource=True) }}"></script>
<script src="{{ pathto('_static/wrap_tables.js', resource=True) }}"></script>
Expand Down
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)

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 @@ 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:
"""Write PEPs by number."""
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],
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 @@ def write_pep0(
)
self.emit_newline()

# PEPs by number
if is_pep0:
self.emit_title("Numerical Index")
self.emit_text(
"The :doc:`numerical index </numerical>` contains "
"a table of all PEPs, ordered 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)
Expand Down Expand Up @@ -203,12 +224,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 +279,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


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-*

0 comments on commit 24552ca

Please sign in to comment.