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

Section aware create #603

Merged
merged 14 commits into from
Jun 13, 2024
Merged

Conversation

SmileyChris
Copy link
Contributor

@SmileyChris SmileyChris commented May 23, 2024

Description

towncrier create should work better with sections if defined in the configuration file.

This adds a new towncrier create --section <section name> option, or if you're using the new interactive create then you'll be asked for the section if there are multiple ones defined in your config:

$ towncrier create --content "Sections!"
Pick a section
 1. Backend
 2. Frontend
Section (1, 2) [1]: 2
Issue number (`+` for none): 603
Fragment type (feature, bugfix, doc, removal, misc): feature
Created news fragment at /home/chris/demo/changes/frontend/603.feature.rst

If you use sections and none have an empty path, you must now specify the section when creating a new news fragment (if one does have an empty path, that section will be used by default).

This PR also deduplicates the code that determines the base fragment path which was done in three places!

Checklist

  • Make sure changes are covered by existing or new tests.
  • For at least one Python version, make sure local test run is green.
  • Create a file in src/towncrier/newsfragments/. Describe your
    change and include important information. Your change will be included in the public release notes.
  • Make sure all GitHub Actions checks are green (they are automatically checking all of the above).
  • Ensure docs/tutorial.rst is still up-to-date.
  • If you add new CLI arguments (or change the meaning of existing ones), make sure docs/cli.rst reflects those changes.
  • If you add new configuration options (or change the meaning of existing ones), make sure docs/configuration.rst reflects those changes.

@SmileyChris SmileyChris requested a review from a team as a code owner May 23, 2024 23:31
@adiroiban
Copy link
Member

Thanks for the PR.
I am not using the create command, so there is not much UI/UX feedback I can provide.

As long as you are happy with the behaviour, we can merge it.


I am tring to understand what "sections" is in the context of towncrier.

I am reading something about it here https://towncrier.readthedocs.io/en/latest/configuration.html#sections

Especially the part from Section Path Behaviour is confusing.

I think that it needs better example.

For example

If directory is not set, “newsfragments” is added to the end of each path. For example, with the above sections, the paths would be:

Which directory , I guess that this is [tool.towncrier] -> directory

Are people using this behaviour ?

To me, this all seems very confusing.

Copy link
Member

@adiroiban adiroiban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Many thanks for the PR. It looks very good.

I left an initial round of feedback.

I have never used the create command .

Also, for my privarte project, I am not using the "section" functionality.

I know that "sections" are used in twisted/twisted without a path ... and that's all my experience with it.

In twisted/twisted there is a single section without a path.

https://github.com/twisted/twisted/blob/c465c460c68bec3cf481c2815d1039da6796eb03/pyproject.toml#L215-L245

The major concert is the backward incompatible change for the create CLI

I don't know why you would want multiple sections without a path.... so maybe this is not a big deal, and it's ok to have the current behaviour.

I would still document this as .removal.

docs/cli.rst Outdated Show resolved Hide resolved
src/towncrier/_builder.py Show resolved Hide resolved
@@ -53,6 +55,35 @@ def parse_newfragment_basename(
return invalid


class FragmentsPath:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this expected to be public API?

I can do something like this: from towncrier.create import FragmentsPath

src/towncrier/create.py Outdated Show resolved Hide resolved
src/towncrier/newsfragments/603.feature.rst Outdated Show resolved Hide resolved
src/towncrier/test/test_create.py Show resolved Hide resolved
Copy link
Member

@adiroiban adiroiban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks all good. I saw the auto-merge, so I hope this will be merged.

@SmileyChris SmileyChris merged commit e3e73bd into twisted:trunk Jun 13, 2024
16 checks passed
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 this pull request may close these issues.

2 participants