Skip to content

Commit

Permalink
Exclude rather than mock problematic modules for API docs (#3731)
Browse files Browse the repository at this point in the history
Exclude rather than mock Bio.Alphabet etc as per suggestion here:
sphinx-doc/sphinx#9631

Should be OK with latest Sphinx now (on both GitHub actions and CircleCI)
  • Loading branch information
peterjc committed Sep 20, 2021
1 parent 7b946db commit 80e1e2d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .circleci/requirements-sphinx.txt
Expand Up @@ -4,7 +4,7 @@ numpy
rdflib
reportlab
scipy
sphinx==4.1.2
sphinx>=4.2.0
numpydoc==1.0.0
pygments
sphinx_rtd_theme
18 changes: 14 additions & 4 deletions Doc/api/conf.py
Expand Up @@ -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 ----------------------------------------------

Expand Down Expand Up @@ -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"):
Expand Down
2 changes: 1 addition & 1 deletion ci-dependencies.txt
Expand Up @@ -27,6 +27,6 @@ scipy
## Documentation
numpydoc==1.0.0
pygments
sphinx==4.1.2
sphinx>=4.2.0
sphinx_rtd_theme

0 comments on commit 80e1e2d

Please sign in to comment.