1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Merge pull request #10580 from pradyunsg/better-towncrier-template

Improve our towncrier template, to do the right thing after releases
This commit is contained in:
Pradyun Gedam 2021-10-15 18:31:10 +01:00 committed by GitHub
commit bf71afc143
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 34 deletions

View file

@ -7,6 +7,6 @@ Changelog
Major and minor releases of pip also include changes listed within Major and minor releases of pip also include changes listed within
prior beta releases. prior beta releases.
.. towncrier-draft-entries:: |release|, unreleased as on .. towncrier-draft-entries:: Not yet released
.. pip-news-include:: ../../NEWS.rst .. pip-news-include:: ../../NEWS.rst

View file

@ -3,13 +3,19 @@ requires = ["setuptools", "wheel"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[tool.towncrier] [tool.towncrier]
# For finding the __version__
package = "pip" package = "pip"
package_dir = "src" package_dir = "src"
# For writing into the correct file
filename = "NEWS.rst" filename = "NEWS.rst"
# For finding the news fragments
directory = "news/" directory = "news/"
title_format = "{version} ({project_date})"
# For rendering properly for this project
issue_format = "`#{issue} <https://github.com/pypa/pip/issues/{issue}>`_" issue_format = "`#{issue} <https://github.com/pypa/pip/issues/{issue}>`_"
template = "tools/news/template.rst" template = "tools/news/template.rst"
# Grouping of entries, within our changelog
type = [ type = [
{ name = "Process", directory = "process", showcontent = true }, { name = "Process", directory = "process", showcontent = true },
{ name = "Deprecations and Removals", directory = "removal", showcontent = true }, { name = "Deprecations and Removals", directory = "removal", showcontent = true },

View file

@ -1,41 +1,46 @@
{% set underline = "=" %} {# This is a heavily customised version of towncrier's default template. #}
{{ underline * ((top_line)|length) }} {#-
{% for section in sections %} Only render if there's any changes to show.
{% set underline = "-" %}
{% if section %}
{{ section }}
{{ underline * section|length }}{% set underline = "~" %}
{% endif %} This serves as a compatibility "hack" since we render unreleased news entries
{% if sections[section] %} in our changelog with ``sphinxcontrib.towncrier``; which triggers a render even
{% for category, val in definitions.items() if category in sections[section] and category != 'trivial' %} when there's no entries to be rendered.
#}
{% if sections[''] %}
{{ definitions[category]['name'] }} {#- Heading for individual version #}
{{ underline * definitions[category]['name']|length }} {{ versiondata.version }} ({{ versiondata.date }})
{{ top_underline * ((versiondata.version + versiondata.date)|length + 3) }}
{% if definitions[category]['showcontent'] %} {#
{% for text, values in sections[section][category]|dictsort(by='value') %}
- {{ text }}{% if category != 'vendor' and category != 'process' %} ({{ values|sort|join(', ') }}){% endif %}
The following loop will run exactly once, with ``section_name == ""``.
This is due to the undocumented "sections" feature in towncrier.
See https://github.com/twisted/towncrier/issues/61.
We don't use this feature, and this template doesn't render the section
heading for that reason.
#}
{% for section_name, entries_by_type in sections.items() -%}
{# Only show types with entries and ``showcontent = true``, using the order from pyproject.toml #}
{% for type_ in definitions if (sections[section_name][type_] and definitions[type_]['showcontent']) %}
{# Heading for individual types #}
{{ definitions[type_]['name'] }}
{{ underlines[0] * definitions[type_]['name']|length }}
{# This is the loop that generates individual entries #}
{% for message, issue_reference in sections[section_name][type_]|dictsort(by='value') %}
- {{ message }}
{%- if type_ not in ["vendor", "process"] %} ({{ issue_reference|sort|join(', ') }}){% endif %}
{% endfor %} {% endfor %}
{% else %} {% else %}
- {{ sections[section][category]['']|sort|join(', ') }} {# We only have entries where the type has ``showcontent = true``. #}
{% endif %}
{% if sections[section][category]|length == 0 %}
No significant changes. No significant changes.
{% endfor -%}
{% else %} {% endfor -%}
{% endif %} {% endif -%}
{% endfor %}
{% else %}
No significant changes.
{% endif %}
{% endfor %}