A very simplistic changelog parser/updater
Project description
parse-changelog
This is a simplified changelog updater/parser, made for CI pipeline use. It has these abilities:
- Add a new change to the changelog, in the Unreleased section
- Add a new release into the changelog, using the list of changes from the Unreleased section
- Parse the releases in the changelog into a JSON structure.
Changelogs must be in the format documented by Keep a Changelog, see the details below.
Release history: parse-changelog's CHANGELOG
Adding a Release
This mode is invoked by using the --release
arg and will parse the changelog and insert a new release at the beginning
of the list of releases, using the changes from the Unreleased section. You can optionally specify a release date, or by
default use todays date.
The changelog must use the format ## [Unreleased]
(case insensitive) for this parser to find it.
For example, here is the diff generated by adding a new release(--release 1.0.2
):
## [Unreleased]
+
+## [1.0.2] - 2022-10-20
* Great new stuff
## [1.0.1] - 2022-10-08
Adding a Change
This mode is invoked with the --add-change
and --type
args. It will parse the changelog to find the Unreleased
section and any changes already there, find the correct change type heading, and add the new change.
For example, here is the diff generated by adding a new fix (--add-change "Fix that annoying bug" --type fixed
):
## [Unreleased]
* Great new stuff
+### Fixed
+* Fix that annoying bug
## [1.0.1] - 2022-10-08
Changelog Parsing
This mode will parse the changelog into JSON and print it to the screen. It finds all of
the heading2 entries (lines starting with ##
) and assumes each of those is a release. For each release, it parses
the release title into version and date, and collects the content of the release as a single string. Each release
heading must be of the format ## [release_version] - YYYY-MM-DD
, where release_version
matches SemVer version string
spec, and YYYY-MM-DD
is a valid year-month-day. The one exception to this format is the special release heading for
unreleased changes, which must match ## [Unreleased]
. The content of the release is parsed as a single string and not
interpreted in any way.
The top heading1 and project description are parsed into a special section named "introduction".
For example, given the following changelog:
# Changelog
My Project Name
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.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
* Great new stuff
## [1.0.1] - 2022-10-08
### Fixed
* Minor bug that we missed
### Changed
* New name for an artifact
## [1.0.0] - 2022-09-01
Initial release
* Some cool feature
* Other interesting stuff
It will be parsed into this JSON:
{
"introduction": {
"title": "Changelog",
"content": "\nMy Project Name\n\nAll notable changes to this project will be documented in this file.\n\nThe format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),\nand this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).",
"version": "",
"date": ""
},
"prerelease": {
"title": "[Unreleased]",
"content": "* Great new stuff",
"version": "prerelease",
"date": "unreleased"
},
"[1.0.1] - 2022-10-08": {
"title": "[1.0.1] - 2022-10-08",
"content": "### Fixed\n* Minor bug that we missed\n### Changed\n* New name for an artifact",
"version": "1.0.1",
"date": "2022-10-08"
},
"[1.0.0] - 2022-09-01": {
"title": "[1.0.0] - 2022-09-01",
"content": "Initial release\n* Some cool feature\n* Other interesting stuff",
"version": "1.0.0",
"date": "2022-09-01"
}
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file parse-changelog-1.0.8.tar.gz
.
File metadata
- Download URL: parse-changelog-1.0.8.tar.gz
- Upload date:
- Size: 6.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5477f1ed985c36b9b64eeda66c48568254f1dc88b5d78bd5880b511e1db6b9c0 |
|
MD5 | c2a58f8dc5f051a52f2e49ec77e719e9 |
|
BLAKE2b-256 | e3b277e3b3776e57ce59584be1e97a3b71111ebe1e54e72dc85f7914b2132d3c |
File details
Details for the file parse_changelog-1.0.8-py2.py3-none-any.whl
.
File metadata
- Download URL: parse_changelog-1.0.8-py2.py3-none-any.whl
- Upload date:
- Size: 6.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/4.0.2 CPython/3.11.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5462295948d293c5ca483e7800173d40e4a9c540fec8c787169e9b7b6b3ef6f4 |
|
MD5 | 3a244a8c71eb7796479e994fa2637572 |
|
BLAKE2b-256 | 62ccb0214a831ab96c9426bbb0acdfbd9219ce4f6491154acd01f68beee0fa8c |