Package: keepachangelog
Manipulate keep a changelog filesConvert to dictRelease a new versionAdd changelog retrieval REST API endpointStarletteFlask-RestXConvert changelog to dictConvert changelog markdown file followingkeep a changelogformat into python dict.importkeepachangelogchanges=keepachangelog.to_dict("path/to/CHANGELOG.md")changeswould look like:changes={"1.1.0":{"changed":["Enhancement 1 (1.1.0)","sub enhancement 1","sub enhancement 2","Enhancement 2 (1.1.0)",],"release_date":"2018-05-31","version":"1.1.0","semantic_version":{"major":1,"minor":1,"patch":0,"prerelease":None,"buildmetadata":None,},"url":"https://github.test_url/test_project/compare/v1.0.1...v1.1.0",},"1.0.1":{"fixed":["Bug fix 1 (1.0.1)","sub bug 1","sub bug 2","Bug fix 2 (1.0.1)",],"release_date":"2018-05-31","version":"1.0.1","semantic_version":{"major":1,"minor":0,"patch":1,"prerelease":None,"buildmetadata":None,},"url":"https://github.test_url/test_project/compare/v1.0.0...v1.0.1",},"1.0.0":{"deprecated":["Known issue 1 (1.0.0)","Known issue 2 (1.0.0)"],"release_date":"2017-04-10","version":"1.0.0","semantic_version":{"major":1,"minor":0,"patch":0,"prerelease":None,"buildmetadata":None,},"url":"https://github.test_url/test_project/releases/tag/v1.0.0",},}For a markdown file with the following content:# ChangelogAll 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]### Changed-Release note 1.-Release note 2.### Added-Enhancement 1-sub enhancement 1-sub enhancement 2-Enhancement 2### Fixed-Bug fix 1-sub bug 1-sub bug 2-Bug fix 2### Security-Known issue 1-Known issue 2### Deprecated-Deprecated feature 1-Future removal 2### Removed-Deprecated feature 2-Future removal 1## [1.1.0] - 2018-05-31### Changed-Enhancement 1 (1.1.0)-sub enhancement 1-sub enhancement 2-Enhancement 2 (1.1.0)## [1.0.1] - 2018-05-31### Fixed-Bug fix 1 (1.0.1)-sub bug 1-sub bug 2-Bug fix 2 (1.0.1)## [1.0.0] - 2017-04-10### Deprecated-Known issue 1 (1.0.0)-Known issue 2 (1.0.0)

[Unreleased]:https://github.test_url/test_project/compare/v1.1.0...HEAD[1.1.0]:https://github.test_url/test_project/compare/v1.0.1...v1.1.0[1.0.1]:https://github.test_url/test_project/compare/v1.0.0...v1.0.1[1.0.0]:https://github.test_url/test_project/releases/tag/v1.0.0show_unreleasedparameter can be specified in order to includeUnreleasedsection information.
Note thatrelease_datewill be set to None in such as case.Retrieving the raw contentIf for some reason you would like to retrieve the raw content of a release you can useto_raw_dictinstead.importkeepachangelogchanges=keepachangelog.to_raw_dict("path/to/CHANGELOG.md")changeswould look like:changes={"1.1.0":{"raw":"""### Changed- Enhancement 1 (1.1.0)- sub enhancement 1- sub enhancement 2- Enhancement 2 (1.1.0)""","release_date":"2018-05-31","version":"1.1.0","semantic_version":{"major":1,"minor":1,"patch":0,"prerelease":None,"buildmetadata":None,},"url":"https://github.test_url/test_project/compare/v1.0.1...v1.1.0",},"1.0.1":{"raw":"""### Fixed- Bug fix 1 (1.0.1)- sub bug 1- sub bug 2- Bug fix 2 (1.0.1)""","release_date":"2018-05-31","version":"1.0.1","semantic_version":{"major":1,"minor":0,"patch":1,"prerelease":None,"buildmetadata":None,},"url":"https://github.test_url/test_project/compare/v1.0.0...v1.0.1",},"1.0.0":{"raw":"""### Deprecated- Known issue 1 (1.0.0)- Known issue 2 (1.0.0)""","release_date":"2017-04-10","version":"1.0.0","semantic_version":{"major":1,"minor":0,"patch":0,"prerelease":None,"buildmetadata":None,},"url":"https://github.test_url/test_project/releases/tag/v1.0.0",},}ReleaseYou can create a new release by usingkeepachangelog.releasefunction.importkeepachangelognew_version=keepachangelog.release("path/to/CHANGELOG.md")This will:Ifnew_versionparameter is not provided, guess the new version number and return it:RemovedorChangedsections will be considered as breaking changes, thus incrementing the major version.If the only section isFixed, only patch will be incremented.Otherwise, minor will be incremented.Update changelog.Unreleased section content will be moved into a new section.[Unreleased]link will be updated.New link will be created corresponding to the new section (based on the format of the Unreleased link).EndpointStarletteAn helper function is available to create astarletteendpoint to retrieve changelog as JSON.fromstarlette.applicationsimportStarlettefromkeepachangelog.starletteimportadd_changelog_endpointapp=Starlette()# /changelog endpoint will return the dict extracted from the changelog as JSON.add_changelog_endpoint(app,"path/to/CHANGELOG.md")Note:starlettemodule must be installed.Flask-RestXAn helper function is available to create aFlask-RestXendpoint to retrieve changelog as JSON.importflaskimportflask_restxfromkeepachangelog.flask_restximportadd_changelog_endpointapp=flask.Flask(__name__)api=flask_restx.Api(app)# /changelog endpoint will return the dict extracted from the changelog as JSON.add_changelog_endpoint(api,"path/to/CHANGELOG.md")Note:flask-restxmodule must be installed.How to installpython 3.6+must be installedUse pip to install module:python-mpipinstallkeepachangelog