Skip to content

Commit ba7d06e

Browse files
Revathyvenugopal162pyansys-ci-botjorgepilotoklmcadamsRobPasMue
authored
feat: add whatsnew options (#583)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Jorge Martínez <[email protected]> Co-authored-by: klmcadams <[email protected]> Co-authored-by: Kerry McAdams <[email protected]> Co-authored-by: Roberto Pastor Muela <[email protected]>
1 parent bab85f5 commit ba7d06e

File tree

15 files changed

+812
-22
lines changed

15 files changed

+812
-22
lines changed

.gitattributes

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
* text=auto !eol
2+
*.sh eol=lf
3+
*.bat eol=crlf

.github/workflows/ci_cd.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,19 @@ jobs:
4545
pull-requests: write
4646
runs-on: ubuntu-latest
4747
steps:
48+
- name: "Setup python"
49+
uses: actions/setup-python@v5
50+
with:
51+
python-version: ${{ env.MAIN_PYTHON_VERSION }}
52+
53+
- name: "Checkout repo"
54+
uses: actions/checkout@v4
55+
56+
- name: "Install dependencies"
57+
run: |
58+
python -m pip install --upgrade pip
59+
pip install -e .[changelog]
60+
4861
- uses: ansys/actions/doc-changelog@v8
4962
if: ${{ github.event_name == 'pull_request' }}
5063
with:

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ repos:
3434
- id: check-github-workflows
3535

3636
- repo: https://github.com/ansys/pre-commit-hooks
37-
rev: v0.4.4
37+
rev: v0.5.1
3838
hooks:
3939
- id: add-license-headers
4040
files: '(src|doc/source/examples)/.*\.(py)'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
feat: add whatsnew options
Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
{% if sections[""] %}
2-
{% for category, val in definitions.items() if category in sections[""] %}
3-
4-
{{ definitions[category]['name'] }}
5-
{% set underline = '^' * definitions[category]['name']|length %}
6-
{{ underline }}
7-
8-
{% for text, values in sections[""][category].items() %}
9-
- {{ text }} {{ values|join(', ') }}
10-
{% endfor %}
11-
12-
{% endfor %}
13-
{% else %}
14-
No significant changes.
15-
16-
17-
{% endif %}
1+
{% if sections[""] %}
2+
{% for category, val in definitions.items() if category in sections[""] %}
3+
4+
{{ definitions[category]['name'] }}
5+
{% set underline = '^' * definitions[category]['name']|length %}
6+
{{ underline }}
7+
8+
{% for text, values in sections[""][category].items() %}
9+
- {{ text }} {{ values|join(', ') }}
10+
{% endfor %}
11+
12+
{% endfor %}
13+
{% else %}
14+
No significant changes.
15+
16+
17+
{% endif %}
13.3 KB
Loading
8.8 KB
Loading

doc/source/changelog.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1+
12
.. _ref_release_notes:
23

34
Release notes
45
#############
56

6-
This document contains the release notes for the project.
7-
87
.. vale off
98
109
.. towncrier release notes start

doc/source/user-guide/options.rst

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,91 @@ main ``index.rst`` file and the ``learning.rst`` file in its "Getting started" s
256256
To use this feature, you must have the `quarto <https://quarto.org/>` package installed. To create thumbnails of generated PDF files,
257257
the theme is using `pdf2image`. So you should have the ``poppler`` package installed in your system.
258258
For more information, see the `pdf2image documentation <https://pypi.org/project/pdf2image/>`_.
259+
260+
What's new section
261+
------------------
262+
263+
The "What's new" section is an option that allows you to highlight new features in your library
264+
for each minor version within the changelog file.
265+
266+
To get started, create a YAML file named ``whatsnew.yml`` in the ``doc/source`` directory. The
267+
YAML file should contain the following structure:
268+
269+
.. code-block:: yaml
270+
271+
fragments:
272+
- title: Feature title
273+
version: 0.2.0 # The version the feature is introduced
274+
content: |
275+
Feature description in RST format.
276+
277+
- title: Another feature title
278+
version: 0.1.2
279+
content: |
280+
Feature description in RST format.
281+
282+
The dropdown generation only supports the following RST formats in the "content" field:
283+
284+
- Bold: Use double asterisks to wrap the text.
285+
- Italics: Use single asterisks to wrap the text.
286+
- Code samples: Use single or double backticks to wrap the text.
287+
- Links: Use the following format to include links:
288+
289+
.. code-block:: rst
290+
291+
`link text <https://www.example.com>`_
292+
293+
- Code blocks: Use the following format to include code blocks:
294+
295+
.. code-block:: rst
296+
297+
.. code:: python
298+
299+
print("hello world")
300+
301+
If a format is used in the "content" field that does not fall into the categories above, it will not
302+
be rendered correctly.
303+
304+
To enable the "What's new" sections and sidebar in the changelog file, add the following dictionary
305+
to the ``html_theme_options`` dictionary:
306+
307+
.. code-block:: python
308+
309+
html_theme_options = (
310+
{
311+
"whatsnew": {
312+
"whatsnew_file_path": "changelog.d/whatsnew.yml",
313+
"changelog_file_path": "changelog.rst",
314+
"sidebar_pages": ["changelog"],
315+
"sidebar_no_of_headers": 3, # Optional
316+
"sidebar_no_of_contents": 3, # Optional
317+
},
318+
},
319+
)
320+
321+
The dictionary contains the following keys:
322+
323+
- ``whatsnew_file_path``: The path to the YAML file containing what's new content local to the
324+
``doc/source`` directory. If not provided, the what's new section will not be generated.
325+
- ``changelog_file_path``: The path to the changelog.rst file local to the ``doc/source``
326+
directory. If not provided, the what's new section will not be generated.
327+
- ``sidebar_pages``: List of names for the pages to include the what's new sidebar on. If not
328+
provided, the what's new sidebar is not displayed.
329+
- ``sidebar_no_of_headers``: Number of minor version sections to display in the what's new sidebar.
330+
By default, it displays three version sections in the sidebar.
331+
- ``sidebar_no_of_contents``: Number of what's new content to display under each minor version in the
332+
what's new sidebar. If not provided, it displays all dropdowns by default.
333+
334+
The following images show a sample "What's new" section and sidebar in the changelog file:
335+
336+
.. tab-set::
337+
338+
.. tab-item:: What's new section
339+
340+
.. image:: ../_static/whatsnew_section.png
341+
:alt: What's new section
342+
343+
.. tab-item:: What's new sidebar
344+
345+
.. image:: ../_static/whatsnew_sidebar.png
346+
:alt: What's new sidebar

pyproject.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ doc = [
4646
"Pillow>=9.0",
4747
"PyGitHub==2.5.0",
4848
"pyvista[jupyter]==0.44.2",
49+
"PyYAML==6.0.2",
4950
"requests==2.32.3",
5051
"Sphinx==8.1.3",
5152
"sphinx-autoapi==3.4.0",
@@ -55,6 +56,10 @@ doc = [
5556
"sphinx-jinja==2.0.2",
5657
"sphinx-notfound-page==1.1.0",
5758
]
59+
changelog = [
60+
"PyYAML==6.0.2",
61+
"sphinx-design==0.6.1",
62+
]
5863

5964
[project.entry-points."sphinx.html_themes"]
6065
ansys_sphinx_theme = "ansys_sphinx_theme"
@@ -122,7 +127,7 @@ directory = "doc/changelog.d"
122127
filename = "doc/source/changelog.rst"
123128
template = "doc/changelog.d/changelog_template.jinja"
124129
start_string = ".. towncrier release notes start\n"
125-
title_format = "`{version} <https://github.com/ansys/ansys-sphinx-theme/releases/tag/v{version}>`_ - {project_date}"
130+
title_format = "`{version} <https://github.com/ansys/ansys-sphinx-theme/releases/tag/v{version}>`_ ({project_date})"
126131
issue_format = "`#{issue} <https://github.com/ansys/ansys-sphinx-theme/pull/{issue}>`_"
127132

128133
[[tool.towncrier.type]]

0 commit comments

Comments
 (0)