snippets2changelog


Namesnippets2changelog JSON
Version 1.6.0 PyPI version JSON
download
home_pagehttps://github.com/brainelectronics/snippets2changelog
SummaryGenerate a changelog from individual snippets
upload_time2024-11-17 19:11:30
maintainerNone
docs_urlNone
authorbrainelectronics
requires_python<4.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            # snippets2changelog

[![Downloads](https://pepy.tech/badge/snippets2changelog)](https://pepy.tech/project/snippets2changelog)
![Release](https://img.shields.io/github/v/release/brainelectronics/snippets2changelog?include_prereleases&color=success)
![Python](https://img.shields.io/badge/Python-3.9%20|%203.10%20|%203.11-green.svg)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![codecov](https://codecov.io/github/brainelectronics/snippets2changelog/branch/main/graph/badge.svg)](https://app.codecov.io/github/brainelectronics/snippets2changelog)

Generate a changelog from individual snippets

---------------


## General

Create version info files based on the latest changelog entry.

<!-- MarkdownTOC -->

- [Installation](#installation)
- [Usage](#usage)
  - [Info](#info)
  - [Create](#create)
    - [Snippet](#snippet)
    - [Changelog](#changelog)
  - [Parse](#parse)
  - [CI](#ci)
    - [GitHub](#github)
      - [Actions](#actions)
      - [Custom workflow](#custom-workflow)
    - [Other](#other)
- [Contributing](#contributing)
  - [Setup](#setup)
  - [Testing](#testing)
  - [Changelog](#changelog-1)
- [Credits](#credits)

<!-- /MarkdownTOC -->

## Installation

```bash
[<PYTHON> -m] pip[3] install [--user] [--upgrade] snippets2changelog
```

## Usage

### Info

Print informations about snippets2changelog

```bash
changelog-generator info
```

### Create
#### Snippet

Create a new snippet with the given name at the specified snippets folder

```bash
changelog-generator create example_snippets/123.md
```

```
Short description: My example snippet
Choose from: ['bugfix', 'feature', 'breaking']
Type of change: feature
Choose from: ['internal', 'external', 'all']
Scope of change: external
Affected users (default all): testers
```

```
## My example snippet
<!--
type: feature
scope: external
affected: testers, users
-->

TBD

```

#### Changelog

Create or update a changelog with all snippets.

The generated changelog will be named `<OLD_CHANGELOG_NAME.new>` unless the
`--in-place` flag is used. This flag is intended for CI usage with a clean
checkout before a run.

*Be aware to restore the changelog before another run as it might generate
version entries and version bumps multiple times otherwise.*

```bash
changelog-generator changelog changelog.md --snippets=.snippets [--in-place]
```

To just get the latest changelog entry without updating or generating the
changelog, use `--dry-run` to print the latest snippet content in JSON format.

```json
{
    "version": "1.5.0",
    "timestamp": "2024-10-12T13:36:46+02:00",
    "meta": {
        "type": "feature",
        "scope": [
            "all"
        ],
        "affected": [
            "all"
        ]
    },
    "content": "\n\nUse `--dry-run` with the `changelog` subparser to print the latest changelog entry as JSON instead of updating the changelog file.\n",
    "version_reference": "https://github.com/brainelectronics/snippets2changelog/tree/1.5.0"
}
```

The option `--no-internal` ignores all snippets with scope `internal` during
the changelog generation. This is useful if those changes are not affecting
the "product" like internal documentation changes or similar things, which e.g.
do not require a deployment.

The option `--version-reference` allows to configure the URL to the tags in the
rendered changelog file. Use e.g.
`https://github.com/<GITHUB_USER>/<PROJECT_USING_SNIPPETS2CHANGELOG>/tree/`
for a project using this package.

### Parse

Parse an existing snippet file and return the data as JSON without indentation

```bash
changelog-generator parse example_snippets/123.md \
  --indent=4
```

```json
{
    "type": "feature",
    "scope": [
        "external"
    ],
    "affected": [
        "testers",
        "users"
    ],
    "title": "My example snippet",
    "details": "\n\nTBD\n"
}
```

### CI

To use this tool in a CI environment use the following commands, job configs or
actions.

#### GitHub
##### Actions
See [changelog-from-snippets](https://github.com/brainelectronics/changelog-from-snippets) action.

##### Custom workflow

```yaml
---
name: Generate changelog

on:
  push:
    branches:
      - main

jobs:
  changelog:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with:
          # all history is needed to crawl it properly
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: '3.11'
      - name: Install
        run: |
          pip install snippets2changelog
      - name: Update changelog with snippets
        run: |
          changelog-generator \
            changelog changelog.md \
            --snippets=.snippets \
            --in-place \
            --no-internal
```

#### Other

```bash
pip install snippets2changelog
changelog-generator \
  changelog changelog.md \
  --snippets=.snippets \
  --in-place \
  --no-internal
```

## Contributing

### Setup

For active development you need to have `poetry` and `pre-commit` installed

```bash
python3 -m pip install --upgrade --user poetry pre-commit
git clone https://github.com/brainelectronics/snippets2changelog.git
cd snippets2changelog
pre-commit install
poetry install
```

### Testing

```bash
# run all tests
poetry run coverage run -m pytest -v

# run only one specific tests
poetry run coverage run -m pytest -v -k "test_read_save_json"
```

Generate the coverage files with

```bash
python create_report_dirs.py
coverage html
```

The coverage report is placed at `reports/coverage/html/index.html`

### Changelog

The changelog format is based on [Keep a Changelog][ref-keep-a-changelog], and
this project adheres to [Semantic Versioning][ref-semantic-versioning].

Please add a changelog snippet, see above, for every PR you contribute. The
changes are categorised into:

- `bugfixes` fix an issue which can be used out of the box without any further
changes required by the user. Be aware that in some cases bugfixes can be
breaking changes.
- `features` is used to indicate a backwards compatible change providing
improved or extended functionalitiy. This does, as `bugfixes`, in any case
not require any changes by the user to keep the system running after upgrading.
- `breaking` creates a breaking, non backwards compatible change which
requires the user to perform additional tasks, adopt his currently running
code or in general can't be used as is anymore.

The scope of a change shall either be:
- `internal` if no new deployment is required for this change, like updates in
the documentation for example
- `external` or `all` if this change affects the public API of this package or
requires a new tag and deployment for any other reason

The changelog entry shall be short but meaningful and can of course contain
links and references to other issues or PRs. New lines are only allowed for a
new bulletpoint entry. Usage examples or other code snippets should be placed
in the code documentation, README or the docs folder.

## Credits

A big thank you to the creators and maintainers of [SemVer.org][ref-semver]
for their documentation and [regex example][ref-semver-regex-example]

<!-- Links -->
[ref-keep-a-changelog]: https://keepachangelog.com/en/1.0.0/
[ref-semantic-versioning]: https://semver.org/spec/v2.0.0.html
[ref-semver]: https://semver.org/
[ref-semver-regex-example]: https://regex101.com/r/Ly7O1x/3/


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/brainelectronics/snippets2changelog",
    "name": "snippets2changelog",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "brainelectronics",
    "author_email": "info@brainelectronics.de",
    "download_url": "https://files.pythonhosted.org/packages/3e/a4/c4964fa3a0a4978da793e765cb26e940e854648fa2d4dc450c407a2e5116/snippets2changelog-1.6.0.tar.gz",
    "platform": null,
    "description": "# snippets2changelog\n\n[![Downloads](https://pepy.tech/badge/snippets2changelog)](https://pepy.tech/project/snippets2changelog)\n![Release](https://img.shields.io/github/v/release/brainelectronics/snippets2changelog?include_prereleases&color=success)\n![Python](https://img.shields.io/badge/Python-3.9%20|%203.10%20|%203.11-green.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![codecov](https://codecov.io/github/brainelectronics/snippets2changelog/branch/main/graph/badge.svg)](https://app.codecov.io/github/brainelectronics/snippets2changelog)\n\nGenerate a changelog from individual snippets\n\n---------------\n\n\n## General\n\nCreate version info files based on the latest changelog entry.\n\n<!-- MarkdownTOC -->\n\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Info](#info)\n  - [Create](#create)\n    - [Snippet](#snippet)\n    - [Changelog](#changelog)\n  - [Parse](#parse)\n  - [CI](#ci)\n    - [GitHub](#github)\n      - [Actions](#actions)\n      - [Custom workflow](#custom-workflow)\n    - [Other](#other)\n- [Contributing](#contributing)\n  - [Setup](#setup)\n  - [Testing](#testing)\n  - [Changelog](#changelog-1)\n- [Credits](#credits)\n\n<!-- /MarkdownTOC -->\n\n## Installation\n\n```bash\n[<PYTHON> -m] pip[3] install [--user] [--upgrade] snippets2changelog\n```\n\n## Usage\n\n### Info\n\nPrint informations about snippets2changelog\n\n```bash\nchangelog-generator info\n```\n\n### Create\n#### Snippet\n\nCreate a new snippet with the given name at the specified snippets folder\n\n```bash\nchangelog-generator create example_snippets/123.md\n```\n\n```\nShort description: My example snippet\nChoose from: ['bugfix', 'feature', 'breaking']\nType of change: feature\nChoose from: ['internal', 'external', 'all']\nScope of change: external\nAffected users (default all): testers\n```\n\n```\n## My example snippet\n<!--\ntype: feature\nscope: external\naffected: testers, users\n-->\n\nTBD\n\n```\n\n#### Changelog\n\nCreate or update a changelog with all snippets.\n\nThe generated changelog will be named `<OLD_CHANGELOG_NAME.new>` unless the\n`--in-place` flag is used. This flag is intended for CI usage with a clean\ncheckout before a run.\n\n*Be aware to restore the changelog before another run as it might generate\nversion entries and version bumps multiple times otherwise.*\n\n```bash\nchangelog-generator changelog changelog.md --snippets=.snippets [--in-place]\n```\n\nTo just get the latest changelog entry without updating or generating the\nchangelog, use `--dry-run` to print the latest snippet content in JSON format.\n\n```json\n{\n    \"version\": \"1.5.0\",\n    \"timestamp\": \"2024-10-12T13:36:46+02:00\",\n    \"meta\": {\n        \"type\": \"feature\",\n        \"scope\": [\n            \"all\"\n        ],\n        \"affected\": [\n            \"all\"\n        ]\n    },\n    \"content\": \"\\n\\nUse `--dry-run` with the `changelog` subparser to print the latest changelog entry as JSON instead of updating the changelog file.\\n\",\n    \"version_reference\": \"https://github.com/brainelectronics/snippets2changelog/tree/1.5.0\"\n}\n```\n\nThe option `--no-internal` ignores all snippets with scope `internal` during\nthe changelog generation. This is useful if those changes are not affecting\nthe \"product\" like internal documentation changes or similar things, which e.g.\ndo not require a deployment.\n\nThe option `--version-reference` allows to configure the URL to the tags in the\nrendered changelog file. Use e.g.\n`https://github.com/<GITHUB_USER>/<PROJECT_USING_SNIPPETS2CHANGELOG>/tree/`\nfor a project using this package.\n\n### Parse\n\nParse an existing snippet file and return the data as JSON without indentation\n\n```bash\nchangelog-generator parse example_snippets/123.md \\\n  --indent=4\n```\n\n```json\n{\n    \"type\": \"feature\",\n    \"scope\": [\n        \"external\"\n    ],\n    \"affected\": [\n        \"testers\",\n        \"users\"\n    ],\n    \"title\": \"My example snippet\",\n    \"details\": \"\\n\\nTBD\\n\"\n}\n```\n\n### CI\n\nTo use this tool in a CI environment use the following commands, job configs or\nactions.\n\n#### GitHub\n##### Actions\nSee [changelog-from-snippets](https://github.com/brainelectronics/changelog-from-snippets) action.\n\n##### Custom workflow\n\n```yaml\n---\nname: Generate changelog\n\non:\n  push:\n    branches:\n      - main\n\njobs:\n  changelog:\n    runs-on: ubuntu-latest\n    steps:\n      - name: Checkout\n        uses: actions/checkout@v4\n        with:\n          # all history is needed to crawl it properly\n          fetch-depth: 0\n      - name: Set up Python\n        uses: actions/setup-python@v5\n        with:\n          python-version: '3.11'\n      - name: Install\n        run: |\n          pip install snippets2changelog\n      - name: Update changelog with snippets\n        run: |\n          changelog-generator \\\n            changelog changelog.md \\\n            --snippets=.snippets \\\n            --in-place \\\n            --no-internal\n```\n\n#### Other\n\n```bash\npip install snippets2changelog\nchangelog-generator \\\n  changelog changelog.md \\\n  --snippets=.snippets \\\n  --in-place \\\n  --no-internal\n```\n\n## Contributing\n\n### Setup\n\nFor active development you need to have `poetry` and `pre-commit` installed\n\n```bash\npython3 -m pip install --upgrade --user poetry pre-commit\ngit clone https://github.com/brainelectronics/snippets2changelog.git\ncd snippets2changelog\npre-commit install\npoetry install\n```\n\n### Testing\n\n```bash\n# run all tests\npoetry run coverage run -m pytest -v\n\n# run only one specific tests\npoetry run coverage run -m pytest -v -k \"test_read_save_json\"\n```\n\nGenerate the coverage files with\n\n```bash\npython create_report_dirs.py\ncoverage html\n```\n\nThe coverage report is placed at `reports/coverage/html/index.html`\n\n### Changelog\n\nThe changelog format is based on [Keep a Changelog][ref-keep-a-changelog], and\nthis project adheres to [Semantic Versioning][ref-semantic-versioning].\n\nPlease add a changelog snippet, see above, for every PR you contribute. The\nchanges are categorised into:\n\n- `bugfixes` fix an issue which can be used out of the box without any further\nchanges required by the user. Be aware that in some cases bugfixes can be\nbreaking changes.\n- `features` is used to indicate a backwards compatible change providing\nimproved or extended functionalitiy. This does, as `bugfixes`, in any case\nnot require any changes by the user to keep the system running after upgrading.\n- `breaking` creates a breaking, non backwards compatible change which\nrequires the user to perform additional tasks, adopt his currently running\ncode or in general can't be used as is anymore.\n\nThe scope of a change shall either be:\n- `internal` if no new deployment is required for this change, like updates in\nthe documentation for example\n- `external` or `all` if this change affects the public API of this package or\nrequires a new tag and deployment for any other reason\n\nThe changelog entry shall be short but meaningful and can of course contain\nlinks and references to other issues or PRs. New lines are only allowed for a\nnew bulletpoint entry. Usage examples or other code snippets should be placed\nin the code documentation, README or the docs folder.\n\n## Credits\n\nA big thank you to the creators and maintainers of [SemVer.org][ref-semver]\nfor their documentation and [regex example][ref-semver-regex-example]\n\n<!-- Links -->\n[ref-keep-a-changelog]: https://keepachangelog.com/en/1.0.0/\n[ref-semantic-versioning]: https://semver.org/spec/v2.0.0.html\n[ref-semver]: https://semver.org/\n[ref-semver-regex-example]: https://regex101.com/r/Ly7O1x/3/\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Generate a changelog from individual snippets",
    "version": "1.6.0",
    "project_urls": {
        "Homepage": "https://github.com/brainelectronics/snippets2changelog",
        "Repository": "https://github.com/brainelectronics/snippets2changelog"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1442e1f78b28a22c6c2b52e8d6fa9e2826f2539db3ddbade841159523cc43e0a",
                "md5": "13f084bab15a9c21936265559370cf56",
                "sha256": "1997ddeb50025618bd2a0453707ecd7a9d0ce2aa96441fa0a379b1e9fe0cff34"
            },
            "downloads": -1,
            "filename": "snippets2changelog-1.6.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "13f084bab15a9c21936265559370cf56",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 14487,
            "upload_time": "2024-11-17T19:11:29",
            "upload_time_iso_8601": "2024-11-17T19:11:29.785934Z",
            "url": "https://files.pythonhosted.org/packages/14/42/e1f78b28a22c6c2b52e8d6fa9e2826f2539db3ddbade841159523cc43e0a/snippets2changelog-1.6.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3ea4c4964fa3a0a4978da793e765cb26e940e854648fa2d4dc450c407a2e5116",
                "md5": "d461685297c7b7c20bbc2b6a7fbcf878",
                "sha256": "0a2096919f4f3f935abe6aa1a6809ab676b673f23e5eaf7e1a515fb65b94554b"
            },
            "downloads": -1,
            "filename": "snippets2changelog-1.6.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d461685297c7b7c20bbc2b6a7fbcf878",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 14624,
            "upload_time": "2024-11-17T19:11:30",
            "upload_time_iso_8601": "2024-11-17T19:11:30.680182Z",
            "url": "https://files.pythonhosted.org/packages/3e/a4/c4964fa3a0a4978da793e765cb26e940e854648fa2d4dc450c407a2e5116/snippets2changelog-1.6.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-17 19:11:30",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "brainelectronics",
    "github_project": "snippets2changelog",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "lcname": "snippets2changelog"
}
        
Elapsed time: 0.92375s