diff --git a/rosdoc2/verbs/build/builders/sphinx_builder.py b/rosdoc2/verbs/build/builders/sphinx_builder.py index b6282ea8..e72d6b94 100644 --- a/rosdoc2/verbs/build/builders/sphinx_builder.py +++ b/rosdoc2/verbs/build/builders/sphinx_builder.py @@ -65,6 +65,42 @@ def ensure_global(name, default): ensure_global('release', "{package.version}") ensure_global('version', "{package_version_short}") +# Remove any unsupported extensions +allowed_extensions = set(( + # Shipped with sphinx + 'sphinx.ext.autodoc', + 'sphinx.ext.autosectionlabel', + 'sphinx.ext.autosummary', + 'sphinx.ext.coverage', + 'sphinx.ext.doctest', + 'sphinx.ext.duration', + 'sphinx.ext.extlinks', + 'sphinx.ext.githubpages', + 'sphinx.ext.graphviz', + 'sphinx.ext.ifconfig', + 'sphinx.ext.imgconverter', + 'sphinx.ext.inheritance_diagram', + 'sphinx.ext.intersphinx', + 'sphinx.ext.linkcode', + 'sphinx.ext.napoleon', + 'sphinx.ext.todo', + 'sphinx.ext.viewcode', + # Sphinx-included math extensions + 'sphinx.ext.imgmath', + 'sphinx.ext.mathjax', + # Installed by us + 'breathe', + 'exhale', + 'myst_parser', + 'sphinx_rtd_theme', +)) +for extension in extensions[:]: + if extension not in allowed_extensions: + print(f'[rosdoc2] *** Warning *** removing extension "{{extension}}", not supported') + extensions.remove(extension) +if extensions: + print(f'[rosdoc2] user conf.py specified allowed extensions: {{extensions}}') + if rosdoc2_settings.get('enable_autodoc', True): print('[rosdoc2] enabling autodoc', file=sys.stderr) extensions.append('sphinx.ext.autodoc') diff --git a/test/packages/basic_cpp/doc/conf.py b/test/packages/basic_cpp/doc/conf.py index a6c7e47b..d5b595b9 100644 --- a/test/packages/basic_cpp/doc/conf.py +++ b/test/packages/basic_cpp/doc/conf.py @@ -41,6 +41,29 @@ ## See the rosdoc2_settings below for some options on avoiding that. extensions = [ 'sphinx_rtd_theme', + 'i_do_not_exist', + # Shipped with sphinx + 'sphinx.ext.autodoc', + 'sphinx.ext.autosectionlabel', + 'sphinx.ext.autosummary', + 'sphinx.ext.coverage', + 'sphinx.ext.doctest', + 'sphinx.ext.duration', + 'sphinx.ext.extlinks', + 'sphinx.ext.githubpages', + 'sphinx.ext.graphviz', + 'sphinx.ext.ifconfig', + 'sphinx.ext.imgconverter', + 'sphinx.ext.inheritance_diagram', + 'sphinx.ext.intersphinx', + 'sphinx.ext.linkcode', + 'sphinx.ext.napoleon', + 'sphinx.ext.todo', + 'sphinx.ext.viewcode', + # Sphinx-included math extensions + 'sphinx.ext.imgmath', + 'sphinx.ext.mathjax', + ] # Add any paths that contain templates here, relative to this directory. @@ -126,3 +149,8 @@ ## Support markdown # 'support_markdown': True, } + +## This function is required by the linkcode extension. +## See https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html +def linkcode_resolve(domain, info): + return None