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

Need a way to set the order of fragments #437

Closed
hynek opened this issue Sep 28, 2022 · 1 comment · Fixed by #438
Closed

Need a way to set the order of fragments #437

hynek opened this issue Sep 28, 2022 · 1 comment · Fixed by #438

Comments

@hynek
Copy link
Member

hynek commented Sep 28, 2022

The new way of defining custom fragments uses a dictionary that is unfortunately sorted alphabetically by tomli.

For example this is from my Markdown tutorial in #436:

{'tool': {'towncrier': {'directory': 'changelog.d',
                        'filename': 'CHANGELOG.md',
                        'fragment': {'added': {'name': 'Added'},
                                     'changed': {'name': 'Changed'},
                                     'deprecated': {'name': 'Deprecated'},
                                     'fixed': {'name': 'Fixed'},
                                     'removed': {'name': 'Removed'},
                                     'security': {'name': 'Security'}},
                        'issue_format': '[#{issue}](https://github.com/twisted/my-project/issues/{issue})',
                        'start_string': '<!-- towncrier release notes start '
                                        '-->\n',
                        'template': 'changelog.d/changelog_template.jinja',
                        'title_format': '## '
                                        '[{version}](https://github.com/twisted/my-project/tree/{version}) '
                                        '- {project_date}',
                        'underlines': ['', '', '']}}}

The fragment types are defined as:

[tool.towncrier.fragment.security]
name = "Security"

[tool.towncrier.fragment.removed]
name = "Removed"

[tool.towncrier.fragment.deprecated]
name = "Deprecated"

[tool.towncrier.fragment.added]
name = "Added"

[tool.towncrier.fragment.changed]
name = "Changed"

[tool.towncrier.fragment.fixed]
name = "Fixed"

In hindsight, it's unfortunate we've switched away from using a list for that but it is what it is.

I can think of two way to solve this:

  1. add an order key to the fragments:
[tool.towncrier.fragment.security]
name = "Security"
order = 1

[tool.towncrier.fragment.removed]
name = "Removed"
order = 2
  1. add an option:
[tool.towncrier]
category_order = ["security", "removed", "..."]

I think I prefer option 2, because you don't have to re-number all entries if you change the order.

The question is what would happen if a catefory is missing – I would suggest an error.

@hynek
Copy link
Member Author

hynek commented Sep 28, 2022

Looks like this is a fairly new change in #370 – I wonder if we should just un-deprecate it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant