Skip to content

Commit

Permalink
Infra: Automatically link list addresses to list pages in Discussions-To
Browse files Browse the repository at this point in the history
  • Loading branch information
CAM-Gerlach committed Mar 25, 2022
1 parent a0e50cc commit 90b56ff
Showing 1 changed file with 23 additions and 0 deletions.
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 comments on commit 90b56ff

Please sign in to comment.