Skip to content

Commit

Permalink
docs: customize jinja changelog template
Browse files Browse the repository at this point in the history
  • Loading branch information
mdtanker committed Nov 30, 2023
1 parent 2bdeccb commit 203c1c8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,9 @@ prerelease = true
[tool.semantic_release.changelog]
template_dir = "templates"

[tool.semantic_release.changelog.environment]
trim_blocks = true

[tool.semantic_release.commit_parser_options]
allowed_tags = [
"build", # Changes that affect the build system or external dependencies
Expand Down
45 changes: 41 additions & 4 deletions templates/CHANGELOG.md.j2
Original file line number Diff line number Diff line change
@@ -1,21 +1,58 @@
# Changelog

{% if context.history.unreleased | length > 0 %}
{# UNRELEASED #}
## Unreleased

{% for type_, commits in context.history.unreleased | dictsort %}
{% if type_ == "fix" %}
### πŸ› Bug Fixes
{% elif type_ == "chore" %}
### 🧰 Chores / Maintenance
{% elif type_ == "feature" %}
### πŸš€ Features
{% elif type_ == "documentation" %}
### πŸ“– Documentation
{% elif type_ == "style" %}
### ✏️ Formatting
{% elif type_ == "build" %}
### πŸ“¦οΈ Build
{% else %}
### {{ type_ | capitalize }}
{% endif%}
{% for commit in commits %}{% if type_ != "unknown" %}
* {{ commit.message.rstrip() }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% set msg = commit.message.rstrip() %}
{% set msg_no_ID = msg[msg.index(':')+2:] %}
* {{ msg_no_ID }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% else %}
* {{ commit.message.rstrip() }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
* {{ msg }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% endif %}{% endfor %}{% endfor %}{% endif %}

{% for version, release in context.history.released.items() %}
{# RELEASED #}

## {{ version.as_semver_tag() }} ({{ release.tagged_date.strftime("%Y-%m-%d") }})

{% for type_, commits in release["elements"] | dictsort %}
{% if type_ == "fix" %}
### πŸ› Bug Fixes
{% elif type_ == "chore" %}
### 🧰 Chores / Maintenance
{% elif type_ == "feature" %}
### πŸš€ Features
{% elif type_ == "documentation" %}
### πŸ“– Documentation
{% elif type_ == "style" %}
### ✏️ Formatting
{% elif type_ == "build" %}
### πŸ“¦οΈ Build
{% else %}
### {{ type_ | capitalize }}
{% endif%}
{% for commit in commits %}{% if type_ != "unknown" %}
* {{ commit.message.rstrip() }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% set msg = commit.message.rstrip() %}
{% set msg_no_ID = msg[msg.index(':')+2:] %}
* {{ msg_no_ID }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% else %}
* {{ commit.message.rstrip() }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
* {{ msg }} ([`{{ commit.short_hash }}`]({{ commit.hexsha | commit_hash_url }}))
{% endif %}{% endfor %}{% endfor %}{% endfor %}

0 comments on commit 203c1c8

Please sign in to comment.