You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Subject: Support autodoc_mock_imports in autosummary
Problem
The autodoc extension has a autodoc_mock_imports configuration option which may be used to produce documentation despite not all modules imported by some module being available. However, autosummary (which depends on autodoc) does not recognize this configuration option, and thus fails to generate summaries for modules containing unknown imports.
Suggested fix
diff --git a/sphinx/ext/autosummary/__init__.py b/sphinx/ext/autosummary/__init__.py
index 10adfc9ce..59184b23a 100644
--- a/sphinx/ext/autosummary/__init__.py
+++ b/sphinx/ext/autosummary/__init__.py
@@ -72,7 +72,7 @@ from sphinx import addnodes
from sphinx.environment.adapters.toctree import TocTree
from sphinx.ext.autodoc import get_documenters
from sphinx.ext.autodoc.directive import DocumenterBridge, Options
-from sphinx.ext.autodoc.importer import import_module
+from sphinx.ext.autodoc.importer import import_module, mock
from sphinx.locale import __
from sphinx.pycode import ModuleAnalyzer, PycodeError
from sphinx.util import import_object, rst, logging
@@ -678,10 +678,11 @@ def process_generate_options(app):
'But your source_suffix does not contain .rst. Skipped.'))
return
- generate_autosummary_docs(genfiles, builder=app.builder,
- warn=logger.warning, info=logger.info,
- suffix=suffix, base_path=app.srcdir,
- app=app)
+ with(mock(app.env.config.autodoc_mock_imports):
+ generate_autosummary_docs(genfiles, builder=app.builder,
+ warn=logger.warning, info=logger.info,
+ suffix=suffix, base_path=app.srcdir,
+ app=app)
def setup(app):
Workaround
I currently use monkey patching to work around the problem.
+1: Resonable. But I'd like to add a new option like autosummary_mock_imports because it is hard to understand autodoc_mock_imports effects to autosummary.
Subject: Support autodoc_mock_imports in autosummary
Problem
The autodoc extension has a
autodoc_mock_imports
configuration option which may be used to produce documentation despite not all modules imported by some module being available. However, autosummary (which depends on autodoc) does not recognize this configuration option, and thus fails to generate summaries for modules containing unknown imports.Suggested fix
Workaround
I currently use monkey patching to work around the problem.
Perhaps there are better ways to handle this situation?
The text was updated successfully, but these errors were encountered: