Skip to content

MkDevEnvSetup

Show source on GitHub

Text node containing Instructions to set up a dev environment.

Example: From project

Jinja

{{ mk.MkDevEnvSetup() }}

Python

MkDevEnvSetup()

All development for this library happens in the mknodes repo on GitHub. First, you'll need to download the source code and install an editable version of the Python package:

# Clone the repository
git clone https://github.com/phil65/mknodes.git
cd mknodes

Build system

Hatch is used as the build system.

pip install hatch

More information

All development for this library happens in the
[mknodes](https://github.com/phil65/mknodes.git) repo on GitHub.
First, you'll need to download the source code and install an
editable version of the Python package:

```` {.md }
# Clone the repository
git clone https://github.com/phil65/mknodes.git
cd mknodes
````

## Build system

Hatch is used as the build system.

```` {.bash }
pip install hatch
````

[More information](https://hatch.pypa.io)
<p>All development for this library happens in the
<a href=".git.md">.git.md</a> repo on GitHub.
First, you'll need to download the source code and install an
editable version of the Python package:</p>
<div class="language-md highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="gh"># Clone the repository</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a>git clone .git
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a>cd 
</span></code></pre></div>
<h2 id="build-system">Build system</h2>
<p>Hatch is used as the build system.</p>
<div class="language-bash highlight"><pre><span></span><code><span id="__span-1-1"><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a>pip<span class="w"> </span>install<span class="w"> </span>hatch
</span></code></pre></div>
<p><a href="https://hatch.pypa.io">More information</a></p>
MkDevEnvSetup
├── MkLink('https://github.com/phil65/mknodes.git', 'mknodes')
├── MkCode('# Clone the repository\ngit clone https://github.com/phil65/mknodes.git\ncd mknodes', language='md')
│   ╰── MkText('# Clone the repository\ngit clone https://github.com/phil65/mknodes.git\ncd mknodes')
├── MkHeader('Build system')
├── MkCode('pip install hatch', language='bash')
│   ╰── MkText('pip install hatch')
╰── MkLink('https://hatch.pypa.io', 'More information')

Example: Explicit

Jinja

{{ mk.MkDevEnvSetup(repo_url="http://url_to_git_repo.com/name.git") }}

Python

MkDevEnvSetup(repo_url='http://url_to_git_repo.com/name.git')

All development for this library happens in the name repo on GitHub. First, you'll need to download the source code and install an editable version of the Python package:

# Clone the repository
git clone http://url_to_git_repo.com/name.git
cd name

Build system

Hatch is used as the build system.

pip install hatch

More information

All development for this library happens in the
[name](http://url_to_git_repo.com/name.git) repo on GitHub.
First, you'll need to download the source code and install an
editable version of the Python package:

```` {.md }
# Clone the repository
git clone http://url_to_git_repo.com/name.git
cd name
````

## Build system

Hatch is used as the build system.

```` {.bash }
pip install hatch
````

[More information](https://hatch.pypa.io)
<p>All development for this library happens in the
<a href="http://url_to_git_repo.com/name.git">name</a> repo on GitHub.
First, you'll need to download the source code and install an
editable version of the Python package:</p>
<div class="language-md highlight"><pre><span></span><code><span id="__span-0-1"><a id="__codelineno-0-1" name="__codelineno-0-1" href="#__codelineno-0-1"></a><span class="gh"># Clone the repository</span>
</span><span id="__span-0-2"><a id="__codelineno-0-2" name="__codelineno-0-2" href="#__codelineno-0-2"></a>git clone http://url_to_git_repo.com/name.git
</span><span id="__span-0-3"><a id="__codelineno-0-3" name="__codelineno-0-3" href="#__codelineno-0-3"></a>cd name
</span></code></pre></div>
<h2 id="build-system">Build system</h2>
<p>Hatch is used as the build system.</p>
<div class="language-bash highlight"><pre><span></span><code><span id="__span-1-1"><a id="__codelineno-1-1" name="__codelineno-1-1" href="#__codelineno-1-1"></a>pip<span class="w"> </span>install<span class="w"> </span>hatch
</span></code></pre></div>
<p><a href="https://hatch.pypa.io">More information</a></p>
MkDevEnvSetup
├── MkLink('http://url_to_git_repo.com/name.git', 'name')
├── MkCode('# Clone the repository\ngit clone http://url_to_git_repo.com/name.git\ncd name', language='md')
│   ╰── MkText('# Clone the repository\ngit clone http://url_to_git_repo.com/name.git\ncd name')
├── MkHeader('Build system')
├── MkCode('pip install hatch', language='bash')
│   ╰── MkText('pip install hatch')
╰── MkLink('https://hatch.pypa.io', 'More information')

Bases: MkTemplate

__init__

__init__(
    *,
    repo_url: str | None = None,
    build_backend: buildsystems.BuildSystemStr | None = None,
    **kwargs: Any
)

Parameters:

Name Type Description Default
repo_url str | None

Repo url to show. If None, it will be pulled from project.

None
build_backend BuildSystemStr | None

Build backend to show install instructions for. If None, it will be pulled from project.

None
kwargs Any

Keyword arguments passed to parent

{}
graph TD
  94854583585120["mkdevenvsetup.MkDevEnvSetup"]
  94854582782240["mktemplate.MkTemplate"]
  94854582919984["mkcontainer.MkContainer"]
  94854582916880["mknode.MkNode"]
  94854582838576["node.Node"]
  140544995341632["builtins.object"]
  94854582782240 --> 94854583585120
  94854582919984 --> 94854582782240
  94854582916880 --> 94854582919984
  94854582838576 --> 94854582916880
  140544995341632 --> 94854582838576
/home/runner/work/mknodes/mknodes/mknodes/templatenodes/mkdevenvsetup/metadata.toml
[metadata]
icon = "mdi:dev-to"
status = "new"
name = "MkDevEnvSetup"
virtual_children = true

[examples.regular]
title = "From project"
jinja = """
{{ mk.MkDevEnvSetup() }}
"""

[examples.explicit]
title = "Explicit"
jinja = """
{{ mk.MkDevEnvSetup(repo_url="http://url_to_git_repo.com/name.git") }}
"""

[output.markdown]
template = """
{% set folder_name = node.repo_url.removesuffix(".git").split("/")[-1] %}
All development for this library happens in the
{{ node.repo_url | MkLink(folder_name) }} repo on GitHub.
First, you'll need to download the source code and install an
editable version of the Python package:

{{ ("# Clone the repository
git clone " ~ node.repo_url ~
"
cd " ~ folder_name ) | MkCode(language="md") }}

{{ "Build system" | MkHeader }}

{{ node.build_backend.identifier.capitalize() }} is used as the build system.

{{ ("pip install " ~ node.build_backend.identifier) | MkCode(language="bash") }}

{{ node.build_backend.url | MkLink("More information")}}
"""
mknodes.templatenodes.mkdevenvsetup.MkDevEnvSetup
class MkDevEnvSetup(mktemplate.MkTemplate):
    """Text node containing Instructions to set up a dev environment."""

    ICON = "material/dev-to"

    def __init__(
        self,
        *,
        repo_url: str | None = None,
        build_backend: buildsystems.BuildSystemStr | None = None,
        **kwargs: Any,
    ):
        """Constructor.

        Arguments:
            repo_url: Repo url to show. If None, it will be pulled from project.
            build_backend: Build backend to show install instructions for.
                            If None, it will be pulled from project.
            kwargs: Keyword arguments passed to parent
        """
        super().__init__("output/markdown/template", **kwargs)
        self._repo_url = repo_url
        self._build_backend = build_backend

    @property
    def repo_url(self) -> str:
        match self._repo_url:
            case None:
                repo_url = self.ctx.metadata.repository_url
            case str():
                repo_url = self._repo_url
            case _:
                raise TypeError(self._repo_url)
        repo_url = repo_url.rstrip("/")
        if not repo_url.endswith(".git"):
            repo_url += ".git"
        return repo_url

    @repo_url.setter
    def repo_url(self, value):
        self._repo_url = value

    @property
    def build_backend(self) -> buildsystems.BuildSystem:  # type: ignore[return]
        if self._build_backend is None:
            return self.ctx.metadata.build_system or buildsystems.setuptools
        return buildsystems.BUILD_SYSTEMS[self._build_backend]

    @build_backend.setter
    def build_backend(self, value):
        self._build_backend = value