Skip to content

Commit 598d38b

Browse files
author
Abrar Rahman Protyasha
committed
Add rosdoc2 option to specify primary_domain
This option should enable `sphinx` to land on reasonable defaults for code highlighting Pygments lexers, as well as other markup behaviors, depending on the domain of a package (defaults to `cpp`). Signed-off-by: Abrar Rahman Protyasha <[email protected]>
1 parent 77854b6 commit 598d38b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

rosdoc2/verbs/build/builders/sphinx_builder.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ def ensure_global(name, default):
119119
# TODO(aprotyas): Migrate files under the `include` tag in the project's Doxygen
120120
# configuration into the Sphinx project tree used to run the Sphinx builder in.
121121
extensions.append('myst_parser')
122+
123+
# if no `primary_domain` option provided, defaults to 'cpp'
124+
if rosdoc2_settings.get('primary_domain', 'cpp'):
125+
print(f"[rosdoc2] setting primary domain to '{{rosdoc2_settings.get('primary_domain')}}'",
126+
file=sys.stderr)
127+
# Tell sphinx what the primary language being documented is.
128+
primary_domain = rosdoc2_settings.get('primary_domain')
129+
130+
# Tell sphinx what the pygments highlight language should be.
131+
highlight_language = rosdoc2_settings.get('primary_domain')
122132
"""
123133

124134
default_conf_py_template = """\
@@ -239,6 +249,13 @@ def ensure_global(name, default):
239249
240250
## Support markdown
241251
# 'support_markdown': True,
252+
253+
## This setting, if set, will attempt to set the `sphinx` options
254+
## `primary_domain` and `highlight_language` equal to this setting. These
255+
## options allow `sphinx` to choose reasonable defaults for source
256+
## code highlighting, among other things.
257+
## Possible values (without extensions): 'c', 'cpp', 'js', 'py'
258+
# 'primary_domain': 'cpp',
242259
}}
243260
"""
244261

0 commit comments

Comments
 (0)