prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Waste less vertical space at top of rendered PEP
  This is about usability of peps rendered on peps.python.org.
  
  At the top of a PEP (e.g. https://peps.python.org/pep-0687/) there's a table with metadata. Most of that I ignore or is even duplicate (the title). I usually have to scroll right past that to the Abstract. Maybe the metadata could be collapsed, like the ToC? Or moved to the sidebar, like the ToC?
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `pep_sphinx_extensions/pep_processor/transforms/pep_title.py`
  Content:
  ```
  1 from pathlib import Path
  2 
  3 from docutils import nodes
  4 from docutils import transforms
  5 from docutils import utils
  6 from docutils.parsers.rst import roles
  7 from docutils.parsers.rst import states
  8 
  9 
  10 class PEPTitle(transforms.Transform):
  11     """Add PEP title and organise document hierarchy."""
  12 
  13     # needs to run before docutils.transforms.frontmatter.DocInfo and after
  14     # pep_processor.transforms.pep_title.PEPTitle
  15     default_priority = 335
  16 
  17     def apply(self) -> None:
  18         if not Path(self.document["source"]).match("pep-*"):
  19             return  # not a PEP file, exit early
  20 
  21         # Directory to hold the PEP's RFC2822 header details, to extract a title string
  22         pep_header_details = {}
  23 
  24         # Iterate through the header fields, which are the first section of the document
  25         for field in self.document[0]:
  26             # Hold details of the attribute's tag against its details
  27             row_attributes = {sub.tagname: sub.rawsource for sub in field}
  28             pep_header_details[row_attributes["field_name"]] = row_attributes["field_body"]
  29 
  30             # We only need the PEP number and title
  31             if pep_header_details.keys() >= {"PEP", "Title"}:
  32                 break
  33 
  34         # Create the title string for the PEP
  35         pep_number = int(pep_header_details["PEP"])
  36         pep_title = pep_header_details["Title"]
  37         pep_title_string = f"PEP {pep_number} -- {pep_title}"  # double hyphen for en dash
  38 
  39         # Generate the title section node and its properties
  40         title_nodes = _line_to_nodes(pep_title_string)
  41         pep_title_node = nodes.section("", nodes.title("", "", *title_nodes, classes=["page-title"]), names=["pep-content"])
  42 
  43         # Insert the title node as the root element, move children down
  44         document_children = self.document.children
  45         self.document.children = [pep_title_node]
  46         pep_title_node.extend(document_children)
  47         self.document.note_implicit_target(pep_title_node, pep_title_node)
  48 
  49 
  50 def _line_to_nodes(text: str) -> list[nodes.Node]:
  51     """Parse RST string to nodes."""
  52     document = utils.new_document("<inline-rst>")
  53     document.settings.pep_references = document.settings.rfc_references = False  # patch settings
  54     states.RSTStateMachine(state_classes=states.state_classes, initial_state="Body").run([text], document)  # do parsing
  55     roles._roles.pop("", None)  # restore the "default" default role after parsing a document
  56     return document[0].children
  57
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/pep_sphinx_extensions/pep_processor/transforms/pep_title.py b/pep_sphinx_extensions/pep_processor/transforms/pep_title.py
  --- a/pep_sphinx_extensions/pep_processor/transforms/pep_title.py
  +++ b/pep_sphinx_extensions/pep_processor/transforms/pep_title.py
  @@ -22,13 +22,19 @@
           pep_header_details = {}
   
           # Iterate through the header fields, which are the first section of the document
  +        desired_fields = {"PEP", "Title"}
  +        fields_to_remove = []
           for field in self.document[0]:
               # Hold details of the attribute's tag against its details
               row_attributes = {sub.tagname: sub.rawsource for sub in field}
               pep_header_details[row_attributes["field_name"]] = row_attributes["field_body"]
   
  +            # Store the redundant fields in the table for removal
  +            if row_attributes["field_name"] in desired_fields:
  +                fields_to_remove.append(field)
  +
               # We only need the PEP number and title
  -            if pep_header_details.keys() >= {"PEP", "Title"}:
  +            if pep_header_details.keys() >= desired_fields:
                   break
   
           # Create the title string for the PEP
  @@ -46,6 +52,10 @@
           pep_title_node.extend(document_children)
           self.document.note_implicit_target(pep_title_node, pep_title_node)
   
  +        # Remove the now-redundant fields
  +        for field in fields_to_remove:
  +            field.parent.remove(field)
  +
   
   def _line_to_nodes(text: str) -> list[nodes.Node]:
       """Parse RST string to nodes."""
  
verification_info: {"golden_diff": "diff --git a/pep_sphinx_extensions/pep_processor/transforms/pep_title.py b/pep_sphinx_extensions/pep_processor/transforms/pep_title.py\n--- a/pep_sphinx_extensions/pep_processor/transforms/pep_title.py\n+++ b/pep_sphinx_extensions/pep_processor/transforms/pep_title.py\n@@ -22,13 +22,19 @@\n         pep_header_details = {}\n \n         # Iterate through the header fields, which are the first section of the document\n+        desired_fields = {\"PEP\", \"Title\"}\n+        fields_to_remove = []\n         for field in self.document[0]:\n             # Hold details of the attribute's tag against its details\n             row_attributes = {sub.tagname: sub.rawsource for sub in field}\n             pep_header_details[row_attributes[\"field_name\"]] = row_attributes[\"field_body\"]\n \n+            # Store the redundant fields in the table for removal\n+            if row_attributes[\"field_name\"] in desired_fields:\n+                fields_to_remove.append(field)\n+\n             # We only need the PEP number and title\n-            if pep_header_details.keys() >= {\"PEP\", \"Title\"}:\n+            if pep_header_details.keys() >= desired_fields:\n                 break\n \n         # Create the title string for the PEP\n@@ -46,6 +52,10 @@\n         pep_title_node.extend(document_children)\n         self.document.note_implicit_target(pep_title_node, pep_title_node)\n \n+        # Remove the now-redundant fields\n+        for field in fields_to_remove:\n+            field.parent.remove(field)\n+\n \n def _line_to_nodes(text: str) -> list[nodes.Node]:\n     \"\"\"Parse RST string to nodes.\"\"\"\n", "issue": "Waste less vertical space at top of rendered PEP\nThis is about usability of peps rendered on peps.python.org.\r\n\r\nAt the top of a PEP (e.g. https://peps.python.org/pep-0687/) there's a table with metadata. Most of that I ignore or is even duplicate (the title). I usually have to scroll right past that to the Abstract. Maybe the metadata could be collapsed, like the ToC? Or moved to the sidebar, like the ToC?\n", "before_files": [{"content": "from pathlib import Path\n\nfrom docutils import nodes\nfrom docutils import transforms\nfrom docutils import utils\nfrom docutils.parsers.rst import roles\nfrom docutils.parsers.rst import states\n\n\nclass PEPTitle(transforms.Transform):\n    \"\"\"Add PEP title and organise document hierarchy.\"\"\"\n\n    # needs to run before docutils.transforms.frontmatter.DocInfo and after\n    # pep_processor.transforms.pep_title.PEPTitle\n    default_priority = 335\n\n    def apply(self) -> None:\n        if not Path(self.document[\"source\"]).match(\"pep-*\"):\n            return  # not a PEP file, exit early\n\n        # Directory to hold the PEP's RFC2822 header details, to extract a title string\n        pep_header_details = {}\n\n        # Iterate through the header fields, which are the first section of the document\n        for field in self.document[0]:\n            # Hold details of the attribute's tag against its details\n            row_attributes = {sub.tagname: sub.rawsource for sub in field}\n            pep_header_details[row_attributes[\"field_name\"]] = row_attributes[\"field_body\"]\n\n            # We only need the PEP number and title\n            if pep_header_details.keys() >= {\"PEP\", \"Title\"}:\n                break\n\n        # Create the title string for the PEP\n        pep_number = int(pep_header_details[\"PEP\"])\n        pep_title = pep_header_details[\"Title\"]\n        pep_title_string = f\"PEP {pep_number} -- {pep_title}\"  # double hyphen for en dash\n\n        # Generate the title section node and its properties\n        title_nodes = _line_to_nodes(pep_title_string)\n        pep_title_node = nodes.section(\"\", nodes.title(\"\", \"\", *title_nodes, classes=[\"page-title\"]), names=[\"pep-content\"])\n\n        # Insert the title node as the root element, move children down\n        document_children = self.document.children\n        self.document.children = [pep_title_node]\n        pep_title_node.extend(document_children)\n        self.document.note_implicit_target(pep_title_node, pep_title_node)\n\n\ndef _line_to_nodes(text: str) -> list[nodes.Node]:\n    \"\"\"Parse RST string to nodes.\"\"\"\n    document = utils.new_document(\"<inline-rst>\")\n    document.settings.pep_references = document.settings.rfc_references = False  # patch settings\n    states.RSTStateMachine(state_classes=states.state_classes, initial_state=\"Body\").run([text], document)  # do parsing\n    roles._roles.pop(\"\", None)  # restore the \"default\" default role after parsing a document\n    return document[0].children\n", "path": "pep_sphinx_extensions/pep_processor/transforms/pep_title.py"}], "after_files": [{"content": "from pathlib import Path\n\nfrom docutils import nodes\nfrom docutils import transforms\nfrom docutils import utils\nfrom docutils.parsers.rst import roles\nfrom docutils.parsers.rst import states\n\n\nclass PEPTitle(transforms.Transform):\n    \"\"\"Add PEP title and organise document hierarchy.\"\"\"\n\n    # needs to run before docutils.transforms.frontmatter.DocInfo and after\n    # pep_processor.transforms.pep_title.PEPTitle\n    default_priority = 335\n\n    def apply(self) -> None:\n        if not Path(self.document[\"source\"]).match(\"pep-*\"):\n            return  # not a PEP file, exit early\n\n        # Directory to hold the PEP's RFC2822 header details, to extract a title string\n        pep_header_details = {}\n\n        # Iterate through the header fields, which are the first section of the document\n        desired_fields = {\"PEP\", \"Title\"}\n        fields_to_remove = []\n        for field in self.document[0]:\n            # Hold details of the attribute's tag against its details\n            row_attributes = {sub.tagname: sub.rawsource for sub in field}\n            pep_header_details[row_attributes[\"field_name\"]] = row_attributes[\"field_body\"]\n\n            # Store the redundant fields in the table for removal\n            if row_attributes[\"field_name\"] in desired_fields:\n                fields_to_remove.append(field)\n\n            # We only need the PEP number and title\n            if pep_header_details.keys() >= desired_fields:\n                break\n\n        # Create the title string for the PEP\n        pep_number = int(pep_header_details[\"PEP\"])\n        pep_title = pep_header_details[\"Title\"]\n        pep_title_string = f\"PEP {pep_number} -- {pep_title}\"  # double hyphen for en dash\n\n        # Generate the title section node and its properties\n        title_nodes = _line_to_nodes(pep_title_string)\n        pep_title_node = nodes.section(\"\", nodes.title(\"\", \"\", *title_nodes, classes=[\"page-title\"]), names=[\"pep-content\"])\n\n        # Insert the title node as the root element, move children down\n        document_children = self.document.children\n        self.document.children = [pep_title_node]\n        pep_title_node.extend(document_children)\n        self.document.note_implicit_target(pep_title_node, pep_title_node)\n\n        # Remove the now-redundant fields\n        for field in fields_to_remove:\n            field.parent.remove(field)\n\n\ndef _line_to_nodes(text: str) -> list[nodes.Node]:\n    \"\"\"Parse RST string to nodes.\"\"\"\n    document = utils.new_document(\"<inline-rst>\")\n    document.settings.pep_references = document.settings.rfc_references = False  # patch settings\n    states.RSTStateMachine(state_classes=states.state_classes, initial_state=\"Body\").run([text], document)  # do parsing\n    roles._roles.pop(\"\", None)  # restore the \"default\" default role after parsing a document\n    return document[0].children\n", "path": "pep_sphinx_extensions/pep_processor/transforms/pep_title.py"}]}