Skip to content

MkCommitConventions

Show source on GitHub

Text node containing Commit message conventions.

Example: All commit_types

Jinja

{{ mk.MkCommitConventions() }}

Python

MkCommitConventions()

Commit messages must follow the following convention:

<type>[(scope)]: Subject

[Body]

Subject and body must be valid Markdown. Subject must have proper casing (uppercase for first letter if it makes sense), but no dot at the end, and no punctuation in general.

Scope and body are optional. Type can be:

  • build: About packaging, building wheels, etc.
  • chore: About packaging or repo/files management.
  • docs: About documentation.
  • feat: New feature.
  • fix: Bug fix.
  • refactor: Changes that are not features or bug fixes.
  • test: About tests.

If you write a body, please add trailers at the end (for example issues and PR references, or co-authors), without relying on GitHub's flavored Markdown:

Body.

Issue #10: https://github.com/namespace/project/issues/10
Related to PR namespace/other-project#2: https://github.com/namespace/other-project/pull/2"

These "trailers" must appear at the end of the body, without any blank lines between them. The trailer title can contain any character except colons :. We expect a full URI for each trailer, not just GitHub autolinks (for example, full GitHub URLs for commits and issues, not the hash or the #issue-number).

We do not enforce a line length on commit messages summary and body, but please avoid very long summaries, and very long lines in the body, unless they are part of code blocks that must not be wrapped.

Commit messages must follow the following convention:

```md
<type>[(scope)]: Subject

[Body]

Subject and body must be valid Markdown. Subject must have proper casing (uppercase for first letter if it makes sense), but no dot at the end, and no punctuation in general.

Scope and body are optional. Type can be:

  • build: About packaging, building wheels, etc.
  • chore: About packaging or repo/files management.
  • docs: About documentation.
  • feat: New feature.
  • fix: Bug fix.
  • refactor: Changes that are not features or bug fixes.
  • test: About tests.

If you write a body, please add trailers at the end (for example issues and PR references, or co-authors), without relying on GitHub's flavored Markdown:

Body.

Issue #10: https://github.com/namespace/project/issues/10
Related to PR namespace/other-project#2: https://github.com/namespace/other-project/pull/2"

These "trailers" must appear at the end of the body, without any blank lines between them. The trailer title can contain any character except colons :. We expect a full URI for each trailer, not just GitHub autolinks (for example, full GitHub URLs for commits and issues, not the hash or the #issue-number).

We do not enforce a line length on commit messages summary and body, but please avoid very long summaries, and very long lines in the body, unless they are part of code blocks that must not be wrapped. ```

<p>Commit messages must follow the following convention:</p>
<div class="highlight"><pre><span></span><code>&lt;type&gt;[(scope)]: Subject

[Body]
</code></pre></div>
<p><strong>Subject and body must be valid Markdown.</strong>
Subject must have proper casing (uppercase for first letter
if it makes sense), but no dot at the end, and no punctuation
in general.</p>
<p>Scope and body are optional. Type can be:</p>
<ul>
<li><code>build</code>: About packaging, building wheels, etc.</li>
<li><code>chore</code>: About packaging or repo/files management.</li>
<li><code>ci</code>: About Continuous Integration.</li>
<li><code>deps</code>: Dependencies update.</li>
<li><code>doc</code>: About documentation.</li>
<li><code>docs</code>: About documentation.</li>
<li><code>feat</code>: New feature.</li>
<li><code>fix</code>: Bug fix.</li>
<li><code>ref</code>: Code refactoring.</li>
<li><code>revert</code>: Code revert.</li>
<li><code>perf</code>: About performance.</li>
<li><code>refactor</code>: Changes that are not features or bug fixes.</li>
<li><code>style</code>: A change in code style/format.</li>
<li><code>test</code>: About tests.</li>
<li><code>tests</code>: About tests.</li>
</ul>
<p>If you write a body, please add trailers at the end
(for example issues and PR references, or co-authors),
without relying on GitHub's flavored Markdown:</p>
<div class="highlight"><pre><span></span><code>Body.

Issue <span class="ni">#10:</span> https://github.com/namespace/project/issues/10
Related to PR namespace/other-project#2: https://github.com/namespace/other-project/pull/2&quot;
</code></pre></div>
<p>These "trailers" must appear at the end of the body,
without any blank lines between them. The trailer title
can contain any character except colons <code>:</code>.
We expect a full URI for each trailer, not just GitHub autolinks
(for example, full GitHub URLs for commits and issues,
not the hash or the #issue-number).</p>
<p>We do not enforce a line length on commit messages summary and body,
but please avoid very long summaries, and very long lines in the body,
unless they are part of code blocks that must not be wrapped.</p>

Example: Selected commit types

Jinja

{{ ["fix", "feat", "refactor"] | MkCommitConventions }}

Python

MkCommitConventions(['fix', 'feat', 'refactor'])

Commit messages must follow the following convention:

<type>[(scope)]: Subject

[Body]

Subject and body must be valid Markdown. Subject must have proper casing (uppercase for first letter if it makes sense), but no dot at the end, and no punctuation in general.

Scope and body are optional. Type can be:

  • feat: New feature.
  • fix: Bug fix.
  • refactor: Changes that are not features or bug fixes.

If you write a body, please add trailers at the end (for example issues and PR references, or co-authors), without relying on GitHub's flavored Markdown:

Body.

Issue #10: https://github.com/namespace/project/issues/10
Related to PR namespace/other-project#2: https://github.com/namespace/other-project/pull/2"

These "trailers" must appear at the end of the body, without any blank lines between them. The trailer title can contain any character except colons :. We expect a full URI for each trailer, not just GitHub autolinks (for example, full GitHub URLs for commits and issues, not the hash or the #issue-number).

We do not enforce a line length on commit messages summary and body, but please avoid very long summaries, and very long lines in the body, unless they are part of code blocks that must not be wrapped.

Commit messages must follow the following convention:

```md
<type>[(scope)]: Subject

[Body]

Subject and body must be valid Markdown. Subject must have proper casing (uppercase for first letter if it makes sense), but no dot at the end, and no punctuation in general.

Scope and body are optional. Type can be:

  • feat: New feature.
  • fix: Bug fix.
  • refactor: Changes that are not features or bug fixes.

If you write a body, please add trailers at the end (for example issues and PR references, or co-authors), without relying on GitHub's flavored Markdown:

Body.

Issue #10: https://github.com/namespace/project/issues/10
Related to PR namespace/other-project#2: https://github.com/namespace/other-project/pull/2"

These "trailers" must appear at the end of the body, without any blank lines between them. The trailer title can contain any character except colons :. We expect a full URI for each trailer, not just GitHub autolinks (for example, full GitHub URLs for commits and issues, not the hash or the #issue-number).

We do not enforce a line length on commit messages summary and body, but please avoid very long summaries, and very long lines in the body, unless they are part of code blocks that must not be wrapped. ```

<p>Commit messages must follow the following convention:</p>
<div class="highlight"><pre><span></span><code>&lt;type&gt;[(scope)]: Subject

[Body]
</code></pre></div>
<p><strong>Subject and body must be valid Markdown.</strong>
Subject must have proper casing (uppercase for first letter
if it makes sense), but no dot at the end, and no punctuation
in general.</p>
<p>Scope and body are optional. Type can be:</p>
<ul>
<li><code>feat</code>: New feature.</li>
<li><code>fix</code>: Bug fix.</li>
<li><code>refactor</code>: Changes that are not features or bug fixes.</li>
</ul>
<p>If you write a body, please add trailers at the end
(for example issues and PR references, or co-authors),
without relying on GitHub's flavored Markdown:</p>
<div class="highlight"><pre><span></span><code>Body.

Issue <span class="ni">#10:</span> https://github.com/namespace/project/issues/10
Related to PR namespace/other-project#2: https://github.com/namespace/other-project/pull/2&quot;
</code></pre></div>
<p>These "trailers" must appear at the end of the body,
without any blank lines between them. The trailer title
can contain any character except colons <code>:</code>.
We expect a full URI for each trailer, not just GitHub autolinks
(for example, full GitHub URLs for commits and issues,
not the hash or the #issue-number).</p>
<p>We do not enforce a line length on commit messages summary and body,
but please avoid very long summaries, and very long lines in the body,
unless they are part of code blocks that must not be wrapped.</p>

Bases: MkTemplate

__init__

__init__(
    commit_types: list[CommitTypeStr] | ConventionTypeStr | None = None, **kwargs: Any
)

Parameters:

Name Type Description Default
commit_types list[CommitTypeStr] | ConventionTypeStr | None

Allowed commit commit_types. Can be "basic", "conventional_commits", or a list of commit_types

None
kwargs Any

Keyword arguments passed to parent

{}
graph TD
  94721312042880["mkcommitconventions.MkCommitConventions"]
  94721308869584["mktemplate.MkTemplate"]
  94721311697232["mkcontainer.MkContainer"]
  94721308848336["mknode.MkNode"]
  94721311766592["node.Node"]
  140564252373184["builtins.object"]
  94721308869584 --> 94721312042880
  94721311697232 --> 94721308869584
  94721308848336 --> 94721311697232
  94721311766592 --> 94721308848336
  140564252373184 --> 94721311766592
/home/runner/work/mknodes/mknodes/mknodes/templatenodes/mkcommitconventions/metadata.toml
[metadata]
icon = "simple-icons:conventionalcommits"
status = "new"
name = "MkCommitConventions"
virtual_children = true

[examples.regular]
title = "All commit_types"
jinja = """
{{ mk.MkCommitConventions() }}
"""

[examples.explicit]
title = "Selected commit types"
jinja = """
{{ ["fix", "feat", "refactor"] | MkCommitConventions }}
"""

[output.markdown]
template = """
Commit messages must follow the following convention:

```md
<type>[(scope)]: Subject

[Body]

Subject and body must be valid Markdown. Subject must have proper casing (uppercase for first letter if it makes sense), but no dot at the end, and no punctuation in general.

Scope and body are optional. Type can be:

{% for commit_type in node.commit_types %} * {{ commit_type.typ }}: {{ commit_type.description }}

If you write a body, please add trailers at the end (for example issues and PR references, or co-authors), without relying on GitHub's flavored Markdown:

Body.

Issue #10: https://github.com/namespace/project/issues/10
Related to PR namespace/other-project#2: https://github.com/namespace/other-project/pull/2"

These "trailers" must appear at the end of the body, without any blank lines between them. The trailer title can contain any character except colons :. We expect a full URI for each trailer, not just GitHub autolinks (for example, full GitHub URLs for commits and issues, not the hash or the #issue-number).

We do not enforce a line length on commit messages summary and body, but please avoid very long summaries, and very long lines in the body, unless they are part of code blocks that must not be wrapped. """

```

mknodes.templatenodes.mkcommitconventions.MkCommitConventions
class MkCommitConventions(mktemplate.MkTemplate):
    """Text node containing Commit message conventions."""

    ICON = "simple/conventionalcommits"
    STATUS = "new"

    def __init__(
        self,
        commit_types: (
            list[commitconventions.CommitTypeStr]
            | commitconventions.ConventionTypeStr
            | None
        ) = None,
        **kwargs: Any,
    ):
        """Constructor.

        Args:
            commit_types: Allowed commit commit_types. Can be "basic",
                          "conventional_commits", or a list of commit_types
            kwargs: Keyword arguments passed to parent
        """
        super().__init__(template="output/markdown/template", **kwargs)
        self._commit_types = commit_types

    @property
    def commit_types(self) -> list[commitconventions.CommitType]:
        val: list[commitconventions.CommitTypeStr] | commitconventions.ConventionTypeStr
        match self._commit_types:
            case None:
                val = self.ctx.metadata.commit_types or "conventional_commits"
            case _:
                val = self._commit_types
        return commitconventions.get_types(val)