Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Create jinja template for changelog actions #610

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ jobs:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: "Setup python"
uses: actions/setup-python@v5
with:
python-version: ${{ env.MAIN_PYTHON_VERSION }}

- name: "Checkout repo"
uses: actions/checkout@v4

- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install -e .[changelog]
- uses: ansys/actions/doc-changelog@v8
if: ${{ github.event_name == 'pull_request' }}
with:
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/610.added.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
feat: Create jinja template for changelog actions
15 changes: 12 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ doc = [
"sphinx-jinja==2.0.2",
"sphinx-notfound-page==1.1.0",
]
changelog = [
"sphinx-design==0.6.1",
]

[project.entry-points."sphinx.html_themes"]
ansys_sphinx_theme = "ansys_sphinx_theme"
Expand Down Expand Up @@ -120,14 +123,16 @@ show_missing = true
[tool.towncrier]
directory = "doc/changelog.d"
filename = "doc/source/changelog.rst"
template = "doc/changelog.d/changelog_template.jinja"
template = "ansys_sphinx_theme:changelog_template.jinja"
start_string = ".. towncrier release notes start\n"
title_format = "`{version} <https://github.com/ansys/ansys-sphinx-theme/releases/tag/v{version}>`_ - {project_date}"
issue_format = "`#{issue} <https://github.com/ansys/ansys-sphinx-theme/pull/{issue}>`_"
all_bullets = false
underlines = ["=", "^"]

[[tool.towncrier.type]]
directory = "added"
name = "Added"
name = "Features"
showcontent = true

[[tool.towncrier.type]]
Expand All @@ -137,7 +142,7 @@ showcontent = true

[[tool.towncrier.type]]
directory = "fixed"
name = "Fixed"
name = "Bug fixes"
showcontent = true

[[tool.towncrier.type]]
Expand All @@ -164,3 +169,7 @@ showcontent = true
directory = "test"
name = "Test"
showcontent = true

[[tool.towncrier.section]]
name = ""
path = ""
23 changes: 23 additions & 0 deletions src/ansys_sphinx_theme/templates/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Copyright (C) 2021 - 2025 ANSYS, Inc. and/or its affiliates.
# SPDX-License-Identifier: MIT
#
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

"""Reusable templates for changelog files."""
19 changes: 19 additions & 0 deletions src/ansys_sphinx_theme/templates/changelog_template.jinja
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{% if sections[""] %}

.. tab-set::
{%+ for category, val in definitions.items() if category in sections[""] +%}
.. tab-item:: {{ definitions[category]['name'] }}

.. list-table::
:header-rows: 0
:widths: auto

{%+ for text, values in sections[""][category].items() +%}
* - {{ text }}
- {{ values|join(', ') }}
{% endfor %}
{% endfor %}

{% else %}
No significant changes.
{% endif %}