Skip to content

Commit

Permalink
Add markdown parsing support to rosdoc2 (ros-infrastructure#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
Abrar Rahman Protyasha authored Jul 29, 2021
1 parent 25d00f0 commit 77854b6
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
26 changes: 26 additions & 0 deletions rosdoc2/verbs/build/builders/sphinx_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ def ensure_global(name, default):
print('[rosdoc2] enabling exhale', file=sys.stderr)
extensions.append('exhale')
ensure_global('exhale_args', {{}})
from exhale import utils
exhale_args.update({{
# These arguments are required.
"containmentFolder": "{user_sourcedir}/api",
Expand All @@ -85,6 +87,14 @@ def ensure_global(name, default):
# TIP: if using the sphinx-bootstrap-theme, you need
# "treeViewIsBootstrap": True,
"exhaleExecutesDoxygen": False,
# Maps markdown files to the "md" lexer, and not the "markdown" lexer
# Pygments registers "md" as a valid markdown lexer, and not "markdown"
"lexerMapping": {{r".*\.(md|markdown)$": "md",}},
# This mapping will work when `exhale` supports `:doxygenpage:` directives
# Check https://github.com/svenevs/exhale/issues/111
# TODO(aprotyas): Uncomment the mapping below once the above issue is resolved.
# "customSpecificationsMapping": utils.makeCustomSpecificationsMapping(
# lambda kind: [":project:", ":path:", ":content-only:"] if kind == "page" else []),
}})
if rosdoc2_settings.get('override_theme', True):
Expand All @@ -101,6 +111,14 @@ def ensure_global(name, default):
ensure_global('intersphinx_mapping', {{
{intersphinx_mapping_extensions}
}})
if rosdoc2_settings.get('support_markdown', True):
print(f"[rosdoc2] adding markdown parser", file=sys.stderr)
# The `myst_parser` is used specifically if there are markdown files
# in the sphinx project
# TODO(aprotyas): Migrate files under the `include` tag in the project's Doxygen
# configuration into the Sphinx project tree used to run the Sphinx builder in.
extensions.append('myst_parser')
"""

default_conf_py_template = """\
Expand Down Expand Up @@ -160,6 +178,11 @@ def ensure_global(name, default):
master_doc = 'index'
source_suffix = {{
'.rst': 'restructuredtext',
'.md': 'markdown',
'.markdown': 'markdown',
}}
# -- Options for HTML output -------------------------------------------------
Expand Down Expand Up @@ -213,6 +236,9 @@ def ensure_global(name, default):
## scope when run with rosdoc2, and could be conditionally used in your own
## Sphinx conf.py file.
# 'automatically_extend_intersphinx_mapping': True,
## Support markdown
# 'support_markdown': True,
}}
"""

Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ install_requires =
setuptools>=40.6.0
sphinx
sphinx-rtd-theme
myst-parser
packages = find:
tests_require =
flake8
Expand Down

0 comments on commit 77854b6

Please sign in to comment.