Presubmit.Changelog (presubmit v0.2.2)

Copy Markdown View Source

Reads a Markdown changelog as a list of sections keyed by heading.

Any ## heading starts a section. Version headings are matched leniently: ## 1.2.0, ## v1.2.0, ## [1.2.0], and ## 1.2.0 - 2026-01-01 all name version 1.2.0. The unreleased section is any heading that contains "unreleased" case-insensitively.

Summary

Functions

Parses changelog text into sections.

The section for version, if any.

Sections of the changelog at path, or [] if absent.

The unreleased section, if any.

Types

section()

@type section() :: %{heading: String.t(), version: String.t() | nil, body: String.t()}

Functions

parse(text)

@spec parse(String.t()) :: [section()]

Parses changelog text into sections.

section_for(tree, version, path \\ "CHANGELOG.md")

@spec section_for(Presubmit.Tree.t(), String.t(), String.t()) :: section() | nil

The section for version, if any.

sections(tree, path \\ "CHANGELOG.md")

@spec sections(Presubmit.Tree.t(), String.t()) :: [section()]

Sections of the changelog at path, or [] if absent.

unreleased(tree, path \\ "CHANGELOG.md")

@spec unreleased(Presubmit.Tree.t(), String.t()) :: section() | nil

The unreleased section, if any.