We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Version switching on the Sphinx API docs
We now have:

- https://biopython.org/docs/1.74/api/
- https://biopython.org/docs/1.75/api/
- https://biopython.org/docs/1.76/api/
- https://biopython.org/docs/1.77/api/
- ...
- https://biopython.org/docs/dev/api/

The webpage source for these exists here:

https://github.com/biopython/docs

The Sphinx configuration to build them is here:

https://github.com/biopython/biopython/tree/master/Doc/api

Can we add some JavaScript or otherwise like on ReadTheDocs to make it easy to toggle between version from within the browse?

This likely means some changes to our Sphinx configuration (e.g. the common templates), and therefore would require backporting to regenerate the old pages - which would be OK.

This could also resolve #2904.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `Doc/api/conf.py`
Content:
```
1 #!/usr/bin/env python3
2 """Biopython Sphinx documentation build configuration file.
3 
4 After generating ``*.rst`` files from the source code, this
5 file controls running ``sphinx-build`` to turn these into
6 human readable documentation.
7 """
8 
9 import os
10 import shutil
11 import sys
12 import tempfile
13 
14 from sphinx.ext import autodoc
15 
16 from Bio import __version__, Application
17 
18 # -- General configuration ------------------------------------------------
19 
20 # If your documentation needs a minimal Sphinx version, state it here.
21 #
22 # needs_sphinx = '1.0'
23 needs_sphinx = "1.8"
24 
25 # Add any Sphinx extension module names here, as strings. They can be
26 # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
27 # ones.
28 extensions = [
29     "sphinx.ext.autodoc",
30     "sphinx.ext.todo",
31     # Don't want to include source code in the API docs
32     # 'sphinx.ext.viewcode',
33     "sphinx.ext.autosummary",
34     "numpydoc",
35 ]
36 
37 # Add any paths that contain templates here, relative to this directory.
38 templates_path = ["_templates"]
39 
40 # The suffix(es) of source filenames.
41 # You can specify multiple suffix as a list of string:
42 #
43 # source_suffix = ['.rst', '.md']
44 source_suffix = ".rst"
45 
46 # The master toctree document.
47 master_doc = "index"
48 
49 # General information about the project.
50 project = "Biopython"
51 copyright = "1999-2020, The Biopython Contributors"
52 author = "The Biopython Contributors"
53 document = "Biopython API Documentation"
54 
55 # The version info for the project you're documenting, acts as replacement for
56 # |version| and |release|, also used in various other places throughout the
57 # built documents.
58 #
59 # The short X.Y version.
60 version = __version__  # TODO: Shorten this
61 # The full version, including alpha/beta/rc tags.
62 release = __version__
63 
64 # The language for content autogenerated by Sphinx. Refer to documentation
65 # for a list of supported languages.
66 #
67 # This is also used if you do content translation via gettext catalogs.
68 # Usually you set "language" from the command line for these cases.
69 language = "en"
70 
71 # List of patterns, relative to source directory, that match files and
72 # directories to ignore when looking for source files.
73 # This patterns also effect to html_static_path and html_extra_path
74 exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
75 
76 # The name of the Pygments (syntax highlighting) style to use.
77 pygments_style = "sphinx"
78 
79 # If true, `todo` and `todoList` produce output, else they produce nothing.
80 todo_include_todos = True
81 
82 # -- Options for autodoc --------------------------------------------------
83 
84 # This requires Sphinx 1.8 or later:
85 autodoc_default_options = {
86     "members": None,
87     "undoc-members": None,
88     "special-members": None,
89     "show-inheritance": None,
90     "member-order": "bysource",
91     "exclude-members": "__dict__,__weakref__,__module__",
92 }
93 
94 # To avoid import errors.
95 autodoc_mock_imports = ["MySQLdb", "Bio.Restriction.Restriction", "Bio.Alphabet"]
96 
97 # -- Options for HTML output ----------------------------------------------
98 
99 # Sphinx default was html_theme = "alabaster"
100 html_theme = "sphinx_rtd_theme"
101 
102 # Sphinx Read The Docs theme settings, see
103 # https://sphinx-rtd-theme.readthedocs.io/en/latest/configuring.html
104 html_theme_options = {
105     "prev_next_buttons_location": "both",
106     # Same a Hyde theme sidebar on biopython.org:
107     "style_nav_header_background": "#10100F",
108     # Since we have the Biopython logo via html_logo,
109     "logo_only": True,
110 }
111 
112 # Based on:
113 # https://github.com/readthedocs/sphinx_rtd_theme/issues/231#issuecomment-126447493
114 html_context = {
115     "display_github": True,  # Add 'Edit on Github' link instead of 'View page source'
116     "github_user": "biopython",
117     "github_repo": "biopython",
118     "github_version": "master",
119     "conf_py_path": "/Doc/api/",
120     # "source_suffix": source_suffix,
121 }
122 
123 html_logo = "../images/biopython_logo.svg"
124 
125 # The RST source is transient, don't need/want to include it
126 html_show_sourcelink = False
127 html_copy_source = False
128 
129 # Add any paths that contain custom static files (such as style sheets) here,
130 # relative to this directory. They are copied after the builtin static files,
131 # so a file named "default.css" will overwrite the builtin "default.css".
132 html_static_path = ["_static"]
133 
134 # Custom sidebar templates, must be a dictionary that maps document names
135 # to template names.
136 #
137 # This is required for the alabaster theme
138 # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
139 html_sidebars = {
140     "**": [
141         "about.html",
142         "navigation.html",
143         "relations.html",  # needs 'show_related': True theme option to display
144         "searchbox.html",
145         "donate.html",
146     ]
147 }
148 
149 
150 # -- Options for HTMLHelp output ------------------------------------------
151 
152 # Output file base name for HTML help builder.
153 htmlhelp_basename = "Biopython_doc"
154 
155 
156 # -- Options for LaTeX output ---------------------------------------------
157 
158 latex_elements = {
159     # The paper size ('letterpaper' or 'a4paper').
160     #
161     # 'papersize': 'letterpaper',
162     # The font size ('10pt', '11pt' or '12pt').
163     #
164     # 'pointsize': '10pt',
165     # Additional stuff for the LaTeX preamble.
166     #
167     # 'preamble': '',
168     # Latex figure (float) alignment
169     #
170     # 'figure_align': 'htbp',
171 }
172 
173 # Grouping the document tree into LaTeX files. List of tuples
174 # (source start file, target name, title,
175 #  author, documentclass [howto, manual, or own class]).
176 latex_documents = [(master_doc, "Biopython_API.tex", document, author, "manual")]
177 
178 
179 # -- Options for manual page output ---------------------------------------
180 
181 # One entry per manual page. List of tuples
182 # (source start file, name, description, authors, manual section).
183 man_pages = [(master_doc, "biopython", document, [author], 1)]
184 
185 
186 # -- Options for Texinfo output -------------------------------------------
187 
188 # Grouping the document tree into Texinfo files. List of tuples
189 # (source start file, target name, title, author,
190 #  dir menu entry, description, category)
191 texinfo_documents = [
192     (
193         master_doc,
194         "Biopython",
195         document,
196         author,
197         "Biopython",
198         "Collection of modules for dealing with biological data in Python.",
199         "Miscellaneous",
200     )
201 ]
202 
203 
204 # -- Options for Epub output ----------------------------------------------
205 
206 # Bibliographic Dublin Core info.
207 epub_title = document  # project
208 epub_author = author
209 epub_publisher = author
210 epub_copyright = copyright
211 
212 # The unique identifier of the text. This can be a ISBN number
213 # or the project homepage.
214 #
215 # epub_identifier = ''
216 
217 # A unique identification for the text.
218 #
219 # epub_uid = ''
220 
221 # A list of files that should not be packed into the epub file.
222 epub_exclude_files = ["search.html"]
223 
224 # -- Options for numpydoc -------------------------------------------------
225 
226 numpydoc_class_members_toctree = False
227 # Prevents the attributes and methods from being shown twice
228 numpydoc_show_class_members = False
229 
230 # -- Magic to run sphinx-apidoc automatically -----------------------------
231 
232 # See https://github.com/rtfd/readthedocs.org/issues/1139
233 # on which this is based.
234 
235 
236 def insert_github_link(filename):
237     """Insert file specific :github_url: metadata for theme breadcrumbs."""
238     assert "/" not in filename and filename.endswith(".rst")
239     with open(filename) as handle:
240         text = handle.read()
241     if ":github_url:" in text:
242         return
243 
244     python = filename[:-4].replace(".", "/") + "/__init__.py"
245     if not os.path.isfile(os.path.join("../../", python)):
246         python = filename[:-4].replace(".", "/") + ".py"
247     if not os.path.isfile(os.path.join("../../", python)):
248         sys.stderr.write(
249             "WARNING: Could not map %s to a Python file, e.g. %s\n" % (filename, python)
250         )
251         return
252 
253     text = ":github_url: https://github.com/%s/%s/blob/%s/%s\n\n%s" % (
254         html_context["github_user"],
255         html_context["github_repo"],
256         html_context["github_version"],
257         python,
258         text,
259     )
260     with open(filename, "w") as handle:
261         handle.write(text)
262 
263 
264 def run_apidoc(_):
265     """Call sphinx-apidoc on Bio and BioSQL modules."""
266     from sphinx.ext.apidoc import main as apidoc_main
267 
268     cur_dir = os.path.abspath(os.path.dirname(__file__))
269     # Can't see a better way than running apidoc twice, for Bio & BioSQL
270     # We don't care about the index.rst / conf.py (we have our own)
271     # or the Makefile / make.bat (effectively same) clashing,
272     # $ sphinx-apidoc -e -F -o /tmp/api/BioSQL BioSQL
273     # $ sphinx-apidoc -e -F -o /tmp/api/Bio Bio
274     tmp_path = tempfile.mkdtemp()
275     apidoc_main(["-e", "-F", "-o", tmp_path, "../../BioSQL"])
276     apidoc_main(["-e", "-F", "-o", tmp_path, "../../Bio"])
277     os.remove(os.path.join(tmp_path, "index.rst"))  # Using our own
278     for filename in os.listdir(tmp_path):
279         if filename.endswith(".rst"):
280             shutil.move(
281                 os.path.join(tmp_path, filename), os.path.join(cur_dir, filename)
282             )
283     shutil.rmtree(tmp_path)
284 
285     for f in os.listdir(cur_dir):
286         if f.startswith("Bio") and f.endswith(".rst"):
287             insert_github_link(f)
288 
289 
290 class BioPythonAPI(autodoc.ClassDocumenter):
291     """Custom Class Documenter for AbstractCommandline classes."""
292 
293     def import_object(self):
294         """Import the class."""
295         ret = super().import_object()
296 
297         if not issubclass(self.object, Application.AbstractCommandline):
298             return ret
299 
300         try:
301             # If the object is an AbstractCommandline we instantiate it.
302             self.object()
303         except TypeError:
304             # Throws if the object is the base AbstractCommandline class
305             pass
306         return ret
307 
308 
309 def setup(app):
310     """Over-ride Sphinx setup to trigger sphinx-apidoc."""
311     app.connect("builder-inited", run_apidoc)
312 
313     def add_documenter(app, env, docnames):
314         app.add_autodocumenter(BioPythonAPI, True)
315 
316     # Over-ride autodoc documenter
317     app.connect("env-before-read-docs", add_documenter)
318
```
--- 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/Doc/api/conf.py b/Doc/api/conf.py
--- a/Doc/api/conf.py
+++ b/Doc/api/conf.py
@@ -61,6 +61,25 @@
 # The full version, including alpha/beta/rc tags.
 release = __version__
 
+# Versions for versions.html:
+# (this will break if we have version gaps)
+try:
+    main_version, minor_version, _ = version.split(".")  # e.g. 1.79.dev0
+    dev_version = True
+except ValueError:
+    main_version, minor_version = version.split(".")  # e.g. 1.78
+    dev_version = False
+prev_minor_version = int(minor_version) - (2 if dev_version else 1)
+previous_version = f"{main_version}.{prev_minor_version}"
+versions = [
+    ("Previous", f"../../{previous_version}/api/"),
+    ("Latest", "../../latest/api/"),
+    ("Develop", "../../dev/api/"),
+]
+
+if version < "1.75":  # 1.74 is the earliest Sphinx-generated api documentation
+    del versions[0]
+
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.
 #
@@ -92,7 +111,9 @@
 }
 
 # To avoid import errors.
-autodoc_mock_imports = ["MySQLdb", "Bio.Restriction.Restriction", "Bio.Alphabet"]
+autodoc_mock_imports = ["MySQLdb", "Bio.Restriction.Restriction"]
+if version > "1.77":
+    autodoc_mock_imports.append("Bio.Alphabet")
 
 # -- Options for HTML output ----------------------------------------------
 
@@ -118,9 +139,16 @@
     "github_version": "master",
     "conf_py_path": "/Doc/api/",
     # "source_suffix": source_suffix,
+    "theme_display_version": False,
+    # Biopython-specific values for version-footer (versions.html):
+    "display_version_footer": True,
+    "current_version": version,
+    "versions": versions,
+    "project_home_url": "https://biopython.org",
+    "project_github_url": "https://github.com/biopython/biopython",
 }
 
-html_logo = "../images/biopython_logo.svg"
+html_logo = "../images/biopython_logo_white.png"
 
 # The RST source is transient, don't need/want to include it
 html_show_sourcelink = False
@@ -131,20 +159,21 @@
 # so a file named "default.css" will overwrite the builtin "default.css".
 html_static_path = ["_static"]
 
+# The following is not applicable to the Read-the-docs theme:
 # Custom sidebar templates, must be a dictionary that maps document names
 # to template names.
 #
 # This is required for the alabaster theme
 # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
-html_sidebars = {
-    "**": [
-        "about.html",
-        "navigation.html",
-        "relations.html",  # needs 'show_related': True theme option to display
-        "searchbox.html",
-        "donate.html",
-    ]
-}
+# html_sidebars = {
+#     "**": [
+#         "about.html",
+#         "navigation.html",
+#         "relations.html",  # needs 'show_related': True theme option to display
+#         "searchbox.html",
+#         "donate.html",
+#     ]
+# }
 
 
 # -- Options for HTMLHelp output ------------------------------------------
@@ -310,6 +339,8 @@
     """Over-ride Sphinx setup to trigger sphinx-apidoc."""
     app.connect("builder-inited", run_apidoc)
 
+    app.add_css_file("biopython.css")
+
     def add_documenter(app, env, docnames):
         app.add_autodocumenter(BioPythonAPI, True)

{"golden_diff": "diff --git a/Doc/api/conf.py b/Doc/api/conf.py\n--- a/Doc/api/conf.py\n+++ b/Doc/api/conf.py\n@@ -61,6 +61,25 @@\n # The full version, including alpha/beta/rc tags.\n release = __version__\n \n+# Versions for versions.html:\n+# (this will break if we have version gaps)\n+try:\n+    main_version, minor_version, _ = version.split(\".\")  # e.g. 1.79.dev0\n+    dev_version = True\n+except ValueError:\n+    main_version, minor_version = version.split(\".\")  # e.g. 1.78\n+    dev_version = False\n+prev_minor_version = int(minor_version) - (2 if dev_version else 1)\n+previous_version = f\"{main_version}.{prev_minor_version}\"\n+versions = [\n+    (\"Previous\", f\"../../{previous_version}/api/\"),\n+    (\"Latest\", \"../../latest/api/\"),\n+    (\"Develop\", \"../../dev/api/\"),\n+]\n+\n+if version < \"1.75\":  # 1.74 is the earliest Sphinx-generated api documentation\n+    del versions[0]\n+\n # The language for content autogenerated by Sphinx. Refer to documentation\n # for a list of supported languages.\n #\n@@ -92,7 +111,9 @@\n }\n \n # To avoid import errors.\n-autodoc_mock_imports = [\"MySQLdb\", \"Bio.Restriction.Restriction\", \"Bio.Alphabet\"]\n+autodoc_mock_imports = [\"MySQLdb\", \"Bio.Restriction.Restriction\"]\n+if version > \"1.77\":\n+    autodoc_mock_imports.append(\"Bio.Alphabet\")\n \n # -- Options for HTML output ----------------------------------------------\n \n@@ -118,9 +139,16 @@\n     \"github_version\": \"master\",\n     \"conf_py_path\": \"/Doc/api/\",\n     # \"source_suffix\": source_suffix,\n+    \"theme_display_version\": False,\n+    # Biopython-specific values for version-footer (versions.html):\n+    \"display_version_footer\": True,\n+    \"current_version\": version,\n+    \"versions\": versions,\n+    \"project_home_url\": \"https://biopython.org\",\n+    \"project_github_url\": \"https://github.com/biopython/biopython\",\n }\n \n-html_logo = \"../images/biopython_logo.svg\"\n+html_logo = \"../images/biopython_logo_white.png\"\n \n # The RST source is transient, don't need/want to include it\n html_show_sourcelink = False\n@@ -131,20 +159,21 @@\n # so a file named \"default.css\" will overwrite the builtin \"default.css\".\n html_static_path = [\"_static\"]\n \n+# The following is not applicable to the Read-the-docs theme:\n # Custom sidebar templates, must be a dictionary that maps document names\n # to template names.\n #\n # This is required for the alabaster theme\n # refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars\n-html_sidebars = {\n-    \"**\": [\n-        \"about.html\",\n-        \"navigation.html\",\n-        \"relations.html\",  # needs 'show_related': True theme option to display\n-        \"searchbox.html\",\n-        \"donate.html\",\n-    ]\n-}\n+# html_sidebars = {\n+#     \"**\": [\n+#         \"about.html\",\n+#         \"navigation.html\",\n+#         \"relations.html\",  # needs 'show_related': True theme option to display\n+#         \"searchbox.html\",\n+#         \"donate.html\",\n+#     ]\n+# }\n \n \n # -- Options for HTMLHelp output ------------------------------------------\n@@ -310,6 +339,8 @@\n     \"\"\"Over-ride Sphinx setup to trigger sphinx-apidoc.\"\"\"\n     app.connect(\"builder-inited\", run_apidoc)\n \n+    app.add_css_file(\"biopython.css\")\n+\n     def add_documenter(app, env, docnames):\n         app.add_autodocumenter(BioPythonAPI, True)\n", "issue": "Version switching on the Sphinx API docs\nWe now have:\r\n\r\n- https://biopython.org/docs/1.74/api/\r\n- https://biopython.org/docs/1.75/api/\r\n- https://biopython.org/docs/1.76/api/\r\n- https://biopython.org/docs/1.77/api/\r\n- ...\r\n- https://biopython.org/docs/dev/api/\r\n\r\nThe webpage source for these exists here:\r\n\r\nhttps://github.com/biopython/docs\r\n\r\nThe Sphinx configuration to build them is here:\r\n\r\nhttps://github.com/biopython/biopython/tree/master/Doc/api\r\n\r\nCan we add some JavaScript or otherwise like on ReadTheDocs to make it easy to toggle between version from within the browse?\r\n\r\nThis likely means some changes to our Sphinx configuration (e.g. the common templates), and therefore would require backporting to regenerate the old pages - which would be OK.\r\n\r\nThis could also resolve #2904.\n", "before_files": [{"content": "#!/usr/bin/env python3\n\"\"\"Biopython Sphinx documentation build configuration file.\n\nAfter generating ``*.rst`` files from the source code, this\nfile controls running ``sphinx-build`` to turn these into\nhuman readable documentation.\n\"\"\"\n\nimport os\nimport shutil\nimport sys\nimport tempfile\n\nfrom sphinx.ext import autodoc\n\nfrom Bio import __version__, Application\n\n# -- General configuration ------------------------------------------------\n\n# If your documentation needs a minimal Sphinx version, state it here.\n#\n# needs_sphinx = '1.0'\nneeds_sphinx = \"1.8\"\n\n# Add any Sphinx extension module names here, as strings. They can be\n# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom\n# ones.\nextensions = [\n    \"sphinx.ext.autodoc\",\n    \"sphinx.ext.todo\",\n    # Don't want to include source code in the API docs\n    # 'sphinx.ext.viewcode',\n    \"sphinx.ext.autosummary\",\n    \"numpydoc\",\n]\n\n# Add any paths that contain templates here, relative to this directory.\ntemplates_path = [\"_templates\"]\n\n# The suffix(es) of source filenames.\n# You can specify multiple suffix as a list of string:\n#\n# source_suffix = ['.rst', '.md']\nsource_suffix = \".rst\"\n\n# The master toctree document.\nmaster_doc = \"index\"\n\n# General information about the project.\nproject = \"Biopython\"\ncopyright = \"1999-2020, The Biopython Contributors\"\nauthor = \"The Biopython Contributors\"\ndocument = \"Biopython API Documentation\"\n\n# The version info for the project you're documenting, acts as replacement for\n# |version| and |release|, also used in various other places throughout the\n# built documents.\n#\n# The short X.Y version.\nversion = __version__  # TODO: Shorten this\n# The full version, including alpha/beta/rc tags.\nrelease = __version__\n\n# The language for content autogenerated by Sphinx. Refer to documentation\n# for a list of supported languages.\n#\n# This is also used if you do content translation via gettext catalogs.\n# Usually you set \"language\" from the command line for these cases.\nlanguage = \"en\"\n\n# List of patterns, relative to source directory, that match files and\n# directories to ignore when looking for source files.\n# This patterns also effect to html_static_path and html_extra_path\nexclude_patterns = [\"_build\", \"Thumbs.db\", \".DS_Store\"]\n\n# The name of the Pygments (syntax highlighting) style to use.\npygments_style = \"sphinx\"\n\n# If true, `todo` and `todoList` produce output, else they produce nothing.\ntodo_include_todos = True\n\n# -- Options for autodoc --------------------------------------------------\n\n# This requires Sphinx 1.8 or later:\nautodoc_default_options = {\n    \"members\": None,\n    \"undoc-members\": None,\n    \"special-members\": None,\n    \"show-inheritance\": None,\n    \"member-order\": \"bysource\",\n    \"exclude-members\": \"__dict__,__weakref__,__module__\",\n}\n\n# To avoid import errors.\nautodoc_mock_imports = [\"MySQLdb\", \"Bio.Restriction.Restriction\", \"Bio.Alphabet\"]\n\n# -- Options for HTML output ----------------------------------------------\n\n# Sphinx default was html_theme = \"alabaster\"\nhtml_theme = \"sphinx_rtd_theme\"\n\n# Sphinx Read The Docs theme settings, see\n# https://sphinx-rtd-theme.readthedocs.io/en/latest/configuring.html\nhtml_theme_options = {\n    \"prev_next_buttons_location\": \"both\",\n    # Same a Hyde theme sidebar on biopython.org:\n    \"style_nav_header_background\": \"#10100F\",\n    # Since we have the Biopython logo via html_logo,\n    \"logo_only\": True,\n}\n\n# Based on:\n# https://github.com/readthedocs/sphinx_rtd_theme/issues/231#issuecomment-126447493\nhtml_context = {\n    \"display_github\": True,  # Add 'Edit on Github' link instead of 'View page source'\n    \"github_user\": \"biopython\",\n    \"github_repo\": \"biopython\",\n    \"github_version\": \"master\",\n    \"conf_py_path\": \"/Doc/api/\",\n    # \"source_suffix\": source_suffix,\n}\n\nhtml_logo = \"../images/biopython_logo.svg\"\n\n# The RST source is transient, don't need/want to include it\nhtml_show_sourcelink = False\nhtml_copy_source = False\n\n# Add any paths that contain custom static files (such as style sheets) here,\n# relative to this directory. They are copied after the builtin static files,\n# so a file named \"default.css\" will overwrite the builtin \"default.css\".\nhtml_static_path = [\"_static\"]\n\n# Custom sidebar templates, must be a dictionary that maps document names\n# to template names.\n#\n# This is required for the alabaster theme\n# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars\nhtml_sidebars = {\n    \"**\": [\n        \"about.html\",\n        \"navigation.html\",\n        \"relations.html\",  # needs 'show_related': True theme option to display\n        \"searchbox.html\",\n        \"donate.html\",\n    ]\n}\n\n\n# -- Options for HTMLHelp output ------------------------------------------\n\n# Output file base name for HTML help builder.\nhtmlhelp_basename = \"Biopython_doc\"\n\n\n# -- Options for LaTeX output ---------------------------------------------\n\nlatex_elements = {\n    # The paper size ('letterpaper' or 'a4paper').\n    #\n    # 'papersize': 'letterpaper',\n    # The font size ('10pt', '11pt' or '12pt').\n    #\n    # 'pointsize': '10pt',\n    # Additional stuff for the LaTeX preamble.\n    #\n    # 'preamble': '',\n    # Latex figure (float) alignment\n    #\n    # 'figure_align': 'htbp',\n}\n\n# Grouping the document tree into LaTeX files. List of tuples\n# (source start file, target name, title,\n#  author, documentclass [howto, manual, or own class]).\nlatex_documents = [(master_doc, \"Biopython_API.tex\", document, author, \"manual\")]\n\n\n# -- Options for manual page output ---------------------------------------\n\n# One entry per manual page. List of tuples\n# (source start file, name, description, authors, manual section).\nman_pages = [(master_doc, \"biopython\", document, [author], 1)]\n\n\n# -- Options for Texinfo output -------------------------------------------\n\n# Grouping the document tree into Texinfo files. List of tuples\n# (source start file, target name, title, author,\n#  dir menu entry, description, category)\ntexinfo_documents = [\n    (\n        master_doc,\n        \"Biopython\",\n        document,\n        author,\n        \"Biopython\",\n        \"Collection of modules for dealing with biological data in Python.\",\n        \"Miscellaneous\",\n    )\n]\n\n\n# -- Options for Epub output ----------------------------------------------\n\n# Bibliographic Dublin Core info.\nepub_title = document  # project\nepub_author = author\nepub_publisher = author\nepub_copyright = copyright\n\n# The unique identifier of the text. This can be a ISBN number\n# or the project homepage.\n#\n# epub_identifier = ''\n\n# A unique identification for the text.\n#\n# epub_uid = ''\n\n# A list of files that should not be packed into the epub file.\nepub_exclude_files = [\"search.html\"]\n\n# -- Options for numpydoc -------------------------------------------------\n\nnumpydoc_class_members_toctree = False\n# Prevents the attributes and methods from being shown twice\nnumpydoc_show_class_members = False\n\n# -- Magic to run sphinx-apidoc automatically -----------------------------\n\n# See https://github.com/rtfd/readthedocs.org/issues/1139\n# on which this is based.\n\n\ndef insert_github_link(filename):\n    \"\"\"Insert file specific :github_url: metadata for theme breadcrumbs.\"\"\"\n    assert \"/\" not in filename and filename.endswith(\".rst\")\n    with open(filename) as handle:\n        text = handle.read()\n    if \":github_url:\" in text:\n        return\n\n    python = filename[:-4].replace(\".\", \"/\") + \"/__init__.py\"\n    if not os.path.isfile(os.path.join(\"../../\", python)):\n        python = filename[:-4].replace(\".\", \"/\") + \".py\"\n    if not os.path.isfile(os.path.join(\"../../\", python)):\n        sys.stderr.write(\n            \"WARNING: Could not map %s to a Python file, e.g. %s\\n\" % (filename, python)\n        )\n        return\n\n    text = \":github_url: https://github.com/%s/%s/blob/%s/%s\\n\\n%s\" % (\n        html_context[\"github_user\"],\n        html_context[\"github_repo\"],\n        html_context[\"github_version\"],\n        python,\n        text,\n    )\n    with open(filename, \"w\") as handle:\n        handle.write(text)\n\n\ndef run_apidoc(_):\n    \"\"\"Call sphinx-apidoc on Bio and BioSQL modules.\"\"\"\n    from sphinx.ext.apidoc import main as apidoc_main\n\n    cur_dir = os.path.abspath(os.path.dirname(__file__))\n    # Can't see a better way than running apidoc twice, for Bio & BioSQL\n    # We don't care about the index.rst / conf.py (we have our own)\n    # or the Makefile / make.bat (effectively same) clashing,\n    # $ sphinx-apidoc -e -F -o /tmp/api/BioSQL BioSQL\n    # $ sphinx-apidoc -e -F -o /tmp/api/Bio Bio\n    tmp_path = tempfile.mkdtemp()\n    apidoc_main([\"-e\", \"-F\", \"-o\", tmp_path, \"../../BioSQL\"])\n    apidoc_main([\"-e\", \"-F\", \"-o\", tmp_path, \"../../Bio\"])\n    os.remove(os.path.join(tmp_path, \"index.rst\"))  # Using our own\n    for filename in os.listdir(tmp_path):\n        if filename.endswith(\".rst\"):\n            shutil.move(\n                os.path.join(tmp_path, filename), os.path.join(cur_dir, filename)\n            )\n    shutil.rmtree(tmp_path)\n\n    for f in os.listdir(cur_dir):\n        if f.startswith(\"Bio\") and f.endswith(\".rst\"):\n            insert_github_link(f)\n\n\nclass BioPythonAPI(autodoc.ClassDocumenter):\n    \"\"\"Custom Class Documenter for AbstractCommandline classes.\"\"\"\n\n    def import_object(self):\n        \"\"\"Import the class.\"\"\"\n        ret = super().import_object()\n\n        if not issubclass(self.object, Application.AbstractCommandline):\n            return ret\n\n        try:\n            # If the object is an AbstractCommandline we instantiate it.\n            self.object()\n        except TypeError:\n            # Throws if the object is the base AbstractCommandline class\n            pass\n        return ret\n\n\ndef setup(app):\n    \"\"\"Over-ride Sphinx setup to trigger sphinx-apidoc.\"\"\"\n    app.connect(\"builder-inited\", run_apidoc)\n\n    def add_documenter(app, env, docnames):\n        app.add_autodocumenter(BioPythonAPI, True)\n\n    # Over-ride autodoc documenter\n    app.connect(\"env-before-read-docs\", add_documenter)\n", "path": "Doc/api/conf.py"}], "after_files": [{"content": "#!/usr/bin/env python3\n\"\"\"Biopython Sphinx documentation build configuration file.\n\nAfter generating ``*.rst`` files from the source code, this\nfile controls running ``sphinx-build`` to turn these into\nhuman readable documentation.\n\"\"\"\n\nimport os\nimport shutil\nimport sys\nimport tempfile\n\nfrom sphinx.ext import autodoc\n\nfrom Bio import __version__, Application\n\n# -- General configuration ------------------------------------------------\n\n# If your documentation needs a minimal Sphinx version, state it here.\n#\n# needs_sphinx = '1.0'\nneeds_sphinx = \"1.8\"\n\n# Add any Sphinx extension module names here, as strings. They can be\n# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom\n# ones.\nextensions = [\n    \"sphinx.ext.autodoc\",\n    \"sphinx.ext.todo\",\n    # Don't want to include source code in the API docs\n    # 'sphinx.ext.viewcode',\n    \"sphinx.ext.autosummary\",\n    \"numpydoc\",\n]\n\n# Add any paths that contain templates here, relative to this directory.\ntemplates_path = [\"_templates\"]\n\n# The suffix(es) of source filenames.\n# You can specify multiple suffix as a list of string:\n#\n# source_suffix = ['.rst', '.md']\nsource_suffix = \".rst\"\n\n# The master toctree document.\nmaster_doc = \"index\"\n\n# General information about the project.\nproject = \"Biopython\"\ncopyright = \"1999-2020, The Biopython Contributors\"\nauthor = \"The Biopython Contributors\"\ndocument = \"Biopython API Documentation\"\n\n# The version info for the project you're documenting, acts as replacement for\n# |version| and |release|, also used in various other places throughout the\n# built documents.\n#\n# The short X.Y version.\nversion = __version__  # TODO: Shorten this\n# The full version, including alpha/beta/rc tags.\nrelease = __version__\n\n# Versions for versions.html:\n# (this will break if we have version gaps)\ntry:\n    main_version, minor_version, _ = version.split(\".\")  # e.g. 1.79.dev0\n    dev_version = True\nexcept ValueError:\n    main_version, minor_version = version.split(\".\")  # e.g. 1.78\n    dev_version = False\nprev_minor_version = int(minor_version) - (2 if dev_version else 1)\nprevious_version = f\"{main_version}.{prev_minor_version}\"\nversions = [\n    (\"Previous\", f\"../../{previous_version}/api/\"),\n    (\"Latest\", \"../../latest/api/\"),\n    (\"Develop\", \"../../dev/api/\"),\n]\n\nif version < \"1.75\":  # 1.74 is the earliest Sphinx-generated api documentation\n    del versions[0]\n\n# The language for content autogenerated by Sphinx. Refer to documentation\n# for a list of supported languages.\n#\n# This is also used if you do content translation via gettext catalogs.\n# Usually you set \"language\" from the command line for these cases.\nlanguage = \"en\"\n\n# List of patterns, relative to source directory, that match files and\n# directories to ignore when looking for source files.\n# This patterns also effect to html_static_path and html_extra_path\nexclude_patterns = [\"_build\", \"Thumbs.db\", \".DS_Store\"]\n\n# The name of the Pygments (syntax highlighting) style to use.\npygments_style = \"sphinx\"\n\n# If true, `todo` and `todoList` produce output, else they produce nothing.\ntodo_include_todos = True\n\n# -- Options for autodoc --------------------------------------------------\n\n# This requires Sphinx 1.8 or later:\nautodoc_default_options = {\n    \"members\": None,\n    \"undoc-members\": None,\n    \"special-members\": None,\n    \"show-inheritance\": None,\n    \"member-order\": \"bysource\",\n    \"exclude-members\": \"__dict__,__weakref__,__module__\",\n}\n\n# To avoid import errors.\nautodoc_mock_imports = [\"MySQLdb\", \"Bio.Restriction.Restriction\"]\nif version > \"1.77\":\n    autodoc_mock_imports.append(\"Bio.Alphabet\")\n\n# -- Options for HTML output ----------------------------------------------\n\n# Sphinx default was html_theme = \"alabaster\"\nhtml_theme = \"sphinx_rtd_theme\"\n\n# Sphinx Read The Docs theme settings, see\n# https://sphinx-rtd-theme.readthedocs.io/en/latest/configuring.html\nhtml_theme_options = {\n    \"prev_next_buttons_location\": \"both\",\n    # Same a Hyde theme sidebar on biopython.org:\n    \"style_nav_header_background\": \"#10100F\",\n    # Since we have the Biopython logo via html_logo,\n    \"logo_only\": True,\n}\n\n# Based on:\n# https://github.com/readthedocs/sphinx_rtd_theme/issues/231#issuecomment-126447493\nhtml_context = {\n    \"display_github\": True,  # Add 'Edit on Github' link instead of 'View page source'\n    \"github_user\": \"biopython\",\n    \"github_repo\": \"biopython\",\n    \"github_version\": \"master\",\n    \"conf_py_path\": \"/Doc/api/\",\n    # \"source_suffix\": source_suffix,\n    \"theme_display_version\": False,\n    # Biopython-specific values for version-footer (versions.html):\n    \"display_version_footer\": True,\n    \"current_version\": version,\n    \"versions\": versions,\n    \"project_home_url\": \"https://biopython.org\",\n    \"project_github_url\": \"https://github.com/biopython/biopython\",\n}\n\nhtml_logo = \"../images/biopython_logo_white.png\"\n\n# The RST source is transient, don't need/want to include it\nhtml_show_sourcelink = False\nhtml_copy_source = False\n\n# Add any paths that contain custom static files (such as style sheets) here,\n# relative to this directory. They are copied after the builtin static files,\n# so a file named \"default.css\" will overwrite the builtin \"default.css\".\nhtml_static_path = [\"_static\"]\n\n# The following is not applicable to the Read-the-docs theme:\n# Custom sidebar templates, must be a dictionary that maps document names\n# to template names.\n#\n# This is required for the alabaster theme\n# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars\n# html_sidebars = {\n#     \"**\": [\n#         \"about.html\",\n#         \"navigation.html\",\n#         \"relations.html\",  # needs 'show_related': True theme option to display\n#         \"searchbox.html\",\n#         \"donate.html\",\n#     ]\n# }\n\n\n# -- Options for HTMLHelp output ------------------------------------------\n\n# Output file base name for HTML help builder.\nhtmlhelp_basename = \"Biopython_doc\"\n\n\n# -- Options for LaTeX output ---------------------------------------------\n\nlatex_elements = {\n    # The paper size ('letterpaper' or 'a4paper').\n    #\n    # 'papersize': 'letterpaper',\n    # The font size ('10pt', '11pt' or '12pt').\n    #\n    # 'pointsize': '10pt',\n    # Additional stuff for the LaTeX preamble.\n    #\n    # 'preamble': '',\n    # Latex figure (float) alignment\n    #\n    # 'figure_align': 'htbp',\n}\n\n# Grouping the document tree into LaTeX files. List of tuples\n# (source start file, target name, title,\n#  author, documentclass [howto, manual, or own class]).\nlatex_documents = [(master_doc, \"Biopython_API.tex\", document, author, \"manual\")]\n\n\n# -- Options for manual page output ---------------------------------------\n\n# One entry per manual page. List of tuples\n# (source start file, name, description, authors, manual section).\nman_pages = [(master_doc, \"biopython\", document, [author], 1)]\n\n\n# -- Options for Texinfo output -------------------------------------------\n\n# Grouping the document tree into Texinfo files. List of tuples\n# (source start file, target name, title, author,\n#  dir menu entry, description, category)\ntexinfo_documents = [\n    (\n        master_doc,\n        \"Biopython\",\n        document,\n        author,\n        \"Biopython\",\n        \"Collection of modules for dealing with biological data in Python.\",\n        \"Miscellaneous\",\n    )\n]\n\n\n# -- Options for Epub output ----------------------------------------------\n\n# Bibliographic Dublin Core info.\nepub_title = document  # project\nepub_author = author\nepub_publisher = author\nepub_copyright = copyright\n\n# The unique identifier of the text. This can be a ISBN number\n# or the project homepage.\n#\n# epub_identifier = ''\n\n# A unique identification for the text.\n#\n# epub_uid = ''\n\n# A list of files that should not be packed into the epub file.\nepub_exclude_files = [\"search.html\"]\n\n# -- Options for numpydoc -------------------------------------------------\n\nnumpydoc_class_members_toctree = False\n# Prevents the attributes and methods from being shown twice\nnumpydoc_show_class_members = False\n\n# -- Magic to run sphinx-apidoc automatically -----------------------------\n\n# See https://github.com/rtfd/readthedocs.org/issues/1139\n# on which this is based.\n\n\ndef insert_github_link(filename):\n    \"\"\"Insert file specific :github_url: metadata for theme breadcrumbs.\"\"\"\n    assert \"/\" not in filename and filename.endswith(\".rst\")\n    with open(filename) as handle:\n        text = handle.read()\n    if \":github_url:\" in text:\n        return\n\n    python = filename[:-4].replace(\".\", \"/\") + \"/__init__.py\"\n    if not os.path.isfile(os.path.join(\"../../\", python)):\n        python = filename[:-4].replace(\".\", \"/\") + \".py\"\n    if not os.path.isfile(os.path.join(\"../../\", python)):\n        sys.stderr.write(\n            \"WARNING: Could not map %s to a Python file, e.g. %s\\n\" % (filename, python)\n        )\n        return\n\n    text = \":github_url: https://github.com/%s/%s/blob/%s/%s\\n\\n%s\" % (\n        html_context[\"github_user\"],\n        html_context[\"github_repo\"],\n        html_context[\"github_version\"],\n        python,\n        text,\n    )\n    with open(filename, \"w\") as handle:\n        handle.write(text)\n\n\ndef run_apidoc(_):\n    \"\"\"Call sphinx-apidoc on Bio and BioSQL modules.\"\"\"\n    from sphinx.ext.apidoc import main as apidoc_main\n\n    cur_dir = os.path.abspath(os.path.dirname(__file__))\n    # Can't see a better way than running apidoc twice, for Bio & BioSQL\n    # We don't care about the index.rst / conf.py (we have our own)\n    # or the Makefile / make.bat (effectively same) clashing,\n    # $ sphinx-apidoc -e -F -o /tmp/api/BioSQL BioSQL\n    # $ sphinx-apidoc -e -F -o /tmp/api/Bio Bio\n    tmp_path = tempfile.mkdtemp()\n    apidoc_main([\"-e\", \"-F\", \"-o\", tmp_path, \"../../BioSQL\"])\n    apidoc_main([\"-e\", \"-F\", \"-o\", tmp_path, \"../../Bio\"])\n    os.remove(os.path.join(tmp_path, \"index.rst\"))  # Using our own\n    for filename in os.listdir(tmp_path):\n        if filename.endswith(\".rst\"):\n            shutil.move(\n                os.path.join(tmp_path, filename), os.path.join(cur_dir, filename)\n            )\n    shutil.rmtree(tmp_path)\n\n    for f in os.listdir(cur_dir):\n        if f.startswith(\"Bio\") and f.endswith(\".rst\"):\n            insert_github_link(f)\n\n\nclass BioPythonAPI(autodoc.ClassDocumenter):\n    \"\"\"Custom Class Documenter for AbstractCommandline classes.\"\"\"\n\n    def import_object(self):\n        \"\"\"Import the class.\"\"\"\n        ret = super().import_object()\n\n        if not issubclass(self.object, Application.AbstractCommandline):\n            return ret\n\n        try:\n            # If the object is an AbstractCommandline we instantiate it.\n            self.object()\n        except TypeError:\n            # Throws if the object is the base AbstractCommandline class\n            pass\n        return ret\n\n\ndef setup(app):\n    \"\"\"Over-ride Sphinx setup to trigger sphinx-apidoc.\"\"\"\n    app.connect(\"builder-inited\", run_apidoc)\n\n    app.add_css_file(\"biopython.css\")\n\n    def add_documenter(app, env, docnames):\n        app.add_autodocumenter(BioPythonAPI, True)\n\n    # Over-ride autodoc documenter\n    app.connect(\"env-before-read-docs\", add_documenter)\n", "path": "Doc/api/conf.py"}]}