Skip to content

Commit

Permalink
docs(website): split the configuration section
Browse files Browse the repository at this point in the history
  • Loading branch information
orhun committed Dec 20, 2023
1 parent c6a92bf commit 67486cc
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 97 deletions.
55 changes: 55 additions & 0 deletions website/docs/configuration/changelog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# `changelog`

This section contains the configuration options for changelog generation.

<!-- {% raw %} -->

```toml
[changelog]
header = "Changelog"
body = """
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | upper_first }}
{% endfor %}
{% endfor %}
"""
trim = true
footer = "<!-- generated by git-cliff -->"
postprocessors = [{ pattern = "foo", replace = "bar"}]
```

<!-- {% endraw %} -->

### header

Header text that will be added to the beginning of the changelog.

### body

Body template that represents a single release in the changelog.

See [templating](/docs/category/templating) for more detail.

### footer

Footer template that will be rendered and added to the end of the changelog.

The template context is the same as [`body`](#body) and contains all the releases instead of a single release.

For example, to get the list of releases, use the `{{ releases }}` variable in the template. To get information about a single release, iterate over this array and access the fields similar to [`body`](#body).

See [Keep a Changelog configuration](/docs/templating/examples#keep-a-changelog) for seeing the example of adding links to the end of the changelog.

### trim

If set to `true`, leading and trailing whitespace are removed from the [`body`](#body).

It is useful for adding indentation to the template for readability, as shown [in the example](#changelog).

### postprocessors

An array of commit postprocessors for manipulating the changelog before outputting.
Can e.g. be used for replacing commit author with GitHub usernames.
Internally postprocessors and preprocessors are the same. See [commit_preprocessors](/docs/configuration/git#commit_preprocessors) for more detail and examples, it uses the same syntax.
Original file line number Diff line number Diff line change
@@ -1,76 +1,4 @@
---
sidebar_position: 4
---

# Configuration

**git-cliff** configuration file supports [TOML](https://github.com/toml-lang/toml) (preferred) and [YAML](https://yaml.org) formats.

The configuration file is read from `$HOME/git-cliff/cliff.toml` if the file exists. This location depends on the platform, for example:

- on Linux: `/home/<user>/.config/git-cliff/cliff.toml`
- on Windows: `C:\Users\<user>\AppData\Roaming\git-cliff\cliff.toml`
- on macOS: `/Users/<user>/Library/Application Support/git-cliff/cliff.toml`

See [cliff.toml](https://github.com/orhun/git-cliff/blob/main/config/cliff.toml) for the default configuration values.

## `changelog`

This section contains the configuration options for changelog generation.

<!-- {% raw %} -->

```toml
[changelog]
header = "Changelog"
body = """
{% for group, commits in commits | group_by(attribute="group") %}
### {{ group | upper_first }}
{% for commit in commits %}
- {{ commit.message | upper_first }}
{% endfor %}
{% endfor %}
"""
trim = true
footer = "<!-- generated by git-cliff -->"
postprocessors = [{ pattern = "foo", replace = "bar"}]
```

<!-- {% endraw %} -->

### header

Header text that will be added to the beginning of the changelog.

### body

Body template that represents a single release in the changelog.

See [templating](/docs/category/templating) for more detail.

### footer

Footer template that will be rendered and added to the end of the changelog.

The template context is the same as [`body`](#body) and contains all the releases instead of a single release.

For example, to get the list of releases, use the `{{ releases }}` variable in the template. To get information about a single release, iterate over this array and access the fields similar to [`body`](#body).

See [Keep a Changelog configuration](/docs/templating/examples#keep-a-changelog) for seeing the example of adding links to the end of the changelog.

### trim

If set to `true`, leading and trailing whitespace are removed from the [`body`](#body).

It is useful for adding indentation to the template for readability, as shown [in the example](#changelog).

### postprocessors

An array of commit postprocessors for manipulating the changelog before outputting.
Can e.g. be used for replacing commit author with GitHub usernames.
Internally postprocessors and preprocessors are the same. See [commit_preprocessors](#commit_preprocessors) for more detail and examples, it uses the same syntax.

## `git`
# `git`

This section contains the parsing and git related configuration options.

Expand Down Expand Up @@ -298,27 +226,3 @@ Examples:
`limit_commits` is an **optional** positive integer number that limits the number of included commits in the generated changelog.

`limit_commits` is not part of the default configuration.

## Environment Configuration Overrides

It's possible to use environment variables to override configuration elements. If an environment variable matches a configuration element, the variable's value will be used instead of the element's.

Format:

```
[PREFIX]__[CONFIG SECTION]__[FIELD NAME]
```

#### Examples

To override the `footer` element:

```bash
export GIT_CLIFF__CHANGELOG__FOOTER="<!-- footer from env -->"
```

To override the `ignore_tags` element:

```bash
export GIT_CLIFF__GIT__IGNORE_TAGS="v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
```
38 changes: 38 additions & 0 deletions website/docs/configuration/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
sidebar_position: 4
---
# Configuration

**git-cliff** configuration file supports [TOML](https://github.com/toml-lang/toml) (preferred) and [YAML](https://yaml.org) formats.

The configuration file is read from `$HOME/git-cliff/cliff.toml` if the file exists. This location depends on the platform, for example:

- on Linux: `/home/<user>/.config/git-cliff/cliff.toml`
- on Windows: `C:\Users\<user>\AppData\Roaming\git-cliff\cliff.toml`
- on macOS: `/Users/<user>/Library/Application Support/git-cliff/cliff.toml`

See [cliff.toml](https://github.com/orhun/git-cliff/blob/main/config/cliff.toml) for the default configuration values.

## Environment Configuration Overrides

It's possible to use environment variables to override configuration elements. If an environment variable matches a configuration element, the variable's value will be used instead of the element's.

Format:

```
[PREFIX]__[CONFIG SECTION]__[FIELD NAME]
```

#### Examples

To override the `footer` element:

```bash
export GIT_CLIFF__CHANGELOG__FOOTER="<!-- footer from env -->"
```

To override the `ignore_tags` element:

```bash
export GIT_CLIFF__GIT__IGNORE_TAGS="v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+"
```

0 comments on commit 67486cc

Please sign in to comment.