Skip to content

Commit a2c0264

Browse files
committed
docs(customization/config_file): group config examples in tabbed code blocks
1 parent 0645b18 commit a2c0264

2 files changed

Lines changed: 137 additions & 132 deletions

File tree

docs/customization/config_file.md

Lines changed: 135 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -8,142 +8,146 @@ The basic steps are:
88
`cz_customize` is likely to be removed or renamed in the next major release.
99
This change is still under discussion; you can continue using `cz_customize` for now and follow [#1385](https://github.com/commitizen-tools/commitizen/issues/1385) for the rationale, options, and current status.
1010

11+
The following shows the **same configuration** in TOML, JSON, and YAML; use the format your project uses.
12+
1113
Example:
1214

13-
```toml title="pyproject.toml"
14-
[tool.commitizen]
15-
name = "cz_customize"
16-
17-
[tool.commitizen.customize]
18-
message_template = "{{change_type}}:{% if show_message %} {{message}}{% endif %}"
19-
example = "feature: this feature enable customize through config file"
20-
schema = "<type>: <body>"
21-
schema_pattern = "(feature|bug fix):(\\s.*)"
22-
bump_pattern = "^(break|new|fix|hotfix)"
23-
bump_map = {"break" = "MAJOR", "new" = "MINOR", "fix" = "PATCH", "hotfix" = "PATCH"}
24-
change_type_order = ["BREAKING CHANGE", "feat", "fix", "refactor", "perf"]
25-
info_path = "cz_customize_info.txt"
26-
info = """
27-
This is customized info
28-
"""
29-
commit_parser = "^(?P<change_type>feature|bug fix):\\s(?P<message>.*)?"
30-
changelog_pattern = "^(feature|bug fix)?(!)?"
31-
change_type_map = {"feature" = "Feat", "bug fix" = "Fix"}
32-
33-
[[tool.commitizen.customize.questions]]
34-
type = "list"
35-
name = "change_type"
36-
choices = [{value = "feature", name = "feature: A new feature."}, {value = "bug fix", name = "bug fix: A bug fix."}]
37-
# choices = ["feature", "fix"] # short version
38-
message = "Select the type of change you are committing"
39-
40-
[[tool.commitizen.customize.questions]]
41-
type = "input"
42-
name = "message"
43-
message = "Body."
44-
45-
[[tool.commitizen.customize.questions]]
46-
type = "confirm"
47-
name = "show_message"
48-
message = "Do you want to add body message in commit?"
49-
```
50-
51-
The equivalent example for a json config file:
52-
53-
```json title=".cz.json"
54-
{
55-
"commitizen": {
56-
"name": "cz_customize",
57-
"customize": {
58-
"message_template": "{{change_type}}:{% if show_message %} {{message}}{% endif %}",
59-
"example": "feature: this feature enable customize through config file",
60-
"schema": "<type>: <body>",
61-
"schema_pattern": "(feature|bug fix):(\\s.*)",
62-
"bump_pattern": "^(break|new|fix|hotfix)",
63-
"bump_map": {
64-
"break": "MAJOR",
65-
"new": "MINOR",
66-
"fix": "PATCH",
67-
"hotfix": "PATCH"
68-
},
69-
"change_type_order": ["BREAKING CHANGE", "feat", "fix", "refactor", "perf"],
70-
"info_path": "cz_customize_info.txt",
71-
"info": "This is customized info",
72-
"commit_parser": "^(?P<change_type>feature|bug fix):\\s(?P<message>.*)?",
73-
"changelog_pattern": "^(feature|bug fix)?(!)?",
74-
"change_type_map": {"feature": "Feat", "bug fix": "Fix"},
75-
"questions": [
76-
{
77-
"type": "list",
78-
"name": "change_type",
79-
"choices": [
80-
{
81-
"value": "feature",
82-
"name": "feature: A new feature."
83-
},
84-
{
85-
"value": "bug fix",
86-
"name": "bug fix: A bug fix."
87-
}
88-
],
89-
"message": "Select the type of change you are committing"
90-
},
91-
{
92-
"type": "input",
93-
"name": "message",
94-
"message": "Body."
15+
=== "TOML"
16+
17+
```toml title="pyproject.toml"
18+
[tool.commitizen]
19+
name = "cz_customize"
20+
21+
[tool.commitizen.customize]
22+
message_template = "{{change_type}}:{% if show_message %} {{message}}{% endif %}"
23+
example = "feature: this feature enable customize through config file"
24+
schema = "<type>: <body>"
25+
schema_pattern = "(feature|bug fix):(\\s.*)"
26+
bump_pattern = "^(break|new|fix|hotfix)"
27+
bump_map = {"break" = "MAJOR", "new" = "MINOR", "fix" = "PATCH", "hotfix" = "PATCH"}
28+
change_type_order = ["BREAKING CHANGE", "feat", "fix", "refactor", "perf"]
29+
info_path = "cz_customize_info.txt"
30+
info = """
31+
This is customized info
32+
"""
33+
commit_parser = "^(?P<change_type>feature|bug fix):\\s(?P<message>.*)?"
34+
changelog_pattern = "^(feature|bug fix)?(!)?"
35+
change_type_map = {"feature" = "Feat", "bug fix" = "Fix"}
36+
37+
[[tool.commitizen.customize.questions]]
38+
type = "list"
39+
name = "change_type"
40+
choices = [{value = "feature", name = "feature: A new feature."}, {value = "bug fix", name = "bug fix: A bug fix."}]
41+
# choices = ["feature", "fix"] # short version
42+
message = "Select the type of change you are committing"
43+
44+
[[tool.commitizen.customize.questions]]
45+
type = "input"
46+
name = "message"
47+
message = "Body."
48+
49+
[[tool.commitizen.customize.questions]]
50+
type = "confirm"
51+
name = "show_message"
52+
message = "Do you want to add body message in commit?"
53+
```
54+
55+
=== "JSON"
56+
57+
```json title=".cz.json"
58+
{
59+
"commitizen": {
60+
"name": "cz_customize",
61+
"customize": {
62+
"message_template": "{{change_type}}:{% if show_message %} {{message}}{% endif %}",
63+
"example": "feature: this feature enable customize through config file",
64+
"schema": "<type>: <body>",
65+
"schema_pattern": "(feature|bug fix):(\\s.*)",
66+
"bump_pattern": "^(break|new|fix|hotfix)",
67+
"bump_map": {
68+
"break": "MAJOR",
69+
"new": "MINOR",
70+
"fix": "PATCH",
71+
"hotfix": "PATCH"
9572
},
96-
{
97-
"type": "confirm",
98-
"name": "show_message",
99-
"message": "Do you want to add body message in commit?"
100-
}
101-
]
73+
"change_type_order": ["BREAKING CHANGE", "feat", "fix", "refactor", "perf"],
74+
"info_path": "cz_customize_info.txt",
75+
"info": "This is customized info",
76+
"commit_parser": "^(?P<change_type>feature|bug fix):\\s(?P<message>.*)?",
77+
"changelog_pattern": "^(feature|bug fix)?(!)?",
78+
"change_type_map": {"feature": "Feat", "bug fix": "Fix"},
79+
"questions": [
80+
{
81+
"type": "list",
82+
"name": "change_type",
83+
"choices": [
84+
{
85+
"value": "feature",
86+
"name": "feature: A new feature."
87+
},
88+
{
89+
"value": "bug fix",
90+
"name": "bug fix: A bug fix."
91+
}
92+
],
93+
"message": "Select the type of change you are committing"
94+
},
95+
{
96+
"type": "input",
97+
"name": "message",
98+
"message": "Body."
99+
},
100+
{
101+
"type": "confirm",
102+
"name": "show_message",
103+
"message": "Do you want to add body message in commit?"
104+
}
105+
]
106+
}
102107
}
103108
}
104-
}
105-
```
106-
107-
And the correspondent example for a yaml file:
108-
109-
```yaml title=".cz.yaml"
110-
commitizen:
111-
name: cz_customize
112-
customize:
113-
message_template: '{{change_type}}:{% if show_message %} {{message}}{% endif %}'
114-
example: 'feature: this feature enable customize through config file'
115-
schema: '<type>: <body>'
116-
schema_pattern: '(feature|bug fix):(\\s.*)'
117-
bump_pattern: '^(break|new|fix|hotfix)'
118-
commit_parser: '^(?P<change_type>feature|bug fix):\\s(?P<message>.*)?'
119-
changelog_pattern: '^(feature|bug fix)?(!)?'
120-
change_type_map:
121-
feature: Feat
122-
bug fix: Fix
123-
bump_map:
124-
break: MAJOR
125-
new: MINOR
126-
fix: PATCH
127-
hotfix: PATCH
128-
change_type_order: ['BREAKING CHANGE', 'feat', 'fix', 'refactor', 'perf']
129-
info_path: cz_customize_info.txt
130-
info: This is customized info
131-
questions:
132-
- type: list
133-
name: change_type
134-
choices:
135-
- value: feature
136-
name: 'feature: A new feature.'
137-
- value: bug fix
138-
name: 'bug fix: A bug fix.'
139-
message: Select the type of change you are committing
140-
- type: input
141-
name: message
142-
message: 'Body.'
143-
- type: confirm
144-
name: show_message
145-
message: 'Do you want to add body message in commit?'
146-
```
109+
```
110+
111+
=== "YAML"
112+
113+
```yaml title=".cz.yaml"
114+
commitizen:
115+
name: cz_customize
116+
customize:
117+
message_template: '{{change_type}}:{% if show_message %} {{message}}{% endif %}'
118+
example: 'feature: this feature enable customize through config file'
119+
schema: '<type>: <body>'
120+
schema_pattern: '(feature|bug fix):(\\s.*)'
121+
bump_pattern: '^(break|new|fix|hotfix)'
122+
commit_parser: '^(?P<change_type>feature|bug fix):\\s(?P<message>.*)?'
123+
changelog_pattern: '^(feature|bug fix)?(!)?'
124+
change_type_map:
125+
feature: Feat
126+
bug fix: Fix
127+
bump_map:
128+
break: MAJOR
129+
new: MINOR
130+
fix: PATCH
131+
hotfix: PATCH
132+
change_type_order: ['BREAKING CHANGE', 'feat', 'fix', 'refactor', 'perf']
133+
info_path: cz_customize_info.txt
134+
info: This is customized info
135+
questions:
136+
- type: list
137+
name: change_type
138+
choices:
139+
- value: feature
140+
name: 'feature: A new feature.'
141+
- value: bug fix
142+
name: 'bug fix: A bug fix.'
143+
message: Select the type of change you are committing
144+
- type: input
145+
name: message
146+
message: 'Body.'
147+
- type: confirm
148+
name: show_message
149+
message: 'Do you want to add body message in commit?'
150+
```
147151

148152
## Configuration File Options
149153

mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ markdown_extensions:
105105
- name: mermaid
106106
class: mermaid
107107
format: !!python/name:pymdownx.superfences.fence_code_format
108-
- pymdownx.tabbed
108+
- pymdownx.tabbed:
109+
alternate_style: true
109110

110111
plugins:
111112
- search

0 commit comments

Comments
 (0)