@@ -43,7 +43,7 @@ like minified files (e.g. ``*.min.js``) and backup files (e.g. ``*.orig``)::
43
43
ignore = [ '**.min.js', '**.orig' ]
44
44
45
45
Basic TOML concepts
46
- ~~~~~~~~~~~~~~~~~~~~
46
+ ---------------------
47
47
This part describes the basic TOML concepts required to write coala
48
48
configuration files in TOML
49
49
@@ -54,7 +54,9 @@ configuration files in TOML
54
54
- A table is a collection of key-value pairs. Use a table for specifying
55
55
a coala section.
56
56
57
- This is an example of a coala configuration file written in TOML ::
57
+ This is an example of a coala configuration file written in TOML
58
+
59
+ .. code ::
58
60
59
61
[cli]
60
62
bears = 'SpaceConsistencyBear'
@@ -74,12 +76,14 @@ that govern a section. To write coala configuration file you will
74
76
be using TOML strings, booleans, integers and arrays as values.
75
77
76
78
Section Inheritance
77
- ~~~~~~~~~~~~~~~~~~~~
79
+ ---------------------
78
80
coala supports section inheritance. You can define section inheritance
79
81
by using the key ``inherits ``.
80
82
Extra values can be appended to an inherited setting using the ``appends `` key.
81
83
82
- Consider the following configuration file in TOML ::
84
+ Consider the following configuration file in TOML
85
+
86
+ .. code ::
83
87
84
88
[all]
85
89
enabled = true
@@ -105,7 +109,9 @@ In the inherited sections above, ``appends`` key specifies that the value of
105
109
``ignore `` in the derived sections must be appended with the value of
106
110
``ignore `` key in the base section.
107
111
108
- This is the same file without section inheritance::
112
+ This is the same file without section inheritance
113
+
114
+ .. code ::
109
115
110
116
[all]
111
117
enabled = true
@@ -129,7 +135,7 @@ Consider another example
129
135
130
136
Config file in TOML
131
137
132
- ::
138
+ .. code ::
133
139
134
140
[all]
135
141
a = 1
@@ -147,7 +153,7 @@ Config file in TOML
147
153
You can use this syntax to specify multiple inheritance
148
154
The same is coafile appears as
149
155
150
- ::
156
+ .. code ::
151
157
152
158
[all]
153
159
a = 1
@@ -169,14 +175,31 @@ The same is coafile appears as
169
175
p = 5
170
176
q = 6
171
177
178
+ .. note ::
179
+
180
+ - If you want to append multiple settings then use ``appends `` as a list
181
+ .. code ::
182
+
183
+ appends = [ 'a', 'b']
184
+ - If you want to inherit multiple sections use ``inherits `` as a list
185
+ .. code ::
186
+
187
+ inherits = [ 'section1', 'section2']
188
+ - You can only inherit sections
189
+ - You can only append settings
190
+ - If a setting is redefined in the inherited section then it will
191
+ overwritten if appends is not used.
192
+
172
193
Defining Aspects and Tastes
173
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~
194
+ ----------------------------
174
195
175
196
Aspects is an alternative way to configure coala. In this mode, we don't need
176
197
to explicitly state list of bears, coala will choose it automatically based on
177
198
requested aspects in configuration file. To run coala in this mode, we need to
178
199
define `aspects `, `files `, `languages `, and optionally aspect tastes setting.
179
- See the following example::
200
+ See the following example
201
+
202
+ .. code ::
180
203
181
204
[all]
182
205
files = '**'
@@ -186,23 +209,33 @@ See the following example::
186
209
# we can define subaspect taste through its parent
187
210
aspectname1.subaspect_taste = ['word1', 'word2', 'word3']
188
211
189
- ['all. python' ]
212
+ [python]
190
213
files = '**.py'
191
214
language = 'Python'
215
+ inherits = 'all'
192
216
# appending additional aspect
193
217
appends = 'all'
194
218
aspects = 'aspectname3'
195
219
# excluding certain subaspect
196
220
excludes = 'AspectName2Subaspect'
197
221
222
+ For caofile users who want to write configuration in TOML
223
+
224
+ - If you are using aspects ``a:b = 'c' `` in a section named `example `
225
+ then replace ``a:b = 'c' `` with ``a.b = 'c' `` or
226
+
227
+ .. code ::
228
+
229
+ [example.a]
230
+ b = 'c'
198
231
199
232
For existing coala users
200
- ~~~~~~~~~~~~~~~~~~~~~~~~~
233
+ -------------------------
201
234
202
235
In this section we will see how to convert a complex coafile into
203
236
a configuration file in TOML
204
237
205
- coafile ::
238
+ .. code ::
206
239
207
240
[all]
208
241
files = *.py, coantlib/**/*.py, tests/**/*.py, coantbears/**/*.py, .ci/*.py
@@ -217,15 +250,12 @@ coafile ::
217
250
bears = SpaceConsistencyBear
218
251
language = Python
219
252
preferred_quotation = '
220
-
221
253
default_actions = **: ApplyPatchAction
222
254
223
255
[all.flakes]
224
256
# Do not set default_action to ApplyPatchAction as it may lead to some
225
257
# required imports being removed that might result in coala behaving weirdly.
226
-
227
258
default_actions = *: ShowPatchAction
228
-
229
259
bears += PyUnusedCodeBear
230
260
language = Python
231
261
remove_all_unused_imports = true
@@ -234,26 +264,20 @@ To convert a coafile to configuration file in TOML
234
264
235
265
- Enclose all string values in quotes
236
266
- Use array notation to depict list of strings
237
- - Replace ``[parent_section.inherited_section]] `` with ``[inherited.section] ``
267
+ - Replace ``[parent_section.inherited_section] `` with ``[inherited.section] ``
238
268
and add ``inherits = parent_section `` as a key-value pair
239
269
- Use ``true `` or ``false `` to specify booleans
240
270
- Replace ``a += b `` with
241
- ::
271
+
272
+ .. code ::
242
273
243
274
a = 'b'
244
275
appends = 'a'
245
276
246
- - If you are using aspects ``a:b = 'c' `` in a section named `example `
247
- then replace
248
- ``a:b = 'c' `` with ``a.b = 'c' `` or
249
- ::
250
-
251
- [example.a]
252
- b = 'c'
253
277
254
278
Using the above rules we get a configuration file in TOML
255
279
256
- ::
280
+ .. code ::
257
281
258
282
[all]
259
283
files = ['*.py', 'coantlib/**/*.py', 'tests/**/*.py', 'coantbears/**/*.py',
@@ -270,15 +294,13 @@ Using the above rules we get a configuration file in TOML
270
294
bears = 'SpaceConsistencyBear'
271
295
language = 'Python'
272
296
preferred_quotation = '
273
-
274
297
default_actions = '**: ApplyPatchAction'
275
298
276
299
[flakes]
277
300
# Do not set default_action to ApplyPatchAction as it may lead to some
278
301
# required imports being removed that might result in coala behaving weirdly.
279
302
inherits = 'all'
280
303
default_actions = '*: ShowPatchAction'
281
-
282
304
bears = 'PyUnusedCodeBear'
283
305
appends = 'bears'
284
306
language = 'Python'
0 commit comments