Skip to content

Commit 37535e5

Browse files
committed
+ FEAT(sphinxext): +graphtik_plot_keywords sphinx-configuration ...
with a default value that suppresses grafting the title of a netop in the images, to allow for using the `:name:` option of :rst:dir:`graphtik` directive.
1 parent da7a116 commit 37535e5

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

docs/source/plotting.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,14 @@ Configurations
318318
is missing.
319319
If empty, ``{}`` assumed (library's default options).
320320

321+
.. confval:: graphtik_plot_keywords
322+
323+
- type: `dict`
324+
- default: ``{"title": None}``
325+
326+
Arguments or :func:`.build_pydot()` to apply when rendering plottables.
327+
By default it suppresses the grafting the title of a netop in the images,
328+
to allow for using the `:name:` option of :rst:dir:`graphtik` directive.
321329

322330
.. Warning::
323331
Don't disable doctesting of *literal-blocks*, that is,

graphtik/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ def plot(
217217
show=False,
218218
jupyter_render: Union[None, Mapping, str] = None,
219219
**kws,
220-
):
220+
) -> "pydot.Dot":
221221
"""
222222
Entry-point for plotting ready made operation graphs.
223223

graphtik/sphinxext/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,9 +392,10 @@ def setup(app: Sphinx):
392392
)
393393
app.add_config_value("graphtik_default_graph_format", None, "html", [str, None])
394394
# TODO: impl sphinx-config --> graphtik-configs
395-
app.add_config_value("graphtik_configurations", {}, "html", [cabc.Mapping])
396-
# TODO: impl sphinx-config --> plot keywords
397-
app.add_config_value("graphtik_plot_keywords", {}, "html", [cabc.Mapping])
395+
app.add_config_value("graphtik_configurations ", {}, "html", [cabc.Mapping])
396+
app.add_config_value(
397+
"graphtik_plot_keywords", {"title": None}, "html", [cabc.Mapping]
398+
)
398399
app.add_config_value("graphtik_zoomable", True, "html", [bool])
399400
app.add_config_value(
400401
"graphtik_zoomable_options",

graphtik/sphinxext/_graphtikbuilder.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ def _globals_updated(self, code: extdoctest.TestCode, globs: dict):
5757
globs, node["graphvar"], (code.filename, code.lineno)
5858
)
5959
if plottable:
60-
dot: pydot.Dot = plottable if isinstance(
61-
plottable, pydot.Dot
62-
) else plottable.plot()
60+
dot: pydot.Dot
61+
if isinstance(plottable, pydot.Dot):
62+
dot = plottable
63+
else:
64+
dot = plottable.plot(**self.config.graphtik_plot_keywords)
6365
img_format = node["img_format"]
6466
rel_img_path = self._render_dot_image(img_format, dot, node)
6567
dot_str = (

0 commit comments

Comments
 (0)