Skip to content

Commit

Permalink
Only mock dependencies that cannot be imported
Browse files Browse the repository at this point in the history
Signed-off-by: Abrar Rahman Protyasha <[email protected]>
  • Loading branch information
aprotyas committed May 26, 2022
1 parent aa94104 commit 56a7908
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions rosdoc2/verbs/build/builders/sphinx_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,15 @@ def ensure_global(name, default):
if rosdoc2_settings.get('enable_autodoc', True):
print('[rosdoc2] enabling autodoc', file=sys.stderr)
extensions.append('sphinx.ext.autodoc')
# Provide all runtime dependencies to be mocked up
# Note: `autodoc` only mocks up those modules that it actually cannot locate in PATH
autodoc_mock_imports = {exec_depends}
# Add the package directory to PATH, so that `sphinx-autodoc` can import it
sys.path.insert(0, os.path.dirname('{package_src_directory}/'))
pkgs_to_mock = []
import importlib
for exec_depend in {exec_depends}:
try:
importlib.import_module(exec_depend)
except:
pkgs_to_mock.append(exec_depend)
autodoc_mock_imports = pkgs_to_mock
if rosdoc2_settings.get('enable_intersphinx', True):
print('[rosdoc2] enabling intersphinx', file=sys.stderr)
Expand Down

0 comments on commit 56a7908

Please sign in to comment.