8000 Infra: Improve email and link processing and rendering in headers by CAM-Gerlach · Pull Request #2467 · python/peps · GitHub
[go: up one dir, main page]

Skip to content

Infra: Improve email and link processing and rendering in headers #2467

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

Merged
Prev Previous commit
Next Next commit
Infra: Automatically link list addresses to list pages in Discussions-To
  • Loading branch information
CAM-Gerlach committed Apr 17, 2022
commit e10e775929541ac179c84133045e1e8a91e0516f
23 changes: 23 additions & 0 deletions pep_sphinx_extensions/pep_processor/transforms/pep_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ def apply(self) -> None:
if (not isinstance(node, nodes.reference)
or not node["refuri"]):
continue
# Have known mailto links link to their main list pages
if node["refuri"].lower().startswith("mailto:"):
node["refuri"] = _generate_list_url(node["refuri"])
parts = node["refuri"].lower().split("/")
if len(parts) <= 2 or parts[2] not in LINK_PRETTIFIERS:
continue
Expand All @@ -104,6 +107,26 @@ def apply(self) -> None:
field.parent.remove(field)


def _generate_list_url(mailto: str) -> str:
list_name_domain = mailto.lower().removeprefix("mailto:").strip()
list_name = list_name_domain.split("@")[0]

if list_name_domain.endswith("@googlegroups.com"):
return f"https://groups.google.com/g/{list_name}"

if not list_name_domain.endswith("@python.org"):
return mailto

# Active lists not yet on Mailman3; this URL will redirect if/when they are
if list_name in {"csv", "db-sig", "doc-sig", "python-list", "web-sig"}:
return f"https://mail.python.org/mailman/listinfo/{list_name}"
# Retired lists that are closed for posting, so only the archive matters
if list_name in {"import-sig", "python-3000"}:
return f"https://mail.python.org/pipermail/{list_name}/"
# The remaining lists (and any new ones) are all on Mailman3/Hyperkitty
return f"https://mail.python.org/archives/list/{list_name}@python.org/"


def _process_list_url(parts: list[str]) -> tuple[str, str]:
item_type = "list"

Expand Down
0