MkPipDepTree¶
Node to display a mermaid diagram for the dependencies.¶
Example: Regular
Jinja
{{ "jinja2" | MkPipDepTree }}
Python
MkPipDepTree('jinja2')
graph TD
classDef missing stroke-dasharray: 5
jinja2["Jinja2<br/>3.1.6"]
markupsafe["MarkupSafe<br/>3.0.4"]
jinja2 -- ">=2.0" --> markupsafe
````mermaid
graph TD
classDef missing stroke-dasharray: 5
jinja2["Jinja2<br/>3.1.6"]
markupsafe["MarkupSafe<br/>3.0.4"]
jinja2 -- ">=2.0" --> markupsafe
````
<pre><code class="language-mermaid">graph TD
classDef missing stroke-dasharray: 5
jinja2["Jinja2<br/>3.1.6"]
markupsafe["MarkupSafe<br/>3.0.4"]
jinja2 -- ">=2.0" --> markupsafe
</code></pre>
````mermaid
graph TD
classDef missing stroke-dasharray: 5
jinja2["Jinja2<br/>3.1.6"]
markupsafe["MarkupSafe<br/>3.0.4"]
jinja2 -- ">=2.0" --> markupsafe
````
Name |
Children |
Inherits |
|---|---|---|
MkDiagram |
graph TD
570879978["mkpipdeptree.MkPipDepTree"]
1128373226["mkdiagram.MkDiagram"]
1761293797["mkcode.MkCode"]
835538629["mkcontainer.MkContainer"]
1956333208["mkcontainer.MkContainerBase"]
1359323199["mknode.MkNode"]
2751680898["builtins.object"]
1128373226 --> 570879978
1761293797 --> 1128373226
835538629 --> 1761293797
1956333208 --> 835538629
1359323199 --> 1956333208
2751680898 --> 1359323199
/home/runner/work/mknodes/mknodes/src/mknodes/templatenodes/mkpipdeptree/metadata.toml¶
[metadata]
name = "MkPipDepTree"
icon = "mdi:dependency"
status = "new"
group = "documentation"
[requirements.package.pipdeptree]
[examples.regular]
title = "Regular"
jinja = """
{{ "jinja2" | MkPipDepTree }}
"""
# [examples.direction]
# title = "Directed"
# jinja = """
# {{ mk.MkPipDepTree(direction="LR") }}
# """
[output.markdown]
template = """
{{ node.fence_boundary }} mermaid
{{ node.get_text() }}
{{ node.fence_boundary }}
"""
mknodes.templatenodes.mkpipdeptree.MkPipDepTree¶
63class MkPipDepTree(mkdiagram.MkDiagram):
64 """Node to display a mermaid diagram for the dependencies."""
65
66 REQUIRED_PACKAGES = [resources.Package("pipdeptree")]
67 ICON = "material/dependency"
68
69 def __init__(
70 self,
71 package: types.ModuleType | str | None = None,
72 *,
73 direction: Literal["TD", "DT", "LR", "RL"] = "TD",
74 local_only: bool = False,
75 user_only: bool = False,
76 **kwargs: Any,
77 ) -> None:
78 """Constructor.
79
80 Args:
81 package: Package to show a dependency diagram for
82 direction: diagram direction
83 local_only: Show ony local packages
84 user_only: Show only user packages
85 kwargs: Keyword arguments passed to parent
86 """
87 self._package = package
88 self.local_only = local_only
89 self.user_only = user_only
90 super().__init__(direction=direction, **kwargs)
91
92 @property
93 def package(self) -> str:
94 match self._package:
95 case None:
96 return self.ctx.metadata.distribution_name
97 case types.ModuleType():
98 return self._package.__name__
99 case _:
100 return self._package
101
102 def _tree_params(self) -> dict[str, Any]:
103 return dict(package=self.package, local_only=self.local_only, user_only=self.user_only)
104
105 def get_input_requests(self) -> list[inputs.InputRequest]:
106 return [inputs.InputRequest.create("pipdeptree", **self._tree_params())]
107
108 def get_mermaid_code(self) -> str:
109 return self.ctx.inputs.get("pipdeptree", **self._tree_params())
Page info
Code for this page
mknodes.manual.nodes_section.create_section_for_nodes¶
93def create_section_for_nodes(
94 nav: mk.MkNav,
95 klasses: Sequence[type[mk.MkNode]],
96) -> mk.MkTable:
97 table = mk.MkTable(columns=["Node", "Docstrings", "Markdown extensions"])
98 for kls in klasses:
99 tpl = "classpage_custom.jinja"
100 page = mk.MkClassPage(kls, icon=kls.ICON, template_path=tpl, parent=nav, hide="toc")
101 nav += page
102 if kls.STATUS:
103 page.metadata.status = kls.STATUS
104 elif kls.JS_FILES:
105 page.metadata.status = "js"
106 elif kls.CSS:
107 page.metadata.status = "css"
108 page.created_by = create_section_for_nodes
109 link = mk.MkLink(page, kls.__name__, icon=kls.ICON)
110 extensions = ", ".join(f"`{i}`" for i in kls.REQUIRED_EXTENSIONS)
111 table.add_row((link, kls.__doc__, extensions))
112 return table
Resources
Resources(css=[],
markdown_extensions={'admonition': {},
'pymdownx.details': {},
'pymdownx.highlight': {'anchor_linenums': True,
'line_spans': '__span',
'pygments_lang_class': True},
'pymdownx.superfences': {'custom_fences': [{'class': 'mermaid',
'format': <function fence_code_format at 0x7ff77e88b060>,
'name': 'mermaid'}]},
'pymdownx.tabbed': {},
'tables': {}},
plugins=[Plugin('mkdocstrings')],
js=[],
assets=[],
packages=[])
Metadata
created:
source_filename: /home/runner/work/mknodes/mknodes/src/mknodes/manual/nodes_section.py
source_function: create_section_for_nodes
source_line_no: 93
hide:
- toc
icon: material/dependency
title: MkPipDepTree