We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Doc: gallery code links don't need to be underlined
As an example, https://2-5282596-gh.circle-artifacts.com/0/root/project/docs/build/html/gallery/miscellanea/star_shaped_boundary.html#sphx-glr-gallery-miscellanea-star-shaped-boundary-py has all of the functions that have links underlined. This adds visual noise that distracts from the message.

We want to keep the links, but define the CSS to avoid the underlining.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `docs/source/sphinxext/pre_sphinx_gallery.py`
Content:
```
1 """
2 Override sphinx_gallery's treatment of groups (folders) with cartopy's
3 ``__tags__`` semantics. This is tightly bound to the sphinx_gallery
4 implementation, hence the explicit version checking.
5 
6 """
7 from collections import OrderedDict
8 import os.path
9 import shutil
10 import tempfile
11 import textwrap
12 
13 import sphinx_gallery.gen_gallery
14 import sphinx_gallery.gen_rst
15 from sphinx_gallery.gen_rst import (
16     write_backreferences, extract_intro, _thumbnail_div,
17     generate_file_rst, sphinx_compatibility)
18 
19 
20 if sphinx_gallery.__version__ not in ['0.1.12']:
21     raise RuntimeError('not tested with this version of sphinx_gallery ({}). '
22                        'Please modify this check, and validate sphinx_gallery'
23                        ' behaves as expected.'
24                        ''.format(sphinx_gallery.__version__))
25 
26 
27 GALLERY_HEADER = textwrap.dedent("""
28 
29     Cartopy Gallery
30     ---------------
31 
32     The following visual examples demonstrate some of the functionality of
33     Cartopy, particularly its matplotlib interface.
34 
35     For a structured introduction to cartopy, including some of these
36     examples, see :ref:`getting-started-with-cartopy`.
37 
38 """)
39 
40 
41 def example_groups(src_dir):
42     """Return a dictionary of {tag: [example filenames]} for the given dir."""
43 
44     sorted_listdir = [fname for fname in sorted(os.listdir(src_dir))
45                       if fname.endswith('.py') and not fname.startswith('_')]
46     tagged_examples = {}
47 
48     for fname in sorted_listdir:
49         fpath = os.path.join(src_dir, fname)
50         __tags__ = []
51         with open(fpath, 'r') as fh:
52             for line in fh:
53                 # Crudely remove the __tags__ line.
54                 if line.startswith('__tags__ = '):
55                     exec(line.strip(), locals(), globals())
56                     for tag in __tags__:
57                         tagged_examples.setdefault(tag, []).append(fname)
58                     break
59             else:
60                 tag = 'Miscellanea'
61                 tagged_examples.setdefault(tag, []).append(fname)
62     return tagged_examples
63 
64 
65 def order_examples(tagged_examples):
66     """Order the tags and their examples."""
67     preferred_tag_order = ['Introductory',
68                            'Lines and polygons',
69                            'Scalar data',
70                            'Vector data',
71                            'Web services']
72 
73     def sort_key(item):
74         tag = item[0]
75         try:
76             index = preferred_tag_order.index(tag)
77         except ValueError:
78             index = len(preferred_tag_order) + 1
79 
80         return (index, tag.lower())
81     sorted_items = sorted(tagged_examples.items(), key=sort_key)
82     return OrderedDict(sorted_items)
83 
84 
85 def write_example(src_fpath, target_dir):
86     target_fpath = os.path.join(target_dir, os.path.basename(src_fpath))
87     with open(src_fpath, 'r') as fh:
88         with open(target_fpath, 'w') as fh_out:
89             for line in fh:
90                 # Crudely remove the __tags__ line.
91                 if line.startswith('__tags__ = '):
92                     continue
93                 fh_out.write(line)
94 
95 
96 def generate_dir_rst(src_dir, target_dir, gallery_conf, seen_backrefs):
97     """Generate the gallery reStructuredText for an example directory"""
98 
99     fhindex = GALLERY_HEADER
100 
101     if not os.path.exists(target_dir):
102         os.makedirs(target_dir)
103     tagged_examples = example_groups(src_dir)
104     tagged_examples = order_examples(tagged_examples)
105 
106     computation_times = []
107     build_target_dir = os.path.relpath(target_dir, gallery_conf['src_dir'])
108 
109     seen = set()
110     tmp_dir = tempfile.mkdtemp()
111 
112     for tag, examples in tagged_examples.items():
113         sorted_listdir = examples
114 
115         entries_text = []
116         iterator = sphinx_compatibility.status_iterator(
117             sorted_listdir,
118             'Generating gallery for %s ' % tag,
119             length=len(sorted_listdir))
120         for fname in iterator:
121             write_example(os.path.join(src_dir, fname), tmp_dir)
122             amount_of_code, time_elapsed = generate_file_rst(
123                 fname, target_dir, tmp_dir, gallery_conf)
124 
125             if fname not in seen:
126                 seen.add(fname)
127                 computation_times.append((time_elapsed, fname))
128 
129             new_fname = os.path.join(src_dir, fname)
130             intro = extract_intro(new_fname)
131             this_entry = _thumbnail_div(build_target_dir, fname, intro) + textwrap.dedent("""
132 
133                 .. toctree::
134                    :hidden:
135 
136                    /%s
137 
138                    """) % os.path.join(build_target_dir, fname[:-3]).replace(os.sep, '/')  # noqa: E501
139 
140             entries_text.append((amount_of_code, this_entry))
141 
142             if gallery_conf['backreferences_dir']:
143                 write_backreferences(seen_backrefs, gallery_conf,
144                                      target_dir, fname, intro)
145 
146         # sort to have the smallest entries in the beginning
147         entries_text.sort()
148 
149         fhindex += textwrap.dedent("""
150 
151         {tag}
152         {tag_underline}
153 
154         .. container:: gallery_images
155 
156         """.format(tag=tag, tag_underline='-' * len(tag)))
157 
158         for _, entry_text in entries_text:
159             fhindex += '\n    '.join(entry_text.split('\n'))
160 
161         # clear at the end of the section
162         fhindex += """.. raw:: html\n
163         <div style='clear:both'></div>\n\n"""
164 
165     # Tidy up the temp directory
166     shutil.rmtree(tmp_dir)
167 
168     return fhindex, computation_times
169 
170 
171 # Monkey-patch sphinx_gallery to handle cartopy's example format.
172 sphinx_gallery.gen_rst.generate_dir_rst = generate_dir_rst
173 sphinx_gallery.gen_gallery.generate_dir_rst = generate_dir_rst
174 
175 
176 def setup(app):
177     pass
178
```
--- 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()

```

diff --git a/docs/source/sphinxext/pre_sphinx_gallery.py b/docs/source/sphinxext/pre_sphinx_gallery.py
--- a/docs/source/sphinxext/pre_sphinx_gallery.py
+++ b/docs/source/sphinxext/pre_sphinx_gallery.py
@@ -47,13 +47,12 @@
 
     for fname in sorted_listdir:
         fpath = os.path.join(src_dir, fname)
-        __tags__ = []
         with open(fpath, 'r') as fh:
             for line in fh:
                 # Crudely remove the __tags__ line.
                 if line.startswith('__tags__ = '):
                     exec(line.strip(), locals(), globals())
-                    for tag in __tags__:
+                    for tag in __tags__:  # noqa:
                         tagged_examples.setdefault(tag, []).append(fname)
                     break
             else:

{"golden_diff": "diff --git a/docs/source/sphinxext/pre_sphinx_gallery.py b/docs/source/sphinxext/pre_sphinx_gallery.py\n--- a/docs/source/sphinxext/pre_sphinx_gallery.py\n+++ b/docs/source/sphinxext/pre_sphinx_gallery.py\n@@ -47,13 +47,12 @@\n \n     for fname in sorted_listdir:\n         fpath = os.path.join(src_dir, fname)\n-        __tags__ = []\n         with open(fpath, 'r') as fh:\n             for line in fh:\n                 # Crudely remove the __tags__ line.\n                 if line.startswith('__tags__ = '):\n                     exec(line.strip(), locals(), globals())\n-                    for tag in __tags__:\n+                    for tag in __tags__:  # noqa:\n                         tagged_examples.setdefault(tag, []).append(fname)\n                     break\n             else:\n", "issue": "Doc: gallery code links don't need to be underlined\nAs an example, https://2-5282596-gh.circle-artifacts.com/0/root/project/docs/build/html/gallery/miscellanea/star_shaped_boundary.html#sphx-glr-gallery-miscellanea-star-shaped-boundary-py has all of the functions that have links underlined. This adds visual noise that distracts from the message.\r\n\r\nWe want to keep the links, but define the CSS to avoid the underlining.\n", "before_files": [{"content": "\"\"\"\nOverride sphinx_gallery's treatment of groups (folders) with cartopy's\n``__tags__`` semantics. This is tightly bound to the sphinx_gallery\nimplementation, hence the explicit version checking.\n\n\"\"\"\nfrom collections import OrderedDict\nimport os.path\nimport shutil\nimport tempfile\nimport textwrap\n\nimport sphinx_gallery.gen_gallery\nimport sphinx_gallery.gen_rst\nfrom sphinx_gallery.gen_rst import (\n    write_backreferences, extract_intro, _thumbnail_div,\n    generate_file_rst, sphinx_compatibility)\n\n\nif sphinx_gallery.__version__ not in ['0.1.12']:\n    raise RuntimeError('not tested with this version of sphinx_gallery ({}). '\n                       'Please modify this check, and validate sphinx_gallery'\n                       ' behaves as expected.'\n                       ''.format(sphinx_gallery.__version__))\n\n\nGALLERY_HEADER = textwrap.dedent(\"\"\"\n\n    Cartopy Gallery\n    ---------------\n\n    The following visual examples demonstrate some of the functionality of\n    Cartopy, particularly its matplotlib interface.\n\n    For a structured introduction to cartopy, including some of these\n    examples, see :ref:`getting-started-with-cartopy`.\n\n\"\"\")\n\n\ndef example_groups(src_dir):\n    \"\"\"Return a dictionary of {tag: [example filenames]} for the given dir.\"\"\"\n\n    sorted_listdir = [fname for fname in sorted(os.listdir(src_dir))\n                      if fname.endswith('.py') and not fname.startswith('_')]\n    tagged_examples = {}\n\n    for fname in sorted_listdir:\n        fpath = os.path.join(src_dir, fname)\n        __tags__ = []\n        with open(fpath, 'r') as fh:\n            for line in fh:\n                # Crudely remove the __tags__ line.\n                if line.startswith('__tags__ = '):\n                    exec(line.strip(), locals(), globals())\n                    for tag in __tags__:\n                        tagged_examples.setdefault(tag, []).append(fname)\n                    break\n            else:\n                tag = 'Miscellanea'\n                tagged_examples.setdefault(tag, []).append(fname)\n    return tagged_examples\n\n\ndef order_examples(tagged_examples):\n    \"\"\"Order the tags and their examples.\"\"\"\n    preferred_tag_order = ['Introductory',\n                           'Lines and polygons',\n                           'Scalar data',\n                           'Vector data',\n                           'Web services']\n\n    def sort_key(item):\n        tag = item[0]\n        try:\n            index = preferred_tag_order.index(tag)\n        except ValueError:\n            index = len(preferred_tag_order) + 1\n\n        return (index, tag.lower())\n    sorted_items = sorted(tagged_examples.items(), key=sort_key)\n    return OrderedDict(sorted_items)\n\n\ndef write_example(src_fpath, target_dir):\n    target_fpath = os.path.join(target_dir, os.path.basename(src_fpath))\n    with open(src_fpath, 'r') as fh:\n        with open(target_fpath, 'w') as fh_out:\n            for line in fh:\n                # Crudely remove the __tags__ line.\n                if line.startswith('__tags__ = '):\n                    continue\n                fh_out.write(line)\n\n\ndef generate_dir_rst(src_dir, target_dir, gallery_conf, seen_backrefs):\n    \"\"\"Generate the gallery reStructuredText for an example directory\"\"\"\n\n    fhindex = GALLERY_HEADER\n\n    if not os.path.exists(target_dir):\n        os.makedirs(target_dir)\n    tagged_examples = example_groups(src_dir)\n    tagged_examples = order_examples(tagged_examples)\n\n    computation_times = []\n    build_target_dir = os.path.relpath(target_dir, gallery_conf['src_dir'])\n\n    seen = set()\n    tmp_dir = tempfile.mkdtemp()\n\n    for tag, examples in tagged_examples.items():\n        sorted_listdir = examples\n\n        entries_text = []\n        iterator = sphinx_compatibility.status_iterator(\n            sorted_listdir,\n            'Generating gallery for %s ' % tag,\n            length=len(sorted_listdir))\n        for fname in iterator:\n            write_example(os.path.join(src_dir, fname), tmp_dir)\n            amount_of_code, time_elapsed = generate_file_rst(\n                fname, target_dir, tmp_dir, gallery_conf)\n\n            if fname not in seen:\n                seen.add(fname)\n                computation_times.append((time_elapsed, fname))\n\n            new_fname = os.path.join(src_dir, fname)\n            intro = extract_intro(new_fname)\n            this_entry = _thumbnail_div(build_target_dir, fname, intro) + textwrap.dedent(\"\"\"\n\n                .. toctree::\n                   :hidden:\n\n                   /%s\n\n                   \"\"\") % os.path.join(build_target_dir, fname[:-3]).replace(os.sep, '/')  # noqa: E501\n\n            entries_text.append((amount_of_code, this_entry))\n\n            if gallery_conf['backreferences_dir']:\n                write_backreferences(seen_backrefs, gallery_conf,\n                                     target_dir, fname, intro)\n\n        # sort to have the smallest entries in the beginning\n        entries_text.sort()\n\n        fhindex += textwrap.dedent(\"\"\"\n\n        {tag}\n        {tag_underline}\n\n        .. container:: gallery_images\n\n        \"\"\".format(tag=tag, tag_underline='-' * len(tag)))\n\n        for _, entry_text in entries_text:\n            fhindex += '\\n    '.join(entry_text.split('\\n'))\n\n        # clear at the end of the section\n        fhindex += \"\"\".. raw:: html\\n\n        <div style='clear:both'></div>\\n\\n\"\"\"\n\n    # Tidy up the temp directory\n    shutil.rmtree(tmp_dir)\n\n    return fhindex, computation_times\n\n\n# Monkey-patch sphinx_gallery to handle cartopy's example format.\nsphinx_gallery.gen_rst.generate_dir_rst = generate_dir_rst\nsphinx_gallery.gen_gallery.generate_dir_rst = generate_dir_rst\n\n\ndef setup(app):\n    pass\n", "path": "docs/source/sphinxext/pre_sphinx_gallery.py"}], "after_files": [{"content": "\"\"\"\nOverride sphinx_gallery's treatment of groups (folders) with cartopy's\n``__tags__`` semantics. This is tightly bound to the sphinx_gallery\nimplementation, hence the explicit version checking.\n\n\"\"\"\nfrom collections import OrderedDict\nimport os.path\nimport shutil\nimport tempfile\nimport textwrap\n\nimport sphinx_gallery.gen_gallery\nimport sphinx_gallery.gen_rst\nfrom sphinx_gallery.gen_rst import (\n    write_backreferences, extract_intro, _thumbnail_div,\n    generate_file_rst, sphinx_compatibility)\n\n\nif sphinx_gallery.__version__ not in ['0.1.12']:\n    raise RuntimeError('not tested with this version of sphinx_gallery ({}). '\n                       'Please modify this check, and validate sphinx_gallery'\n                       ' behaves as expected.'\n                       ''.format(sphinx_gallery.__version__))\n\n\nGALLERY_HEADER = textwrap.dedent(\"\"\"\n\n    Cartopy Gallery\n    ---------------\n\n    The following visual examples demonstrate some of the functionality of\n    Cartopy, particularly its matplotlib interface.\n\n    For a structured introduction to cartopy, including some of these\n    examples, see :ref:`getting-started-with-cartopy`.\n\n\"\"\")\n\n\ndef example_groups(src_dir):\n    \"\"\"Return a dictionary of {tag: [example filenames]} for the given dir.\"\"\"\n\n    sorted_listdir = [fname for fname in sorted(os.listdir(src_dir))\n                      if fname.endswith('.py') and not fname.startswith('_')]\n    tagged_examples = {}\n\n    for fname in sorted_listdir:\n        fpath = os.path.join(src_dir, fname)\n        with open(fpath, 'r') as fh:\n            for line in fh:\n                # Crudely remove the __tags__ line.\n                if line.startswith('__tags__ = '):\n                    exec(line.strip(), locals(), globals())\n                    for tag in __tags__:  # noqa:\n                        tagged_examples.setdefault(tag, []).append(fname)\n                    break\n            else:\n                tag = 'Miscellanea'\n                tagged_examples.setdefault(tag, []).append(fname)\n    return tagged_examples\n\n\ndef order_examples(tagged_examples):\n    \"\"\"Order the tags and their examples.\"\"\"\n    preferred_tag_order = ['Introductory',\n                           'Lines and polygons',\n                           'Scalar data',\n                           'Vector data',\n                           'Web services']\n\n    def sort_key(item):\n        tag = item[0]\n        try:\n            index = preferred_tag_order.index(tag)\n        except ValueError:\n            index = len(preferred_tag_order) + 1\n\n        return (index, tag.lower())\n    sorted_items = sorted(tagged_examples.items(), key=sort_key)\n    return OrderedDict(sorted_items)\n\n\ndef write_example(src_fpath, target_dir):\n    target_fpath = os.path.join(target_dir, os.path.basename(src_fpath))\n    with open(src_fpath, 'r') as fh:\n        with open(target_fpath, 'w') as fh_out:\n            for line in fh:\n                # Crudely remove the __tags__ line.\n                if line.startswith('__tags__ = '):\n                    continue\n                fh_out.write(line)\n\n\ndef generate_dir_rst(src_dir, target_dir, gallery_conf, seen_backrefs):\n    \"\"\"Generate the gallery reStructuredText for an example directory\"\"\"\n\n    fhindex = GALLERY_HEADER\n\n    if not os.path.exists(target_dir):\n        os.makedirs(target_dir)\n    tagged_examples = example_groups(src_dir)\n    tagged_examples = order_examples(tagged_examples)\n\n    computation_times = []\n    build_target_dir = os.path.relpath(target_dir, gallery_conf['src_dir'])\n\n    seen = set()\n    tmp_dir = tempfile.mkdtemp()\n\n    for tag, examples in tagged_examples.items():\n        sorted_listdir = examples\n\n        entries_text = []\n        iterator = sphinx_compatibility.status_iterator(\n            sorted_listdir,\n            'Generating gallery for %s ' % tag,\n            length=len(sorted_listdir))\n        for fname in iterator:\n            write_example(os.path.join(src_dir, fname), tmp_dir)\n            amount_of_code, time_elapsed = generate_file_rst(\n                fname, target_dir, tmp_dir, gallery_conf)\n\n            if fname not in seen:\n                seen.add(fname)\n                computation_times.append((time_elapsed, fname))\n\n            new_fname = os.path.join(src_dir, fname)\n            intro = extract_intro(new_fname)\n            this_entry = _thumbnail_div(build_target_dir, fname, intro) + textwrap.dedent(\"\"\"\n\n                .. toctree::\n                   :hidden:\n\n                   /%s\n\n                   \"\"\") % os.path.join(build_target_dir, fname[:-3]).replace(os.sep, '/')  # noqa: E501\n\n            entries_text.append((amount_of_code, this_entry))\n\n            if gallery_conf['backreferences_dir']:\n                write_backreferences(seen_backrefs, gallery_conf,\n                                     target_dir, fname, intro)\n\n        # sort to have the smallest entries in the beginning\n        entries_text.sort()\n\n        fhindex += textwrap.dedent(\"\"\"\n\n        {tag}\n        {tag_underline}\n\n        .. container:: gallery_images\n\n        \"\"\".format(tag=tag, tag_underline='-' * len(tag)))\n\n        for _, entry_text in entries_text:\n            fhindex += '\\n    '.join(entry_text.split('\\n'))\n\n        # clear at the end of the section\n        fhindex += \"\"\".. raw:: html\\n\n        <div style='clear:both'></div>\\n\\n\"\"\"\n\n    # Tidy up the temp directory\n    shutil.rmtree(tmp_dir)\n\n    return fhindex, computation_times\n\n\n# Monkey-patch sphinx_gallery to handle cartopy's example format.\nsphinx_gallery.gen_rst.generate_dir_rst = generate_dir_rst\nsphinx_gallery.gen_gallery.generate_dir_rst = generate_dir_rst\n\n\ndef setup(app):\n    pass\n", "path": "docs/source/sphinxext/pre_sphinx_gallery.py"}]}