Skip to content

Commit

Permalink
Adds towncrier and giles config (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cadair authored Dec 6, 2024
2 parents d7e01fd + d0c12e5 commit 3737aa3
Show file tree
Hide file tree
Showing 7 changed files with 120 additions and 0 deletions.
Empty file.
34 changes: 34 additions & 0 deletions {{ cookiecutter.package_name }}/changelog/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
=========
Changelog
=========

.. note::

This README was adapted from the pytest changelog readme under the terms of the MIT licence.

This directory contains "news fragments" which are short files that contain a small **ReST**-formatted text that will be added to the next ``CHANGELOG``.

The ``CHANGELOG`` will be read by users, so this description should be aimed at SunPy users instead of describing internal changes which are only relevant to the developers.

Make sure to use full sentences with correct case and punctuation, for example::

Add support for Helioprojective coordinates in `sunpy.coordinates.frames`.

Please try to use Sphinx intersphinx using backticks.

Each file should be named like ``<PULL REQUEST>.<TYPE>[.<COUNTER>].rst``, where ``<PULL REQUEST>`` is a pull request number, ``COUNTER`` is an optional number if a PR needs multiple entries with the same type and ``<TYPE>`` is one of:

* ``breaking``: A change which requires users to change code and is not backwards compatible. (Not to be used for removal of deprecated features.)
* ``feature``: New user facing features and any new behavior.
* ``bugfix``: Fixes a reported bug.
* ``doc``: Documentation addition or improvement, like rewording an entire session or adding missing docs.
* ``deprecation``: Feature deprecation
* ``removal``: Feature removal.
* ``trivial``: A change which has no user facing effect or is tiny change.

So for example: ``123.feature.rst``, ``456.bugfix.rst``.

If you are unsure what pull request type to use, don't hesitate to ask in your PR.

Note that the ``towncrier`` tool will automatically reflow your text, so it will work best if you stick to a single paragraph, but multiple sentences and links are OK and encouraged.
You can install ``towncrier`` and then run ``towncrier --draft`` if you want to get a preview of how your change will look in the final release notes.
1 change: 1 addition & 0 deletions {{ cookiecutter.package_name }}/docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"sphinx.ext.mathjax",
"sphinx_automodapi.automodapi",
"sphinx_automodapi.smart_resolver",
"sphinx_changelog",
]

# Add any paths that contain templates here, relative to this directory.
Expand Down
2 changes: 2 additions & 0 deletions {{ cookiecutter.package_name }}/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ This is the documentation for {{ cookiecutter.package_name }}.
:maxdepth: 2
:caption: Contents:

whatsnew/index

Indices and tables
==================

Expand Down
10 changes: 10 additions & 0 deletions {{ cookiecutter.package_name }}/docs/whatsnew/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.. _changelog:

**************
Full Changelog
**************

.. changelog::
:towncrier: ../../
:towncrier-skip-if-empty:
:changelog_file: ../../CHANGELOG.rst
12 changes: 12 additions & 0 deletions {{ cookiecutter.package_name }}/docs/whatsnew/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. _whatsnew:

***************
Release History
***************

This page documents the releases for {{ cookiecutter.package_name }}

.. toctree::
:maxdepth: 1

changelog
61 changes: 61 additions & 0 deletions {{ cookiecutter.package_name }}/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ tests = [
docs = [
"sphinx",
"sphinx-automodapi",
"sphinx-changelog",
"sunpy-sphinx-theme",
"packaging",
]
Expand Down Expand Up @@ -87,3 +88,63 @@ write_to = "{{ cookiecutter.module_name }}/_version.py"
{%- else -%}
write_to = "{{ cookiecutter.module_name }}/version.py"
{%- endif %}

[tool.gilesbot]
[tool.gilesbot.pull_requests]
enabled = true

[tool.gilesbot.towncrier_changelog]
enabled = true
verify_pr_number = true
changelog_skip_label = "No Changelog Entry Needed"
help_url = "https://github.com/{{ cookiecutter.github_repo | default('sunpy/sunpy') }}/blob/main/changelog/README.rst"

changelog_missing_long = "There isn't a changelog file in this pull request. Please add a changelog file to the `changelog/` directory following the instructions in the changelog [README](https://github.com/{{ cookiecutter.github_repo | default('sunpy/sunpy') }}/blob/main/changelog/README.rst)."

type_incorrect_long = "The changelog file you added is not one of the allowed types. Please use one of the types described in the changelog [README](https://github.com/{{ cookiecutter.github_repo | default('sunpy/sunpy') }}/blob/main/changelog/README.rst)"

number_incorrect_long = "The number in the changelog file you added does not match the number of this pull request. Please rename the file."

# TODO: This should be in towncrier.toml but Giles currently only works looks in
# pyproject.toml we should move this back when it's fixed.
[tool.towncrier]
package = "{{ cookiecutter.package_name }}"
filename = "CHANGELOG.rst"
directory = "changelog/"
issue_format = "`#{issue} https:github.com/{{ cookiecutter.github_repo | default('sunpy/sunpy') }}/changelog/pull/{issue}>`__"
title_format = "{version} ({project_date})"

[[tool.towncrier.type]]
directory = "breaking"
name = "Breaking Changes"
showcontent = true

[[tool.towncrier.type]]
directory = "deprecation"
name = "Deprecations"
showcontent = true

[[tool.towncrier.type]]
directory = "removal"
name = "Removals"
showcontent = true

[[tool.towncrier.type]]
directory = "feature"
name = "New Features"
showcontent = true

[[tool.towncrier.type]]
directory = "bugfix"
name = "Bug Fixes"
showcontent = true

[[tool.towncrier.type]]
directory = "doc"
name = "Documentation"
showcontent = true

[[tool.towncrier.type]]
directory = "trivial"
name = "Internal Changes"
showcontent = true

0 comments on commit 3737aa3

Please sign in to comment.