From d2ad2df8d0cc7840952183e306f378158e6e849d Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Tue, 31 Jan 2023 11:28:23 +0200 Subject: [PATCH 1/7] Add topic header to PEPs 1 and 12 --- pep-0001.txt | 4 ++++ pep-0012/pep-NNNN.rst | 1 + 2 files changed, 5 insertions(+) diff --git a/pep-0001.txt b/pep-0001.txt index 421aefb194d..3067f57b3f8 100644 --- a/pep-0001.txt +++ b/pep-0001.txt @@ -605,6 +605,7 @@ optional and are described below. All other headers are required. Status: Type: + * Topic: * Content-Type: text/x-rst * Requires: Created: @@ -659,6 +660,9 @@ archives, rather than just a mailto: or hyperlink to the list itself. The Type header specifies the type of PEP: Standards Track, Informational, or Process. +The optional Topic header specifies which topic, if any, the PEP belongs in. +See https://peps.python.org/topic/ for the existing topics. + The format of a PEP is specified with a Content-Type header. All PEPs must use reStructuredText (see :pep:`12`), and have a value of ``text/x-rst``, the default. diff --git a/pep-0012/pep-NNNN.rst b/pep-0012/pep-NNNN.rst index cc66a057285..011616f6f29 100644 --- a/pep-0012/pep-NNNN.rst +++ b/pep-0012/pep-NNNN.rst @@ -6,6 +6,7 @@ PEP-Delegate: Discussions-To: Status: Type: +Topic: Content-Type: text/x-rst Requires: Created: From d33389e751363db49d1b562808c3de158af3318e Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Wed, 1 Feb 2023 18:46:38 +0200 Subject: [PATCH 2/7] Review updates Co-authored-by: C.A.M. Gerlach --- pep-0001.txt | 5 +++-- pep_sphinx_extensions/pep_zero_generator/subindices.py | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pep-0001.txt b/pep-0001.txt index 3067f57b3f8..e0fb766777e 100644 --- a/pep-0001.txt +++ b/pep-0001.txt @@ -660,8 +660,9 @@ archives, rather than just a mailto: or hyperlink to the list itself. The Type header specifies the type of PEP: Standards Track, Informational, or Process. -The optional Topic header specifies which topic, if any, the PEP belongs in. -See https://peps.python.org/topic/ for the existing topics. +The optional Topic header lists which special topics, if any, +the PEP belongs under. +See the :ref:`topic-index` for the existing topics. The format of a PEP is specified with a Content-Type header. All PEPs must use reStructuredText (see :pep:`12`), diff --git a/pep_sphinx_extensions/pep_zero_generator/subindices.py b/pep_sphinx_extensions/pep_zero_generator/subindices.py index 293abe0241d..455a49dd8f0 100644 --- a/pep_sphinx_extensions/pep_zero_generator/subindices.py +++ b/pep_sphinx_extensions/pep_zero_generator/subindices.py @@ -57,6 +57,8 @@ def generate_subindices( def generate_topic_contents(docnames: list[str], env: BuildEnvironment): update_sphinx("topic/index", """\ +.. _topic-index: + Topic Index *********** From 930c77e326505013346341f0aeffa7a2f84cf0d3 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Wed, 1 Feb 2023 18:50:15 +0200 Subject: [PATCH 3/7] Redirect topics to topic/ --- infra/main.tf | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/infra/main.tf b/infra/main.tf index faf53b404c2..2fc8cb799bc 100644 --- a/infra/main.tf +++ b/infra/main.tf @@ -39,6 +39,16 @@ resource "fastly_service_vcl" "peps" { EOT } + snippet { + name = "topics" + type = "recv" + content = <<-EOT + if (req.url == "/topics") { + set req.url = "/topic/"; + } + EOT + } + snippet { name = "redirect" type = "error" From 481761e474c276e4d7eaa26d0fdfd3c6a955b6ba Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 2 Feb 2023 12:51:31 +0200 Subject: [PATCH 4/7] Update topics->topic redirect Co-authored-by: C.A.M. Gerlach --- infra/main.tf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/infra/main.tf b/infra/main.tf index 2fc8cb799bc..a2169a81ee3 100644 --- a/infra/main.tf +++ b/infra/main.tf @@ -43,8 +43,9 @@ resource "fastly_service_vcl" "peps" { name = "topics" type = "recv" content = <<-EOT - if (req.url == "/topics") { - set req.url = "/topic/"; + if (req.url ~ "^/topics($|/)") { + set req.http.Location = regsub(req.http.Location, "^/topics/?", "/topic/"); + error 618; } EOT } From c5a5811533487bb14d050c0efd689af6927c7000 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 2 Feb 2023 12:58:31 +0200 Subject: [PATCH 5/7] Singular topic Co-authored-by: C.A.M. Gerlach --- pep-0001.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pep-0001.txt b/pep-0001.txt index e0fb766777e..5560a7d744b 100644 --- a/pep-0001.txt +++ b/pep-0001.txt @@ -660,7 +660,7 @@ archives, rather than just a mailto: or hyperlink to the list itself. The Type header specifies the type of PEP: Standards Track, Informational, or Process. -The optional Topic header lists which special topics, if any, +The optional Topic header lists the special topic, if any, the PEP belongs under. See the :ref:`topic-index` for the existing topics. From d75d4cd9bc5590bb7f68ea686fa8fda54216fd6c Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 2 Feb 2023 13:12:46 +0200 Subject: [PATCH 6/7] Add topic header to PEP 12 --- pep-0012.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pep-0012.rst b/pep-0012.rst index 3c488e10c8e..bea8a80836a 100644 --- a/pep-0012.rst +++ b/pep-0012.rst @@ -121,6 +121,9 @@ directions below. Python-Version: 2.2 +- Add a Topic header if the PEP belongs under one shown at the :ref:`topic-index`. + Most PEPs don't. + - Leave Post-History alone for now; you'll add dates and corresponding links to this header each time you post your PEP to the designated discussion forum (and update the Discussions-To header with said link, as above). @@ -174,6 +177,7 @@ your PEP): Discussions-To: [URL] Status: Draft Type: [Standards Track | Informational | Process] + Topic: *[Governance | Packaging | Release | Typing] Content-Type: text/x-rst Requires: *[NNN] Created: [DD-MMM-YYYY] From 16f6d7abca7bcc4a02d25bdfa0942b77746fec88 Mon Sep 17 00:00:00 2001 From: Hugo van Kemenade Date: Thu, 2 Feb 2023 13:14:32 +0200 Subject: [PATCH 7/7] Add htmlview target to Makefile --- Makefile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Makefile b/Makefile index c97937106d2..e247299beb1 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,11 @@ RENDER_COMMAND=$(VENVDIR)/bin/python3 build.py -j $(JOBS) -o $(OUTPUT_DIR) html: venv $(RENDER_COMMAND) +## htmlview to open the index page built by the html target in your browser +.PHONY: htmlview +htmlview: html + $(PYTHON) -c "import os, webbrowser; webbrowser.open('file://' + os.path.realpath('build/index.html'))" + ## dirhtml to render PEPs to "index.html" files within "pep-NNNN" directories .PHONY: dirhtml dirhtml: venv rss