From 80e1e2df0c64537752726c1c43104246432c4273 Mon Sep 17 00:00:00 2001
From: Peter Cock
Date: Mon, 20 Sep 2021 10:56:47 +0100
Subject: [PATCH] Exclude rather than mock problematic modules for API docs
(#3731)
Exclude rather than mock Bio.Alphabet etc as per suggestion here:
https://github.com/sphinx-doc/sphinx/issues/9631
Should be OK with latest Sphinx now (on both GitHub actions and CircleCI)
---
.circleci/requirements-sphinx.txt | 2 +-
Doc/api/conf.py | 18 ++++++++++++++----
ci-dependencies.txt | 2 +-
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/.circleci/requirements-sphinx.txt b/.circleci/requirements-sphinx.txt
index 58aac6fbf64..bf9104c0089 100644
--- a/.circleci/requirements-sphinx.txt
+++ b/.circleci/requirements-sphinx.txt
@@ -4,7 +4,7 @@ numpy
rdflib
reportlab
scipy
-sphinx==4.1.2
+sphinx>=4.2.0
numpydoc==1.0.0
pygments
sphinx_rtd_theme
diff --git a/Doc/api/conf.py b/Doc/api/conf.py
index af866d1c061..54ae6d96b85 100644
--- a/Doc/api/conf.py
+++ b/Doc/api/conf.py
@@ -114,9 +114,7 @@
autodoc_preserve_defaults = True
# To avoid import errors.
-autodoc_mock_imports = ["MySQLdb", "Bio.Restriction.Restriction"]
-if version > "1.77":
- autodoc_mock_imports.append("Bio.Alphabet")
+autodoc_mock_imports = ["MySQLdb"]
# -- Options for HTML output ----------------------------------------------
@@ -305,7 +303,19 @@ def run_apidoc(_):
# $ sphinx-apidoc -e -F -o /tmp/api/Bio Bio
tmp_path = tempfile.mkdtemp()
apidoc_main(["-e", "-F", "-o", tmp_path, "../../BioSQL"])
- apidoc_main(["-e", "-F", "-o", tmp_path, "../../Bio"])
+ apidoc_main(
+ [
+ "-e",
+ "-F",
+ "-o",
+ tmp_path,
+ # The input path:
+ "../../Bio",
+ # These are patterns to exclude:
+ "../../Bio/Alphabet/",
+ "../../Bio/Restriction/Restriction.py",
+ ]
+ )
os.remove(os.path.join(tmp_path, "index.rst")) # Using our own
for filename in os.listdir(tmp_path):
if filename.endswith(".rst"):
diff --git a/ci-dependencies.txt b/ci-dependencies.txt
index d98fae7dd55..44f2e8fe923 100644
--- a/ci-dependencies.txt
+++ b/ci-dependencies.txt
@@ -27,6 +27,6 @@ scipy
## Documentation
numpydoc==1.0.0
pygments
-sphinx==4.1.2
+sphinx>=4.2.0
sphinx_rtd_theme