#changelog #keep-a-changelog #serialization #deserialize #semver

keep_a_changelog_file

Read and write changelog files using the Keep a Changelog format

1 unstable release

0.1.0 Jun 26, 2024

#1525 in Parser implementations

Download history 39/week @ 2024-07-22 33/week @ 2024-07-29 8/week @ 2024-08-05 46/week @ 2024-08-12 31/week @ 2024-08-19 106/week @ 2024-08-26 20/week @ 2024-09-02 1/week @ 2024-09-09 115/week @ 2024-09-16 87/week @ 2024-09-23 13/week @ 2024-09-30 9/week @ 2024-10-07 124/week @ 2024-10-14 104/week @ 2024-10-21 22/week @ 2024-10-28 15/week @ 2024-11-04

265 downloads per month

Apache-2.0

71KB
1.5K SLoC

Keep a Changelog File

Build Status MSRV

A serializer and deserializer for changelog files written in Keep a Changelog format.

Install

cargo add keep_a_changelog_file

Usage

use keep_a_changelog_file::{Changelog, ChangeGroup, PromoteOptions, ReleaseLink, ReleaseVersion};

fn example_usage() {
    // parse a changelog
    let mut changelog: Changelog = "\
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]"
        .parse()
        .unwrap();

    // modify the unreleased section
    changelog
        .unreleased
        .add(ChangeGroup::Fixed, "Fixed bug in feature X");
    changelog.unreleased.add(
        ChangeGroup::Deprecated,
        "Feature Y will be removed from the next major release",
    );

    // promote the unreleased changes to a new release
    let release_version = "0.0.1".parse::<ReleaseVersion>().unwrap();
    let release_link = "https://github.com/my-org/my-project/releases/v0.0.1"
        .parse::<ReleaseLink>()
        .unwrap();
    changelog
        .promote_unreleased(&PromoteOptions::new(release_version).with_link(release_link))
        .unwrap();

    // output the changelog
    println!("{changelog}");
}

Dependencies

~5.5–7.5MB
~137K SLoC