From 90b56ff3c532cab617366890bb0c0ff8e5a91809 Mon Sep 17 00:00:00 2001 From: "C.A.M. Gerlach" Date: Thu, 24 Mar 2022 23:12:54 -0500 Subject: [PATCH] Infra: Automatically link list addresses to list pages in Discussions-To --- .../pep_processor/transforms/pep_headers.py | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/pep_sphinx_extensions/pep_processor/transforms/pep_headers.py b/pep_sphinx_extensions/pep_processor/transforms/pep_headers.py index 9339def97c77..2b4cc5d0766f 100644 --- a/pep_sphinx_extensions/pep_processor/transforms/pep_headers.py +++ b/pep_sphinx_extensions/pep_processor/transforms/pep_headers.py @@ -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 @@ -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"