-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Support redirects from non-padded PEP numbers #2421
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,19 @@ | ||||||
from __future__ import annotations | ||||||
|
||||||
from typing import TYPE_CHECKING | ||||||
|
||||||
from pathlib import Path | ||||||
|
||||||
if TYPE_CHECKING: | ||||||
from collections.abc import Iterator | ||||||
|
||||||
from sphinx.application import Sphinx | ||||||
|
||||||
|
||||||
def prepare_redirect_pages(app: Sphinx) -> Iterator[tuple[str, dict, str]]: | ||||||
AA-Turner marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
for path in Path(app.srcdir).glob("pep-????.???"): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Use the correct glob to ensure this is actually a PEP with a valid number. Otherwise, it can match any arbitrary There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This is I suppose my reluctance to put A There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I hope you didn't stay up all night...or just up really early? A few more characters perhaps, but in terms of what actually matters, does that make it that much less clear to the reader? And is it really worth sacrificing precision and correctness, and risking a potential future hard build failure just to skimp on a few characters? I realize there is some tradeoff to be made, but it seems the rest of us who have weighed in so far have considered it a worthwhile one. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. I still disagree though! A |
||||||
if path.suffix not in {".txt", ".rst"}: | ||||||
continue | ||||||
|
||||||
pep_num = int(path.stem[4:]) | ||||||
yield str(pep_num), {"pep_file": path.stem, "pep_num": pep_num}, "redirect.html" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{# Redirect template #} | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
AA-Turner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<meta http-equiv="refresh" content="0; url={{ pathto(pep_file) }}"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
AA-Turner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<title>PEP Redirector | peps.python.org</title> | ||
<link rel="shortcut icon" href="{{ pathto('_static/py.png', resource=True) }}"/> | ||
AA-Turner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<link rel="canonical" href="{{ pathto(pep_file) }}" /> | ||
<meta name="description" content="Python Enhancement Proposals (PEPs)"/> | ||
</head> | ||
<body> | ||
<p><a href="{{ pathto(pep_file) }}">PEP {{ pep_num }}</a></p> | ||
</body> | ||
AA-Turner marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</html> |
Uh oh!
There was an error while loading. Please reload this page.