Skip to content

Commit 0e3437b

Browse files
[CONFIG] Improved documentation configuration (- WIP #413 -)
Changes in file docs/conf.py: * enabled mermaid zoom by default * possible improvement for mermaid theme * added some docstrings to linkcode_resolve * other minor changes
1 parent 70963f4 commit 0e3437b

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

docs/conf.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
# The suffix of source filenames.
104104
source_suffix = {
105105
".yml": "yaml",
106+
".toml": "toml",
106107
".md": "markdown",
107108
".txt": "markdown",
108109
"Makefile": "makefile",
@@ -197,6 +198,7 @@
197198
"default": pygments_options,
198199
"python": pygments_options,
199200
"yaml": pygments_yaml_options,
201+
"ini": pygments_yaml_options,
200202
"makefile": pygments_options,
201203
}
202204

@@ -292,6 +294,15 @@
292294
# Output file base name for HTML help builder.
293295
htmlhelp_basename = "multicast_doc"
294296

297+
# -- Options for MyST markdown parser -------------------------------------------
298+
# see https://github.com/mgaitan/sphinxcontrib-mermaid?tab=readme-ov-file#markdown-support
299+
300+
# GFM style mermaid use zoom
301+
mermaid_d3_zoom = True
302+
303+
# themes
304+
mermaid_params = ["--theme", "dark", "--backgroundColor", "transparent"]
305+
295306
# -- Options for MyST markdown parser -------------------------------------------
296307
# see https://myst-parser.readthedocs.io/en/latest/syntax/roles-and-directives.html
297308

@@ -444,6 +455,48 @@
444455

445456

446457
def linkcode_resolve(domain, info):
458+
"""
459+
Resolves selectivly linking to GitHub source-code for the multicast module.
460+
461+
See https://www.sphinx-doc.org/en/master/usage/extensions/linkcode.html for more details.
462+
463+
Unit-Testing:
464+
465+
First set up test fixtures by importing conf.
466+
467+
>>> import docs.conf as _conf
468+
>>>
469+
470+
Testcase 1: Test function with input.
471+
472+
>>> _conf.linkcode_resolve is not None
473+
True
474+
>>> ignored_input = "docs.conf" # this is unchanged
475+
>>> test_text = "docs.conf" # this is resolved
476+
>>> bad_input = False # this is invalid
477+
>>> res_text = _conf.linkcode_resolve("py", info={"module": test_text})
478+
>>> res_text is not None
479+
True
480+
>>> type(res_text) is type(str())
481+
True
482+
>>> res_text is not test_text
483+
True
484+
>>> _conf.linkcode_resolve("py", info={"module": test_text,}) is res_text
485+
True
486+
>>> _conf.linkcode_resolve("py", info={"module": ignored_input,}) is ignored_input
487+
True
488+
>>> _conf.linkcode_resolve("py", info={"module": bad_input,}) is None
489+
True
490+
>>> len(res_text) > 0
491+
True
492+
>>>
493+
>>> # cleanup from unit-test
494+
>>> del ignored_input
495+
>>> del bad_input
496+
>>> del test_text
497+
>>> del res_text
498+
>>>
499+
"""
447500
if not isinstance(domain, str) or domain != "py":
448501
return None
449502
if not isinstance(info, dict) or "module" not in info or not info["module"]:

0 commit comments

Comments
 (0)