Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganized SphinxBuilder for markdown parsing #25

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 19 additions & 11 deletions rosdoc2/verbs/build/builders/sphinx_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,6 @@ 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 @@ -116,9 +108,21 @@ def ensure_global(name, default):
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')

# If markdown support is enabled, the appropriate Pygments lexer must
# be registered for `.md`/`.markdown` file suffixes
if rosdoc2_settings.get('enable_exhale'):
exhale_args.update({{
# 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 []),
}})
"""

default_conf_py_template = """\
Expand Down Expand Up @@ -237,7 +241,11 @@ def ensure_global(name, default):
## Sphinx conf.py file.
# 'automatically_extend_intersphinx_mapping': True,

## Support markdown
## This setting, if True, will add the `myst_parser` as an extension to
## `sphinx`, hence allowing support for markdown rendering. This will also
## register the `md` Pygments lexer with `.md`/`.markdown` file suffixes, so
## that `exhale` can perform appropriate markdown syntax highlighting for
## program listing rst files.
# 'support_markdown': True,
}}
"""
Expand Down