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: add whatsnew options #583

Merged
merged 95 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
7ebb547
fix: add code
Revathyvenugopal162 Oct 15, 2024
4bdd038
fix: update the html files
Revathyvenugopal162 Oct 15, 2024
9873691
fix: update the events
Revathyvenugopal162 Oct 15, 2024
307315f
fix: update the styles
Revathyvenugopal162 Oct 15, 2024
1b1fd86
fix: update
Revathyvenugopal162 Oct 15, 2024
4f61280
fix: update the styles
Revathyvenugopal162 Oct 29, 2024
d56e39e
fix: update the styles
Revathyvenugopal162 Oct 29, 2024
9450df6
Merge branch 'main' into fix/whatsnew
Revathyvenugopal162 Oct 31, 2024
1534c65
chore: adding changelog file 574.miscellaneous.md [dependabot-skip]
pyansys-ci-bot Oct 31, 2024
e9cd3b7
Merge branch 'main' into fix/whatsnew
Revathyvenugopal162 Oct 31, 2024
3e555eb
test: whatsnew
Revathyvenugopal162 Nov 4, 2024
0a7ea4f
fix: testing
Revathyvenugopal162 Nov 4, 2024
97b05ce
fix more template
Revathyvenugopal162 Nov 5, 2024
e53147a
fix: add whatsnew
Revathyvenugopal162 Nov 7, 2024
17a853b
fix: add the release notes
Revathyvenugopal162 Nov 7, 2024
7272126
fix: spacing
Revathyvenugopal162 Nov 7, 2024
123ad83
Merge branch 'main' into fix/whatsnew
Revathyvenugopal162 Nov 7, 2024
f93e3f0
Merge branch 'fix/whatsnew' into fix/jinja-template-testing
Revathyvenugopal162 Nov 7, 2024
3a53b08
fix: whatsnew
Revathyvenugopal162 Nov 7, 2024
282c04c
chore: adding changelog file 583.documentation.md [dependabot-skip]
pyansys-ci-bot Nov 7, 2024
0db35d3
fix: vale
Revathyvenugopal162 Nov 7, 2024
8aa794c
Merge branch 'fix/jinja-template-testing' of https://github.com/ansys…
Revathyvenugopal162 Nov 7, 2024
302efaa
fix: vale
Revathyvenugopal162 Nov 7, 2024
24efa32
fix: header levels
Revathyvenugopal162 Nov 12, 2024
968d0c2
Merge branch 'main' into fix/jinja-template-testing
Revathyvenugopal162 Nov 13, 2024
4b587e2
fix: test with style
Revathyvenugopal162 Nov 13, 2024
9428fa9
fix: add templates
Revathyvenugopal162 Nov 13, 2024
c7dfd61
Merge branch 'fix/jinja-template-testing' of https://github.com/ansys…
Revathyvenugopal162 Nov 13, 2024
7bc10be
fix: cleanup the code
Revathyvenugopal162 Nov 15, 2024
6a1333b
Merge branch 'main' into fix/jinja-template-testing
Revathyvenugopal162 Nov 15, 2024
3ba40c1
fix: checkout the repo
Revathyvenugopal162 Nov 15, 2024
ed58f53
Merge branch 'fix/jinja-template-testing' of https://github.com/ansys…
Revathyvenugopal162 Nov 15, 2024
0659f57
chore: adding changelog file 583.documentation.md [dependabot-skip]
pyansys-ci-bot Nov 15, 2024
67d4468
Update pyproject.toml
Revathyvenugopal162 Nov 15, 2024
b0b9d5c
Apply suggestions from code review
Revathyvenugopal162 Nov 18, 2024
e942c61
fix: update templates and remove releasenote.rst
Revathyvenugopal162 Nov 18, 2024
e8b8d60
Merge branch 'fix/jinja-template-testing' of https://github.com/ansys…
Revathyvenugopal162 Nov 18, 2024
a598183
fix: update underline
Revathyvenugopal162 Nov 18, 2024
122c850
fix: rename whatsnew_contents o whatsnew
Revathyvenugopal162 Nov 18, 2024
a9951a2
Merge branch 'main' into fix/jinja-template-testing
Revathyvenugopal162 Dec 6, 2024
c01c80d
feat: update the template
Revathyvenugopal162 Dec 11, 2024
5bb7efa
only change changelog format in template & parse docs in __init__ file
klmcadams Dec 16, 2024
3398094
clean up code
klmcadams Dec 16, 2024
0bb5cd3
add whatsnew.yml
klmcadams Dec 17, 2024
a492272
fix: add the doctree read
Revathyvenugopal162 Dec 17, 2024
5037b72
Merge branch 'fix/jinja-template-testing' of https://github.com/ansys…
Revathyvenugopal162 Dec 17, 2024
3323868
add minor version section titles
klmcadams Dec 17, 2024
cb62c4a
add what's new sections under corresponding minor versions
klmcadams Dec 17, 2024
e40315b
add dropdowns to whatsnew sections
klmcadams Dec 19, 2024
819adcd
literal block testing
klmcadams Dec 20, 2024
ce304bb
add code blocks to whatsnew dropdowns
klmcadams Jan 6, 2025
34e4e57
create separate function for code block generation & fix loop
klmcadams Jan 7, 2025
f603187
fix next(iterator) issue and rename function
klmcadams Jan 10, 2025
8c397e9
adjust code block and paragraph generation & update whatsnew.yml file
klmcadams Jan 14, 2025
ddaa4dc
handle all paragraph lines within fill_paragraph and update whatsnew.yml
klmcadams Jan 14, 2025
427f728
add comments and docstrings to functions
klmcadams Jan 14, 2025
ac518b6
add example strings for code that could be confusing
klmcadams Jan 14, 2025
f1ccdeb
add line specifying which version the fragment is available in
klmcadams Jan 14, 2025
1448b4a
Merge branch 'main' into fix/jinja-template-testing
klmcadams Jan 15, 2025
ab2bc8a
add PyYAML dependency to doc & changelog
klmcadams Jan 15, 2025
dc89dc6
chore: adding changelog file 583.miscellaneous.md [dependabot-skip]
pyansys-ci-bot Jan 15, 2025
d9373ee
update init header and fix link in whatsnew.yml
klmcadams Jan 15, 2025
2a627e6
adjust what's new sidebar
klmcadams Jan 16, 2025
2ab588a
fix license file?
klmcadams Jan 16, 2025
6114083
Merge branch 'main' into fix/jinja-template-testing
Revathyvenugopal162 Jan 17, 2025
01a24b5
fix: change the sidebar
Revathyvenugopal162 Jan 17, 2025
1a519e9
parse version sections more concisely
klmcadams Jan 17, 2025
b24c784
Add documentation for the what's new option
klmcadams Jan 20, 2025
4d795b4
fix doc build errors?
klmcadams Jan 20, 2025
ac9232a
skip whatsnew functions if section dne in conf.py
klmcadams Jan 20, 2025
df70429
don't filter number of content in what's new sidebar by default
klmcadams Jan 21, 2025
e58455f
check if assets is defined
klmcadams Jan 21, 2025
dadd212
check if page_assets are defined
klmcadams Jan 21, 2025
150b3f3
move changelog jinja template changes to other PR
klmcadams Jan 21, 2025
0ad5d33
remove whatsnew.yml
klmcadams Jan 21, 2025
ec2a109
don't lstrip lines within dictionary curly brackets
klmcadams Jan 21, 2025
f360156
require whatsnew & changelog file names and sidebar pages
klmcadams Jan 21, 2025
4116691
take local path for changelog & whatsnew files
klmcadams Jan 21, 2025
f0ab9e5
remove whatsnew config from conf.py
klmcadams Jan 21, 2025
c752b7f
fix adding whatsnew sidebar
klmcadams Jan 21, 2025
536f014
execute functions if whatsnew options exist in conf.py
klmcadams Jan 22, 2025
0284e84
chore: adding changelog file 583.maintenance.md [dependabot-skip]
pyansys-ci-bot Jan 22, 2025
8a9288d
add docstrings to functions
klmcadams Jan 22, 2025
9910f35
Merge branch 'fix/jinja-template-testing' of https://github.com/ansys…
klmcadams Jan 22, 2025
73cb5f5
add .gitattributes file
klmcadams Jan 27, 2025
7b0afff
try to fix line endings in conf.py
klmcadams Jan 27, 2025
151c8c0
fix line endings in __init__ file
klmcadams Jan 27, 2025
548f25f
apply suggestion
klmcadams Jan 27, 2025
d3e5aa7
Merge branch 'main' into fix/jinja-template-testing
RobPasMue Feb 4, 2025
db69b3e
chore: adding changelog file 583.documentation.md [dependabot-skip]
pyansys-ci-bot Feb 4, 2025
4f0b8c9
chore: adding changelog file 583.maintenance.md [dependabot-skip]
pyansys-ci-bot Feb 4, 2025
7ea6046
Merge branch 'main' into fix/jinja-template-testing
Revathyvenugopal162 Feb 4, 2025
164c16f
chore: adding changelog file 583.documentation.md [dependabot-skip]
pyansys-ci-bot Feb 4, 2025
92f8dc4
fix: default value
Revathyvenugopal162 Feb 5, 2025
5945f81
remove None from get
klmcadams Feb 5, 2025
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
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
* text=auto !eol
*.sh eol=lf
*.bat eol=crlf
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]
jorgepiloto marked this conversation as resolved.
Show resolved Hide resolved

- uses: ansys/actions/doc-changelog@v8
if: ${{ github.event_name == 'pull_request' }}
with:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ repos:
- id: check-github-workflows

- repo: https://github.com/ansys/pre-commit-hooks
rev: v0.4.4
rev: v0.5.1
hooks:
- id: add-license-headers
files: '(src|doc/source/examples)/.*\.(py)'
Expand Down
1 change: 1 addition & 0 deletions doc/changelog.d/583.documentation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
feat: add whatsnew options
34 changes: 17 additions & 17 deletions doc/changelog.d/changelog_template.jinja
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{% if sections[""] %}
{% for category, val in definitions.items() if category in sections[""] %}

{{ definitions[category]['name'] }}
{% set underline = '^' * definitions[category]['name']|length %}
{{ underline }}

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

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


{% endif %}
{% if sections[""] %}
{% for category, val in definitions.items() if category in sections[""] %}
{{ definitions[category]['name'] }}
{% set underline = '^' * definitions[category]['name']|length %}
{{ underline }}
{% for text, values in sections[""][category].items() %}
- {{ text }} {{ values|join(', ') }}
{% endfor %}
{% endfor %}
{% else %}
No significant changes.
{% endif %}
Binary file added doc/source/_static/whatsnew_section.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/source/_static/whatsnew_sidebar.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 1 addition & 2 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

.. _ref_release_notes:

Release notes
#############

This document contains the release notes for the project.

.. vale off

.. towncrier release notes start
Expand Down
88 changes: 88 additions & 0 deletions doc/source/user-guide/options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,91 @@
To use this feature, you must have the `quarto <https://quarto.org/>` package installed. To create thumbnails of generated PDF files,
the theme is using `pdf2image`. So you should have the ``poppler`` package installed in your system.
For more information, see the `pdf2image documentation <https://pypi.org/project/pdf2image/>`_.

What's new section
------------------

The "What's new" section is an option that allows you to highlight new features in your library
for each minor version within the changelog file.

To get started, create a YAML file named ``whatsnew.yml`` in the ``doc/source`` directory. The
YAML file should contain the following structure:

.. code-block:: yaml

fragments:
- title: Feature title
version: 0.2.0 # The version the feature is introduced
content: |
Feature description in RST format.

- title: Another feature title
version: 0.1.2
content: |
Feature description in RST format.

The dropdown generation only supports the following RST formats in the "content" field:

- Bold: Use double asterisks to wrap the text.
- Italics: Use single asterisks to wrap the text.
- Code samples: Use single or double backticks to wrap the text.
- Links: Use the following format to include links:

.. code-block:: rst

`link text <https://www.example.com>`_

- Code blocks: Use the following format to include code blocks:

.. code-block:: rst

.. code:: python

print("hello world")

If a format is used in the "content" field that does not fall into the categories above, it will not

Check warning on line 301 in doc/source/user-guide/options.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/user-guide/options.rst#L301

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "doc/source/user-guide/options.rst", "range": {"start": {"line": 301, "column": 93}}}, "severity": "WARNING"}
be rendered correctly.

To enable the "What's new" sections and sidebar in the changelog file, add the following dictionary
to the ``html_theme_options`` dictionary:

.. code-block:: python

html_theme_options = (
{
"whatsnew": {
"whatsnew_file_path": "changelog.d/whatsnew.yml",
"changelog_file_path": "changelog.rst",
"sidebar_pages": ["changelog"],
"sidebar_no_of_headers": 3, # Optional
"sidebar_no_of_contents": 3, # Optional
},
},
)

The dictionary contains the following keys:

- ``whatsnew_file_path``: The path to the YAML file containing what's new content local to the
``doc/source`` directory. If not provided, the what's new section will not be generated.

Check warning on line 324 in doc/source/user-guide/options.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/user-guide/options.rst#L324

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "doc/source/user-guide/options.rst", "range": {"start": {"line": 324, "column": 69}}}, "severity": "WARNING"}
- ``changelog_file_path``: The path to the changelog.rst file local to the ``doc/source``
directory. If not provided, the what's new section will not be generated.

Check warning on line 326 in doc/source/user-guide/options.rst

View workflow job for this annotation

GitHub Actions / vale

[vale] doc/source/user-guide/options.rst#L326

[Google.Will] Avoid using 'will'.
Raw output
{"message": "[Google.Will] Avoid using 'will'.", "location": {"path": "doc/source/user-guide/options.rst", "range": {"start": {"line": 326, "column": 54}}}, "severity": "WARNING"}
- ``sidebar_pages``: List of names for the pages to include the what's new sidebar on. If not
provided, the what's new sidebar is not displayed.
- ``sidebar_no_of_headers``: Number of minor version sections to display in the what's new sidebar.
By default, it displays three version sections in the sidebar.
- ``sidebar_no_of_contents``: Number of what's new content to display under each minor version in the
what's new sidebar. If not provided, it displays all dropdowns by default.

The following images show a sample "What's new" section and sidebar in the changelog file:

.. tab-set::

.. tab-item:: What's new section

.. image:: ../_static/whatsnew_section.png
:alt: What's new section

.. tab-item:: What's new sidebar

.. image:: ../_static/whatsnew_sidebar.png
:alt: What's new sidebar
7 changes: 6 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ doc = [
"Pillow>=9.0",
"PyGitHub==2.5.0",
"pyvista[jupyter]==0.44.2",
"PyYAML==6.0.2",
"requests==2.32.3",
"Sphinx==8.1.3",
"sphinx-autoapi==3.4.0",
Expand All @@ -55,6 +56,10 @@ doc = [
"sphinx-jinja==2.0.2",
"sphinx-notfound-page==1.1.0",
]
changelog = [
"PyYAML==6.0.2",
"sphinx-design==0.6.1",
]

[project.entry-points."sphinx.html_themes"]
ansys_sphinx_theme = "ansys_sphinx_theme"
Expand Down Expand Up @@ -122,7 +127,7 @@ directory = "doc/changelog.d"
filename = "doc/source/changelog.rst"
template = "doc/changelog.d/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}"
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}>`_"

[[tool.towncrier.type]]
Expand Down
Loading