Skip to content

Commit ee88679

Browse files
authored
Merge branch 'main' into sphinx-9
2 parents cef97cb + f101f94 commit ee88679

53 files changed

Lines changed: 1987 additions & 1237 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,7 @@ peps/pep-0830.rst @gpshead
709709
peps/pep-0831.rst @pablogsal @Fidget-Spinner @savannahostrowski
710710
peps/pep-0832.rst @brettcannon
711711
peps/pep-0833.rst @dstufft
712+
peps/pep-0835.rst @ilevkivskyi
712713
# ...
713714
peps/pep-2026.rst @hugovk
714715
# ...

.github/workflows/documentation-links.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/lint.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ jobs:
2323
persist-credentials: false
2424

2525
- name: Run pre-commit hooks
26-
uses: j178/prek-action@v2
26+
uses: j178/prek-action@v2.0.4
2727

2828
- name: Check spelling
29-
uses: j178/prek-action@v2
29+
uses: j178/prek-action@v2.0.4
3030
continue-on-error: true
3131
with:
3232
extra_args: --all-files --hook-stage manual codespell

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
uvx --with tox-uv tox -e py -- -v --cov-report term
6464
6565
- name: Upload coverage
66-
uses: codecov/codecov-action@v5
66+
uses: codecov/codecov-action@v6
6767
with:
6868
flags: ${{ matrix.os }}
6969
name: ${{ matrix.os }} Python ${{ matrix.python-version }}

pep_sphinx_extensions/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
pep_parser,
2424
pep_role,
2525
)
26+
from pep_sphinx_extensions.pep_processor.transforms import pep_footer
2627
from pep_sphinx_extensions.pep_processor.transforms import pep_references
2728
from pep_sphinx_extensions.pep_zero_generator.pep_index_generator import create_pep_zero
2829

@@ -68,6 +69,9 @@ def set_description(
6869
else:
6970
context["description"] = "Python Enhancement Proposals (PEPs)"
7071

72+
if pagename != "pep-0000":
73+
context.update(pep_footer.get_page_footer_context(pagename))
74+
7175

7276
def setup(app: Sphinx) -> dict[str, bool]:
7377
"""Initialize Sphinx extension."""

pep_sphinx_extensions/pep_processor/transforms/pep_footer.py

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,6 @@ class PEPFooter(transforms.Transform):
1010
"""Footer transforms for PEPs.
1111
1212
- Remove the References/Footnotes section if it is empty when rendered.
13-
- Create a link to the (GitHub) source text.
14-
15-
Source Link:
16-
Create the link to the source file from the document source path,
17-
and append the text to the end of the document.
18-
1913
"""
2014

2115
# Uses same priority as docutils.transforms.TargetNotes
@@ -44,31 +38,21 @@ def apply(self) -> None:
4438
section.parent.extend(to_hoist)
4539
section.parent.remove(section)
4640

47-
# Add link to source text and last modified date
48-
if pep_source_path.stem != "pep-0000":
49-
if pep_source_path.stem != "pep-0210": # 210 is entirely empty, skip
50-
self.document += nodes.transition()
51-
self.document += _add_source_link(pep_source_path)
52-
self.document += _add_commit_history_info(pep_source_path)
53-
54-
55-
def _add_source_link(pep_source_path: Path) -> nodes.paragraph:
56-
"""Add link to source text on VCS (GitHub)"""
57-
source_link = f"https://github.com/python/peps/blob/main/peps/{pep_source_path.name}"
58-
link_node = nodes.reference("", source_link, refuri=source_link)
59-
return nodes.paragraph("", "Source: ", link_node)
60-
61-
62-
def _add_commit_history_info(pep_source_path: Path) -> nodes.paragraph:
63-
"""Use local git history to find last modified date."""
64-
try:
65-
iso_time = _LAST_MODIFIED_TIMES[pep_source_path.stem]
66-
except KeyError:
67-
return nodes.paragraph()
6841

69-
commit_link = f"https://github.com/python/peps/commits/main/peps/{pep_source_path.name}"
70-
link_node = nodes.reference("", f"{iso_time} GMT", refuri=commit_link)
71-
return nodes.paragraph("", "Last modified: ", link_node)
42+
def get_page_footer_context(pep_stem: str) -> dict[str, str]:
43+
"""Template context for the page footer, rendered by ``page.html``."""
44+
context = {
45+
"source_link": (
46+
f"https://github.com/python/peps/blob/main/peps/{pep_stem}.rst"
47+
),
48+
}
49+
iso_time = _LAST_MODIFIED_TIMES.get(pep_stem, "")
50+
if iso_time:
51+
context["last_modified"] = iso_time
52+
context["commit_link"] = (
53+
f"https://github.com/python/peps/commits/main/peps/{pep_stem}.rst"
54+
)
55+
return context
7256

7357

7458
def _get_last_modified_timestamps():

pep_sphinx_extensions/pep_theme/static/mq.css

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,17 @@
3838
padding: 0.5rem 1rem 0;
3939
width: 100%;
4040
}
41-
section#pep-page-section > article {
41+
section#pep-page-section > main,
42+
section#pep-page-section > footer#pep-page-footer {
4243
max-width: 37em;
4344
width: 74%;
4445
float: right;
4546
margin-right: 0;
4647
font-size: 1rem;
4748
}
49+
section#pep-page-section > footer#pep-page-footer {
50+
clear: right;
51+
}
4852
nav#pep-sidebar {
4953
width: 24%;
5054
float: left;
@@ -61,7 +65,8 @@
6165
}
6266
}
6367
@media (min-width: 60em) {
64-
section#pep-page-section > article {
68+
section#pep-page-section > main,
69+
section#pep-page-section > footer#pep-page-footer {
6570
max-width: 56em;
6671
padding-left: 3.2%;
6772
padding-right: 3.2%;
@@ -78,7 +83,7 @@
7883
font-size: 10pt;
7984
line-height: 1.67;
8085
}
81-
*[role="main"] a[href]:after {
86+
main a[href]:after {
8287
content: " (" attr(href) ")";
8388
font-size: .75rem;
8489
}
@@ -158,7 +163,8 @@
158163
display: none;
159164
}
160165

161-
section#pep-page-section > article {
166+
section#pep-page-section > main,
167+
section#pep-page-section > footer#pep-page-footer {
162168
float: none;
163169
max-width: 100%;
164170
width: auto;

pep_sphinx_extensions/pep_theme/static/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ table.pep-zero-table tr td:nth-child(5) {
288288
}
289289

290290
/* Numerical index */
291-
article:has(> section#numerical-index) {
291+
main:has(> section#numerical-index) {
292292
float: unset !important;
293293
width: 90% !important;
294294
max-width: 90% !important;

pep_sphinx_extensions/pep_theme/templates/page.html

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,14 @@ <h1 data-pagefind-ignore>Python Enhancement Proposals</h1>
5353
</div>
5454
{# Exclude noisy non-PEP pages from Pagefind indexing #}
5555
{%- if pagename.startswith(("404", "numerical", "pep-0000", "topic")) %}
56-
<article>
56+
<main>
5757
{%- else %}
58-
<article data-pagefind-body>
58+
<main data-pagefind-body>
5959
{%- endif %}
6060
{# Add pagefind meta for the title to improve search result display #}
6161
<span data-pagefind-meta="title:{{ title }}" data-pagefind-weight="10" class="visually-hidden">{{ title }}</span>
6262
{{ body }}
63-
</article>
63+
</main>
6464
{%- if not pagename.startswith(("404", "numerical")) %}
6565
<nav id="pep-sidebar">
6666
<pagefind-searchbox shortcut="/" style="font-family: inherit"></pagefind-searchbox>
@@ -72,6 +72,14 @@ <h2>Contents</h2>
7272
{%- endif %}
7373
</nav>
7474
{%- endif %}
75+
{%- if source_link %}
76+
<footer id="pep-page-footer">
77+
<p>Source: <a href="{{ source_link }}">{{ source_link }}</a></p>
78+
{%- if last_modified %}
79+
<p>Last modified: <a href="{{ commit_link }}">{{ last_modified }} UTC</a></p>
80+
{%- endif %}
81+
</footer>
82+
{%- endif %}
7583
</section>
7684
<script src="{{ pathto('_static/colour_scheme.js', resource=True) }}"></script>
7785
<script src="{{ pathto('_static/wrap_tables.js', resource=True) }}"></script>

pep_sphinx_extensions/tests/pep_processor/transform/test_pep_footer.py

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,27 @@
22

33
from pep_sphinx_extensions.pep_processor.transforms import pep_footer
44

5-
from ...conftest import PEP_ROOT
65

6+
def test_get_page_footer_context():
7+
out = pep_footer.get_page_footer_context("pep-0008")
78

8-
def test_add_source_link():
9-
out = pep_footer._add_source_link(PEP_ROOT / "pep-0008.rst")
10-
11-
assert "https://github.com/python/peps/blob/main/peps/pep-0008.rst" in str(out)
12-
13-
14-
def test_add_commit_history_info():
15-
out = pep_footer._add_commit_history_info(PEP_ROOT / "pep-0008.rst")
16-
17-
assert str(out).startswith(
18-
"<paragraph>Last modified: "
19-
'<reference refuri="https://github.com/python/peps/commits/main/peps/pep-0008.rst">'
9+
assert out["source_link"] == (
10+
"https://github.com/python/peps/blob/main/peps/pep-0008.rst"
11+
)
12+
assert out["commit_link"] == (
13+
"https://github.com/python/peps/commits/main/peps/pep-0008.rst"
2014
)
21-
# A variable timestamp comes next, don't test that
22-
assert str(out).endswith("</reference></paragraph>")
15+
# A variable timestamp, don't test the exact value
16+
assert out["last_modified"]
2317

2418

25-
def test_add_commit_history_info_invalid():
26-
out = pep_footer._add_commit_history_info(PEP_ROOT / "pep-not-found.rst")
19+
def test_get_page_footer_context_no_history():
20+
out = pep_footer.get_page_footer_context("pep-not-found")
2721

28-
assert str(out) == "<paragraph/>"
22+
# No git history -> only the static source link
23+
assert out == {
24+
"source_link": "https://github.com/python/peps/blob/main/peps/pep-not-found.rst",
25+
}
2926

3027

3128
def test_get_last_modified_timestamps():

0 commit comments

Comments
 (0)