Skip to content

Commit

Permalink
Check exhale support before registering md lexer
Browse files Browse the repository at this point in the history
The `exhale_args` mapping should only be updated with the appropriate
Pygments markdown lexer if both markdown support and exhale support are
requested. As such, an additional check for `enable_exhale` is added
into the markdown support configuration block.

An alternative would be to invoke `ensure_global` on `exhale_args`, but
that may create a needless copy of `exhale_args` incase `enable_exhale`
is false.

Signed-off-by: Abrar Rahman Protyasha <[email protected]>
  • Loading branch information
Abrar Rahman Protyasha committed Aug 5, 2021
1 parent fd1e092 commit 6281b49
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions rosdoc2/verbs/build/builders/sphinx_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,20 @@ def ensure_global(name, default):
# The `myst_parser` is used specifically if there are markdown files
# in the sphinx project
extensions.append('myst_parser')
# If markdown support is enabled, the appropriate Pygments lexer must
# be registered for `.md`/`.markdown` file suffixes
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 []),
}})
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

0 comments on commit 6281b49

Please sign in to comment.