@@ -9,8 +9,10 @@ Specification of the :file:`setup.cfg` file
99:version: 0.9
1010
1111This document describes the :file: `setup.cfg `, an ini-style configuration file
12- (compatible with :class: `configparser.RawConfigParser `) used by Packaging to
13- replace the :file: `setup.py ` file.
12+ used by Packaging to replace the :file: `setup.py ` file used by Distutils.
13+ This specification is language-agnostic, and will therefore repeat some
14+ information that's already documented for Python in the
15+ :class: `configparser.RawConfigParser ` documentation.
1416
1517.. contents ::
1618 :depth: 3
@@ -20,11 +22,10 @@ replace the :file:`setup.py` file.
2022Syntax
2123======
2224
23- The configuration file is an ini-based file. Variables name can be
24- assigned values, and grouped into sections. A line that starts with "#" is
25- commented out. Empty lines are also removed.
26-
27- Example::
25+ The ini-style format used in the configuration file is a simple collection of
26+ sections that group sets of key-value fields separated by ``= `` or ``: `` and
27+ optional whitespace. Lines starting with ``# `` or ``; `` are comments and will
28+ be ignored. Empty lines are also ignored. Example::
2829
2930 [section1]
3031 # comment
@@ -35,22 +36,24 @@ Example::
3536 foo = bar
3637
3738
38- Values conversion
39- -----------------
39+ Parsing values
40+ ---------------
41+
42+ Here are a set of rules to parse values:
43+
44+ - If a value is quoted with ``" `` chars, it's a string. If a quote character is
45+ present in the quoted value, it can be escaped as ``\" `` or left as-is.
46+
47+ - If the value is ``true ``, ``t ``, ``yes ``, ``y `` (case-insensitive) or ``1 ``,
48+ it's converted to the language equivalent of a ``True `` value; if it's
49+ ``false ``, ``f ``, ``no ``, ``n `` (case-insensitive) or ``0 ``, it's converted to
50+ the equivalent of ``False ``.
4051
41- Here are a set of rules for converting values:
52+ - A value can contain multiple lines. When read, lines are converted into a
53+ sequence of values. Each line after the first must start with a least one
54+ space or tab character; this leading indentation will be stripped.
4255
43- - If value is quoted with " chars, it's a string. This notation is useful to
44- include "=" characters in the value. In case the value contains a "
45- character, it must be escaped with a "\" character.
46- - If the value is "true" or "false" --no matter what the case is--, it's
47- converted to a boolean, or 0 and 1 when the language does not have a
48- boolean type.
49- - A value can contains multiple lines. When read, lines are converted into a
50- sequence of values. Each new line for a multiple lines value must start with
51- a least one space or tab character. These indentation characters will be
52- stripped.
53- - all other values are considered as strings
56+ - All other values are considered strings.
5457
5558Examples::
5659
@@ -68,12 +71,12 @@ Examples::
6871Extending files
6972---------------
7073
71- An INI file can extend another file. For this, a "DEFAULT" section must contain
72- an "extends" variable that can point to one or several INI files which will be
73- merged to the current file by adding new sections and values.
74+ A configuration file can be extended (i.e. included) by other files. For this,
75+ a ``DEFAULT `` section must contain an ``extends `` key which value points to one
76+ or more files which will be merged into the current files by adding new sections
77+ and fields. If a file loaded by ``extends `` contains sections or keys that
78+ already exist in the original file, they will not override the previous values.
7479
75- If the file pointed in "extends" contains section/variable names that already
76- exist in the original file, they will not override existing ones.
7780
7881file_one.ini::
7982
@@ -107,13 +110,12 @@ To point several files, the multi-line notation can be used::
107110 extends = file_one.ini
108111 file_two.ini
109112
110- When several files are provided, they are processed sequentially. So if the
111- first one has a value that is also present in the second, the second one will
112- be ignored. This means that the configuration goes from the most specialized to
113- the most common.
113+ When several files are provided, they are processed sequentially, following the
114+ precedence rules explained above. This means that the list of files should go
115+ from most specialized to most common.
114116
115- **Tools will need to provide a way to produce a canonical version of the
116- file **. This will be useful to publish a single file.
117+ **Tools will need to provide a way to produce a merged version of the
118+ file **. This will be useful to let users publish a single file.
117119
118120
119121Description of sections and fields
0 commit comments