Skip to content

docs: changelog fragments in docs/changes, assembled into WHATS_NEW.md at release - #55

Merged
rkinas merged 1 commit into
rkinas:mainfrom
dkoryto:changelog-fragments
Nov 2, 2026
Merged

rkinas merged 1 commit into
rkinas:mainfrom
dkoryto:changelog-fragments

Conversation

@dkoryto

@dkoryto dkoryto commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Draft for #54: changelog fragments, so open pull requests stop conflicting on the first lines of docs/WHATS_NEW.md.

Change

  • docs/changes/README.md: how to write a fragment. A pull request adds docs/changes/<PR number>.md with the list items it would have added to WHATS_NEW.md.
  • scripts/changelog.py (stdlib only):
    • python scripts/changelog.py prints the next section from the fragments and writes nothing;
    • python scripts/changelog.py 2.4.2 puts # What is new in basal 2.4.2 with the fragments (in PR order) at the top of WHATS_NEW.md and removes them.
    • A misnamed or empty fragment, no fragments, or a version WHATS_NEW.md already has stop the script before anything is written.
  • tests/test_changelog.py: order, removal, the refusals, and a check that the repository's fragments are valid (so a bad fragment fails the tests).

WHATS_NEW.md itself is unchanged. The open PRs would move their entry into a fragment, for example #44's paragraph as docs/changes/44.md, word for word.

Validation

If you'd rather keep editing WHATS_NEW.md directly, close this; nothing else depends on it.

Summary by Sourcery

Introduce validated changelog fragments to avoid pull request conflicts in WHATS_NEW.md and assemble release notes at release time.

New Features:

  • Add a changelog fragment workflow that assembles pull request entries into versioned release-note sections.

Enhancements:

  • Document the fragment format and release process.
  • Provide validation for fragment naming, contents, ordering, duplicate releases, and safe release-note updates.

Documentation:

  • Document how contributors create changelog fragments and assemble them into WHATS_NEW.md.

Tests:

  • Add coverage for fragment ordering, removal, validation failures, duplicate versions, and repository fragment validity.

@sourcery-ai

sourcery-ai Bot commented Oct 26, 2026

Copy link
Copy Markdown

Reviewer's Guide

This PR replaces direct concurrent edits to WHATS_NEW.md with numbered changelog fragments, documented in docs/changes/README.md and assembled by a stdlib-only script. The script offers a read-only preview or validates and inserts a versioned section at release time, then removes consumed fragments; tests cover ordering, cleanup, refusal cases, and repository validation.

Sequence diagram for assembling release notes from changelog fragments

sequenceDiagram
    participant Maintainer
    participant Script as scripts/changelog.py
    participant Fragments as docs/changes
    participant Notes as docs/WHATS_NEW.md

    Maintainer->>Script: release(version)
    Script->>Fragments: fragments()
    Fragments-->>Script: numbered entries in PR order
    Script->>Notes: read_text()
    alt validation fails
        Script-->>Maintainer: SystemExit
    else valid release
        Script->>Notes: write_text(versioned section + existing notes)
        Script->>Fragments: unlink(fragment files)
        Script-->>Maintainer: section added, fragments removed
    end
Loading

Flow diagram for changelog preview and release modes

flowchart TD
    Start[Run scripts/changelog.py]
    Mode{Version argument provided?}
    Read[Read and validate numbered fragments]
    Preview[Print next release section]
    Release[Build versioned section]
    Check[Check fragments exist and version is absent]
    Write[Prepend section to WHATS_NEW.md]
    Remove[Remove consumed fragments]
    Stop[Stop without writing]

    Start --> Mode
    Mode -->|No| Read
    Read -->|Valid fragments| Preview
    Read -->|Invalid or none| Stop
    Mode -->|Yes| Read
    Read -->|Valid fragments| Release
    Release --> Check
    Check -->|Validation fails| Stop
    Check -->|Valid release| Write
    Write --> Remove
Loading

File-Level Changes

Change Details Files
Introduces a documented changelog-fragment workflow to avoid concurrent edits to the release notes file.
  • Defines the <PR number>.md fragment format and release workflow.
  • Adds the repository changes directory and README guidance.
docs/changes/README.md
Adds a standard-library release script that validates, previews, assembles, and removes changelog fragments.
  • Collects numeric fragments in PR-number order while ignoring README.md.
  • Rejects misnamed, empty, missing, or already-released inputs before modifying files.
  • Supports preview mode and versioned release insertion at the top of WHATS_NEW.md.
  • Removes consumed fragments after writing the assembled section.
scripts/changelog.py
Adds focused coverage for fragment ordering, release mutations, validation failures, and repository fragment validity.
  • Verifies ordered assembly and cleanup.
  • Checks that invalid, empty, duplicate-version, and fragment-free releases are refused without mutation.
  • Validates the checked-in fragments through the production parser.
tests/test_changelog.py

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@rkinas

rkinas commented Oct 28, 2026

Copy link
Copy Markdown
Owner

Thank you, Dariusz! We would like to take changelog fragments as the first change after 2.5.0 is published, so the 2.5 release notes are not restructured in the middle of the release. Keeping this open until then.

@rkinas
rkinas merged commit 3c8942c into rkinas:main Nov 2, 2026
rkinas added a commit that referenced this pull request Nov 2, 2026
… version

CONTRIBUTING.md credits the 2.5 pull requests as the release notes' community line lists them (Paweł Kiszczak
#52, #62, #64, #66, #68, #71, #73, #75; Marcin Brzeżański #56; Grzegorz Brzezinka #76, #78) and adds Dariusz
Koryto (#53, #58, #59, #60 and #55); the README's list names him too. docs/changes/README.md and the
changelog.py help use 2.5.1, the next release, as the example.
@rkinas

rkinas commented Nov 2, 2026

Copy link
Copy Markdown
Owner

Thank you, Dariusz: changelog fragments are in main (merged as you wrote them, 72b9381), the first change after 2.5.0 as promised on #54. From now on each pull request adds its entry as docs/changes/<PR>.md; we also moved the 2.5.1 example version into the docs and shortened the README, which now links to WHATS_NEW.md for the full notes.

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