Skip to content

Commit 24552ca

Browse files
hugovkAA-Turner
andauthored
Infra: Move numerical index to own page (#3992)
Co-authored-by: Adam Turner <[email protected]>
1 parent 55cf374 commit 24552ca

File tree

5 files changed

+38
-10
lines changed

5 files changed

+38
-10
lines changed

pep_sphinx_extensions/pep_theme/static/style.css

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,13 @@ table.pep-zero-table tr td:nth-child(5) {
281281
width: 50%;
282282
}
283283

284+
/* Numerical index */
285+
article:has(> section#numerical-index) {
286+
float: unset !important;
287+
width: 90% !important;
288+
max-width: 90% !important;
289+
}
290+
284291
/* Breadcrumbs rules */
285292
section#pep-page-section > header {
286293
border-bottom: 1px solid var(--colour-rule-light);

pep_sphinx_extensions/pep_theme/templates/page.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,16 @@ <h1>Python Enhancement Proposals</h1>
4949
<article>
5050
{{ body }}
5151
</article>
52+
{%- if not pagename == "numerical" %}
5253
<nav id="pep-sidebar">
5354
<h2>Contents</h2>
5455
{{ toc }}
5556
<br>
56-
{%- if not pagename.startswith(("pep-0000", "topic")) %}
57+
{%- if not pagename.startswith(("numerical", "pep-0000", "topic")) %}
5758
<a id="source" href="https://github.com/python/peps/blob/main/peps/{{pagename}}.rst">Page Source (GitHub)</a>
5859
{%- endif %}
5960
</nav>
61+
{%- endif %}
6062
</section>
6163
<script src="{{ pathto('_static/colour_scheme.js', resource=True) }}"></script>
6264
<script src="{{ pathto('_static/wrap_tables.js', resource=True) }}"></script>

pep_sphinx_extensions/pep_zero_generator/pep_index_generator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ def write_peps_json(peps: list[parser.PEP], path: Path) -> None:
6363
def create_pep_zero(app: Sphinx, env: BuildEnvironment, docnames: list[str]) -> None:
6464
peps = _parse_peps(Path(app.srcdir))
6565

66+
numerical_index_text = writer.PEPZeroWriter().write_numerical_index(peps)
67+
subindices.update_sphinx("numerical", numerical_index_text, docnames, env)
68+
6669
pep0_text = writer.PEPZeroWriter().write_pep0(peps, builder=env.settings["builder"])
6770
pep0_path = subindices.update_sphinx("pep-0000", pep0_text, docnames, env)
6871
peps.append(parser.PEP(pep0_path))

pep_sphinx_extensions/pep_zero_generator/writer.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,26 @@ def emit_pep_category(self, category: str, peps: list[PEP]) -> None:
132132
self.emit_text(" -")
133133
self.emit_newline()
134134

135+
def write_numerical_index(self, peps: list[PEP]) -> str:
136+
"""Write PEPs by number."""
137+
self.emit_text(".. _numerical-index:")
138+
self.emit_newline()
139+
140+
self.emit_title("Numerical Index")
141+
self.emit_table(peps)
142+
self.emit_newline()
143+
144+
numerical_index_string = "\n".join(self.output)
145+
return numerical_index_string
146+
135147
def write_pep0(
136148
self,
137149
peps: list[PEP],
138150
header: str = HEADER,
139151
intro: str = INTRO,
140152
is_pep0: bool = True,
141153
builder: str = None,
142-
):
154+
) -> str:
143155
if len(peps) == 0:
144156
return ""
145157

@@ -176,6 +188,15 @@ def write_pep0(
176188
)
177189
self.emit_newline()
178190

191+
# PEPs by number
192+
if is_pep0:
193+
self.emit_title("Numerical Index")
194+
self.emit_text(
195+
"The :doc:`numerical index </numerical>` contains "
196+
"a table of all PEPs, ordered by number."
197+
)
198+
self.emit_newline()
199+
179200
# PEPs by category
180201
self.emit_title("Index by Category")
181202
meta, info, provisional, accepted, open_, finished, historical, deferred, dead = _classify_peps(peps)
@@ -203,12 +224,6 @@ def write_pep0(
203224

204225
self.emit_newline()
205226

206-
# PEPs by number
207-
self.emit_title("Numerical Index")
208-
self.emit_table(peps)
209-
210-
self.emit_newline()
211-
212227
# Reserved PEP numbers
213228
if is_pep0:
214229
self.emit_title("Reserved PEP Numbers")
@@ -264,7 +279,7 @@ def write_pep0(
264279
self.emit_newline()
265280
self.emit_newline()
266281

267-
pep0_string = "\n".join(map(str, self.output))
282+
pep0_string = "\n".join(self.output)
268283
return pep0_string
269284

270285

peps/contents.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This is an internal Sphinx page; please go to the :doc:`PEP Index <pep-0000>`.
1414
:glob:
1515
:caption: PEP Table of Contents (needed for Sphinx):
1616

17-
pep-*
1817
api/*
1918
topic/*
19+
numerical
20+
pep-*

0 commit comments

Comments
 (0)