prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  Links on topic pages are broken
  If you go to a page like https://peps.python.org/topic/packaging/ and try to click on any of the PEPs, you get a github 404, and the URL is ``https://peps.python.org/topic/pep-0582``. 
  
  </issue>
  <code>
  [start of pep_sphinx_extensions/__init__.py]
  1 """Sphinx extensions for performant PEP processing"""
  2 
  3 from __future__ import annotations
  4 
  5 from typing import TYPE_CHECKING
  6 
  7 from docutils.writers.html5_polyglot import HTMLTranslator
  8 from sphinx import environment
  9 from sphinx import project
  10 
  11 from pep_sphinx_extensions.pep_processor.html import pep_html_builder
  12 from pep_sphinx_extensions.pep_processor.html import pep_html_translator
  13 from pep_sphinx_extensions.pep_processor.parsing import pep_parser
  14 from pep_sphinx_extensions.pep_processor.parsing import pep_role
  15 from pep_sphinx_extensions.pep_processor.transforms import pep_references
  16 from pep_sphinx_extensions.pep_zero_generator.pep_index_generator import create_pep_zero
  17 
  18 if TYPE_CHECKING:
  19     from sphinx.application import Sphinx
  20     from sphinx.config import Config
  21 
  22 
  23 def find_files(self: environment.BuildEnvironment, config: Config, _b) -> None:
  24     """Find all pep source files."""
  25     import fnmatch
  26     from pathlib import Path
  27 
  28     root = Path(self.project.srcdir).absolute()
  29     self.project.docnames = set()
  30     for pattern in config.include_patterns:
  31         for path in root.glob(pattern):
  32             filename = str(path.relative_to(root))
  33             if any(fnmatch.fnmatch(filename, pattern) for pattern in config.exclude_patterns):
  34                 continue
  35 
  36             doc_name = self.project.path2doc(filename)
  37             if not doc_name:
  38                 continue
  39 
  40             if doc_name not in self.project.docnames:
  41                 self.project.docnames.add(doc_name)
  42                 continue
  43 
  44             other_files = [str(f.relative_to(root)) for f in root.glob(f"{doc_name}.*")]
  45             project.logger.warning(
  46                 f'multiple files found for the document "{doc_name}": {other_files!r}\n'
  47                 f'Use {self.doc2path(doc_name)!r} for the build.', once=True)
  48 
  49 
  50 environment.BuildEnvironment.find_files = find_files
  51 
  52 
  53 def _depart_maths():
  54     pass  # No-op callable for the type checker
  55 
  56 
  57 def _update_config_for_builder(app: Sphinx) -> None:
  58     app.env.document_ids = {}  # For PEPReferenceRoleTitleText
  59     if app.builder.name == "dirhtml":
  60         app.env.settings["pep_url"] = "../pep-{:0>4}"
  61 
  62     # internal_builder exists if Sphinx is run by build.py
  63     if "internal_builder" not in app.tags:
  64         app.connect("build-finished", _post_build)  # Post-build tasks
  65 
  66 
  67 def _post_build(app: Sphinx, exception: Exception | None) -> None:
  68     from pathlib import Path
  69 
  70     from build import create_index_file
  71 
  72     if exception is not None:
  73         return
  74     create_index_file(Path(app.outdir), app.builder.name)
  75 
  76 
  77 def setup(app: Sphinx) -> dict[str, bool]:
  78     """Initialize Sphinx extension."""
  79 
  80     environment.default_settings["pep_url"] = "pep-{:0>4}.html"
  81     environment.default_settings["halt_level"] = 2  # Fail on Docutils warning
  82 
  83     # Register plugin logic
  84     app.add_builder(pep_html_builder.FileBuilder, override=True)
  85     app.add_builder(pep_html_builder.DirectoryBuilder, override=True)
  86 
  87     app.add_source_parser(pep_parser.PEPParser)  # Add PEP transforms
  88 
  89     app.set_translator("html", pep_html_translator.PEPTranslator)  # Docutils Node Visitor overrides (html builder)
  90     app.set_translator("dirhtml", pep_html_translator.PEPTranslator)  # Docutils Node Visitor overrides (dirhtml builder)
  91 
  92     app.add_role("pep", pep_role.PEPRole(), override=True)  # Transform PEP references to links
  93 
  94     app.add_post_transform(pep_references.PEPReferenceRoleTitleText)
  95 
  96     # Register event callbacks
  97     app.connect("builder-inited", _update_config_for_builder)  # Update configuration values for builder used
  98     app.connect("env-before-read-docs", create_pep_zero)  # PEP 0 hook
  99 
  100     # Mathematics rendering
  101     inline_maths = HTMLTranslator.visit_math, _depart_maths
  102     block_maths = HTMLTranslator.visit_math_block, _depart_maths
  103     app.add_html_math_renderer("maths_to_html", inline_maths, block_maths)  # Render maths to HTML
  104 
  105     # Parallel safety: https://www.sphinx-doc.org/en/master/extdev/index.html#extension-metadata
  106     return {"parallel_read_safe": True, "parallel_write_safe": True}
  107
  [end of pep_sphinx_extensions/__init__.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/pep_sphinx_extensions/__init__.py b/pep_sphinx_extensions/__init__.py
  --- a/pep_sphinx_extensions/__init__.py
  +++ b/pep_sphinx_extensions/__init__.py
  @@ -57,7 +57,7 @@
   def _update_config_for_builder(app: Sphinx) -> None:
       app.env.document_ids = {}  # For PEPReferenceRoleTitleText
       if app.builder.name == "dirhtml":
  -        app.env.settings["pep_url"] = "../pep-{:0>4}"
  +        app.env.settings["pep_url"] = "/pep-{:0>4}"
   
       # internal_builder exists if Sphinx is run by build.py
       if "internal_builder" not in app.tags:
  @@ -77,7 +77,7 @@
   def setup(app: Sphinx) -> dict[str, bool]:
       """Initialize Sphinx extension."""
   
  -    environment.default_settings["pep_url"] = "pep-{:0>4}.html"
  +    environment.default_settings["pep_url"] = "/pep-{:0>4}.html"
       environment.default_settings["halt_level"] = 2  # Fail on Docutils warning
   
       # Register plugin logic
  
verification_info: {"golden_diff": "diff --git a/pep_sphinx_extensions/__init__.py b/pep_sphinx_extensions/__init__.py\n--- a/pep_sphinx_extensions/__init__.py\n+++ b/pep_sphinx_extensions/__init__.py\n@@ -57,7 +57,7 @@\n def _update_config_for_builder(app: Sphinx) -> None:\n     app.env.document_ids = {}  # For PEPReferenceRoleTitleText\n     if app.builder.name == \"dirhtml\":\n-        app.env.settings[\"pep_url\"] = \"../pep-{:0>4}\"\n+        app.env.settings[\"pep_url\"] = \"/pep-{:0>4}\"\n \n     # internal_builder exists if Sphinx is run by build.py\n     if \"internal_builder\" not in app.tags:\n@@ -77,7 +77,7 @@\n def setup(app: Sphinx) -> dict[str, bool]:\n     \"\"\"Initialize Sphinx extension.\"\"\"\n \n-    environment.default_settings[\"pep_url\"] = \"pep-{:0>4}.html\"\n+    environment.default_settings[\"pep_url\"] = \"/pep-{:0>4}.html\"\n     environment.default_settings[\"halt_level\"] = 2  # Fail on Docutils warning\n \n     # Register plugin logic\n", "issue": "Links on topic pages are broken\nIf you go to a page like https://peps.python.org/topic/packaging/ and try to click on any of the PEPs, you get a github 404, and the URL is ``https://peps.python.org/topic/pep-0582``. \n", "before_files": [{"content": "\"\"\"Sphinx extensions for performant PEP processing\"\"\"\n\nfrom __future__ import annotations\n\nfrom typing import TYPE_CHECKING\n\nfrom docutils.writers.html5_polyglot import HTMLTranslator\nfrom sphinx import environment\nfrom sphinx import project\n\nfrom pep_sphinx_extensions.pep_processor.html import pep_html_builder\nfrom pep_sphinx_extensions.pep_processor.html import pep_html_translator\nfrom pep_sphinx_extensions.pep_processor.parsing import pep_parser\nfrom pep_sphinx_extensions.pep_processor.parsing import pep_role\nfrom pep_sphinx_extensions.pep_processor.transforms import pep_references\nfrom pep_sphinx_extensions.pep_zero_generator.pep_index_generator import create_pep_zero\n\nif TYPE_CHECKING:\n    from sphinx.application import Sphinx\n    from sphinx.config import Config\n\n\ndef find_files(self: environment.BuildEnvironment, config: Config, _b) -> None:\n    \"\"\"Find all pep source files.\"\"\"\n    import fnmatch\n    from pathlib import Path\n\n    root = Path(self.project.srcdir).absolute()\n    self.project.docnames = set()\n    for pattern in config.include_patterns:\n        for path in root.glob(pattern):\n            filename = str(path.relative_to(root))\n            if any(fnmatch.fnmatch(filename, pattern) for pattern in config.exclude_patterns):\n                continue\n\n            doc_name = self.project.path2doc(filename)\n            if not doc_name:\n                continue\n\n            if doc_name not in self.project.docnames:\n                self.project.docnames.add(doc_name)\n                continue\n\n            other_files = [str(f.relative_to(root)) for f in root.glob(f\"{doc_name}.*\")]\n            project.logger.warning(\n                f'multiple files found for the document \"{doc_name}\": {other_files!r}\\n'\n                f'Use {self.doc2path(doc_name)!r} for the build.', once=True)\n\n\nenvironment.BuildEnvironment.find_files = find_files\n\n\ndef _depart_maths():\n    pass  # No-op callable for the type checker\n\n\ndef _update_config_for_builder(app: Sphinx) -> None:\n    app.env.document_ids = {}  # For PEPReferenceRoleTitleText\n    if app.builder.name == \"dirhtml\":\n        app.env.settings[\"pep_url\"] = \"../pep-{:0>4}\"\n\n    # internal_builder exists if Sphinx is run by build.py\n    if \"internal_builder\" not in app.tags:\n        app.connect(\"build-finished\", _post_build)  # Post-build tasks\n\n\ndef _post_build(app: Sphinx, exception: Exception | None) -> None:\n    from pathlib import Path\n\n    from build import create_index_file\n\n    if exception is not None:\n        return\n    create_index_file(Path(app.outdir), app.builder.name)\n\n\ndef setup(app: Sphinx) -> dict[str, bool]:\n    \"\"\"Initialize Sphinx extension.\"\"\"\n\n    environment.default_settings[\"pep_url\"] = \"pep-{:0>4}.html\"\n    environment.default_settings[\"halt_level\"] = 2  # Fail on Docutils warning\n\n    # Register plugin logic\n    app.add_builder(pep_html_builder.FileBuilder, override=True)\n    app.add_builder(pep_html_builder.DirectoryBuilder, override=True)\n\n    app.add_source_parser(pep_parser.PEPParser)  # Add PEP transforms\n\n    app.set_translator(\"html\", pep_html_translator.PEPTranslator)  # Docutils Node Visitor overrides (html builder)\n    app.set_translator(\"dirhtml\", pep_html_translator.PEPTranslator)  # Docutils Node Visitor overrides (dirhtml builder)\n\n    app.add_role(\"pep\", pep_role.PEPRole(), override=True)  # Transform PEP references to links\n\n    app.add_post_transform(pep_references.PEPReferenceRoleTitleText)\n\n    # Register event callbacks\n    app.connect(\"builder-inited\", _update_config_for_builder)  # Update configuration values for builder used\n    app.connect(\"env-before-read-docs\", create_pep_zero)  # PEP 0 hook\n\n    # Mathematics rendering\n    inline_maths = HTMLTranslator.visit_math, _depart_maths\n    block_maths = HTMLTranslator.visit_math_block, _depart_maths\n    app.add_html_math_renderer(\"maths_to_html\", inline_maths, block_maths)  # Render maths to HTML\n\n    # Parallel safety: https://www.sphinx-doc.org/en/master/extdev/index.html#extension-metadata\n    return {\"parallel_read_safe\": True, \"parallel_write_safe\": True}\n", "path": "pep_sphinx_extensions/__init__.py"}]}