Skip to content

Commit

Permalink
Provide autodoc the exec_dependencys to mock
Browse files Browse the repository at this point in the history
In this commit, a list of all `exec_dependency`s of a package is format
mapped into `autodoc_mock_imports`.

`autodoc` mocks the modules which it cannot import from PATH. As such,
this allows module documentation to build successfully even if a certain
imported module is not in PATH.

Signed-off-by: Abrar Rahman Protyasha <[email protected]>
  • Loading branch information
Abrar Rahman Protyasha committed Aug 14, 2021
1 parent ec135fb commit cecccee
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions rosdoc2/verbs/build/builders/sphinx_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ 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}
if rosdoc2_settings.get('enable_intersphinx', True):
print('[rosdoc2] enabling intersphinx', file=sys.stderr)
Expand Down Expand Up @@ -539,6 +542,7 @@ def generate_wrapping_rosdoc2_sphinx_project_into_directory(
f' "{package.name} Doxygen Project": "{self.doxygen_xml_directory}"')
template_variables = {
'package_name': package.name,
'exec_depends': [exec_depend.name for exec_depend in package.exec_depends],
'build_type': self.build_context.build_type,
'always_run_doxygen': self.build_context.always_run_doxygen,
'user_sourcedir': os.path.abspath(user_sourcedir),
Expand Down

0 comments on commit cecccee

Please sign in to comment.