MkInstallGuide

github Show source on GitHub

Node to display an install guide.

Example: Regular

Jinja

{{ mk.MkInstallGuide() }}

Python

MkInstallGuide()

pip

The latest released version is available at the Python package index.

pip install mknodes

pipx

pipx allows for the global installation of Python applications in isolated environments.

pipx install mknodes


Example: Explicit

Jinja

{{ "mkdocs" | MkInstallGuide(package_repos=["pip", "pipx"]) }}

Python

MkInstallGuide('mkdocs', package_repos=['pip', 'pipx'])

pip

The latest released version is available at the Python package index.

pip install mkdocs

pipx

pipx allows for the global installation of Python applications in isolated environments.

pipx install mkdocs
### pip

The latest released version is available at the [Python package index](https://pypi.org/project/mkdocs).

````python
pip install mkdocs
````
### pipx

[pipx](https://github.com/pypa/pipx) allows for the global installation of Python applications in isolated environments.

````python
pipx install mkdocs
````
<h3>pip</h3>
<p>The latest released version is available at the <a href="https://pypi.org/project/mkdocs">Python package index</a>.</p>
<pre><code class="language-python">pip install mkdocs
</code></pre>
<h3>pipx</h3>
<p><a href="https://github.com/pypa/pipx">pipx</a> allows for the global installation of Python applications in isolated environments.</p>
<pre><code class="language-python">pipx install mkdocs
</code></pre>
MkInstallGuide
├── MkHeader('pip', level=3)
├── MkCode(None)
│   ╰── MkText('pip install mkdocs')
├── MkHeader('pipx', level=3)
╰── MkCode(None)
    ╰── MkText('pipx install mkdocs')

class MkInstallGuide(mktemplate.MkTemplate)
graph TD
  2805510712["mkinstallguide.MkInstallGuide"]
  1289759389["mktemplate.MkTemplate"]
  3160803176["rendercache.TemplateRenderMixin"]
  2751680898["builtins.object"]
  835538629["mkcontainer.MkContainer"]
  1956333208["mkcontainer.MkContainerBase"]
  1359323199["mknode.MkNode"]
  1289759389 --> 2805510712
  3160803176 --> 1289759389
  2751680898 --> 3160803176
  835538629 --> 1289759389
  1956333208 --> 835538629
  1359323199 --> 1956333208
  2751680898 --> 1359323199
/home/runner/work/mknodes/mknodes/src/mknodes/templatenodes/mkinstallguide/metadata.toml
[metadata]
name = "MkInstallGuide"
icon = "mdi:help"
group = "documentation"
virtual_children = true

[examples.regular]
title = "Regular"
jinja = """
{{ mk.MkInstallGuide() }}
"""

[examples.explicit]
title = "Explicit"
jinja = """
{{ "mkdocs" | MkInstallGuide(package_repos=["pip", "pipx"]) }}
"""

[output.markdown]
template = """
{% for method in node.package_repos %}
{{ method.ID | MkHeader(level=node.header_level) }}

{{ method.info_text() }}

{{ method.install_instructions() | MkCode }}
{% endfor %}
"""

# proj = self.associated_distribution
# if method.ID == "pip" and proj and (extras := proj.info.extras):
#     extras_str = ",".join(extras)
#     text = f"{method.install_instructions()}[{extras_str}]"
#     code = mkcode.MkCode(text)
#     items.append(code)
mknodes.templatenodes.mkinstallguide.MkInstallGuide
11class MkInstallGuide(mktemplate.MkTemplate):
12    """Node to display an install guide."""
13
14    ICON = "material/help"
15    VIRTUAL_CHILDREN = True
16
17    def __init__(
18        self,
19        distribution: str | None = None,
20        *,
21        package_repos: list[installmethods.InstallMethodStr] | None = None,
22        header_level: int = 3,
23        **kwargs: Any,
24    ) -> None:
25        """Constructor.
26
27        Args:
28            distribution: name of the distribution to install
29            package_repos: package repositories the project is available on
30            header_level: Header level for each section
31            kwargs: Keyword arguments passed to parent
32        """
33        super().__init__("output/markdown/template", **kwargs)
34        self._distribution = distribution
35        self.header_level = header_level
36        self._package_repos = package_repos
37
38    @property
39    def package_repos(self) -> list[installmethods.InstallMethod]:
40        if self._package_repos:
41            return [
42                installmethods.InstallMethod.by_id(i)(self.distribution)
43                for i in self._package_repos
44            ]
45        return self.ctx.metadata.package_repos or []
46
47    @property
48    def distribution(self):
49        return self._distribution or self.ctx.metadata.distribution_name
50
51    @distribution.setter
52    def distribution(self, value) -> None:
53        self._distribution = value
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/help
status: new
title: MkInstallGuide