Skip to content

Commit c3a1c74

Browse files
committed
fix
1 parent c6bb89b commit c3a1c74

File tree

1 file changed

+49
-27
lines changed

1 file changed

+49
-27
lines changed

Users/toml_config.rst

Lines changed: 49 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ like minified files (e.g. ``*.min.js``) and backup files (e.g. ``*.orig``)::
4343
ignore = [ '**.min.js', '**.orig' ]
4444

4545
Basic TOML concepts
46-
~~~~~~~~~~~~~~~~~~~~
46+
---------------------
4747
This part describes the basic TOML concepts required to write coala
4848
configuration files in TOML
4949

@@ -54,7 +54,9 @@ configuration files in TOML
5454
- A table is a collection of key-value pairs. Use a table for specifying
5555
a coala section.
5656

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::
5860
5961
[cli]
6062
bears = 'SpaceConsistencyBear'
@@ -74,12 +76,14 @@ that govern a section. To write coala configuration file you will
7476
be using TOML strings, booleans, integers and arrays as values.
7577

7678
Section Inheritance
77-
~~~~~~~~~~~~~~~~~~~~
79+
---------------------
7880
coala supports section inheritance. You can define section inheritance
7981
by using the key ``inherits``.
8082
Extra values can be appended to an inherited setting using the ``appends`` key.
8183

82-
Consider the following configuration file in TOML ::
84+
Consider the following configuration file in TOML
85+
86+
.. code::
8387
8488
[all]
8589
enabled = true
@@ -105,7 +109,9 @@ In the inherited sections above, ``appends`` key specifies that the value of
105109
``ignore`` in the derived sections must be appended with the value of
106110
``ignore`` key in the base section.
107111

108-
This is the same file without section inheritance::
112+
This is the same file without section inheritance
113+
114+
.. code::
109115
110116
[all]
111117
enabled = true
@@ -129,7 +135,7 @@ Consider another example
129135

130136
Config file in TOML
131137

132-
::
138+
.. code::
133139
134140
[all]
135141
a = 1
@@ -147,7 +153,7 @@ Config file in TOML
147153
You can use this syntax to specify multiple inheritance
148154
The same is coafile appears as
149155

150-
::
156+
.. code::
151157
152158
[all]
153159
a = 1
@@ -169,14 +175,31 @@ The same is coafile appears as
169175
p = 5
170176
q = 6
171177
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+
172193
Defining Aspects and Tastes
173-
~~~~~~~~~~~~~~~~~~~~~~~~~~~
194+
----------------------------
174195

175196
Aspects is an alternative way to configure coala. In this mode, we don't need
176197
to explicitly state list of bears, coala will choose it automatically based on
177198
requested aspects in configuration file. To run coala in this mode, we need to
178199
define `aspects`, `files`, `languages`, and optionally aspect tastes setting.
179-
See the following example::
200+
See the following example
201+
202+
.. code::
180203
181204
[all]
182205
files = '**'
@@ -186,23 +209,33 @@ See the following example::
186209
# we can define subaspect taste through its parent
187210
aspectname1.subaspect_taste = ['word1', 'word2', 'word3']
188211
189-
['all.python']
212+
[python]
190213
files = '**.py'
191214
language = 'Python'
215+
inherits = 'all'
192216
# appending additional aspect
193217
appends = 'all'
194218
aspects = 'aspectname3'
195219
# excluding certain subaspect
196220
excludes = 'AspectName2Subaspect'
197221
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'
198231
199232
For existing coala users
200-
~~~~~~~~~~~~~~~~~~~~~~~~~
233+
-------------------------
201234

202235
In this section we will see how to convert a complex coafile into
203236
a configuration file in TOML
204237

205-
coafile ::
238+
.. code::
206239
207240
[all]
208241
files = *.py, coantlib/**/*.py, tests/**/*.py, coantbears/**/*.py, .ci/*.py
@@ -217,15 +250,12 @@ coafile ::
217250
bears = SpaceConsistencyBear
218251
language = Python
219252
preferred_quotation = '
220-
221253
default_actions = **: ApplyPatchAction
222254
223255
[all.flakes]
224256
# Do not set default_action to ApplyPatchAction as it may lead to some
225257
# required imports being removed that might result in coala behaving weirdly.
226-
227258
default_actions = *: ShowPatchAction
228-
229259
bears += PyUnusedCodeBear
230260
language = Python
231261
remove_all_unused_imports = true
@@ -234,26 +264,20 @@ To convert a coafile to configuration file in TOML
234264

235265
- Enclose all string values in quotes
236266
- 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]``
238268
and add ``inherits = parent_section`` as a key-value pair
239269
- Use ``true`` or ``false`` to specify booleans
240270
- Replace ``a += b`` with
241-
::
271+
272+
.. code::
242273
243274
a = 'b'
244275
appends = 'a'
245276
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'
253277
254278
Using the above rules we get a configuration file in TOML
255279

256-
::
280+
.. code::
257281
258282
[all]
259283
files = ['*.py', 'coantlib/**/*.py', 'tests/**/*.py', 'coantbears/**/*.py',
@@ -270,15 +294,13 @@ Using the above rules we get a configuration file in TOML
270294
bears = 'SpaceConsistencyBear'
271295
language = 'Python'
272296
preferred_quotation = '
273-
274297
default_actions = '**: ApplyPatchAction'
275298
276299
[flakes]
277300
# Do not set default_action to ApplyPatchAction as it may lead to some
278301
# required imports being removed that might result in coala behaving weirdly.
279302
inherits = 'all'
280303
default_actions = '*: ShowPatchAction'
281-
282304
bears = 'PyUnusedCodeBear'
283305
appends = 'bears'
284306
language = 'Python'

0 commit comments

Comments
 (0)