This commit extracts the inline mappings logic defined in the previous
commit to a separate config option, as suggested by @adrienverge. I'll
squash this into the previous commit if the change is accepted. (I named
the option slightly differently to what was suggested as I think my
proposal reads better without consulting the docs: I'd be happy to
reconsider this.)
This change make the `comments` rule accept comments that start with
multiple pound signs, e.g.:
##############################
## This is some documentation
Closes: #12
Instead of iterating over lines and tokens (and find comments between
tokens in the comment rules), add a new `Comment` type and set rules
with `type = 'comment'`.
The following source -- although not loadable by pyyaml -- is valid
YAML:
{{key}}: value
This was processed badly by yamllint. The same for `[[value]]`,
`{{{{{moustaches}}}}}` or:
{[val,
{{key: val,
key2}}]}
This patch corrects it and add corresponding test cases.
Related-to: #3
The "indentation stack" is iteratively built by the `check()` function
of the indentation rule. It is important, since everything in the rule
relies on it.
This patch adds tests to make sure the stack is correctly built for some
known structures.
For strings that continue on next line at a lower indentation level:
Blaise Pascal: Je vous écris une longue lettre parce que
je n'ai pas le temps d'en écrire une courte.
This options allows the user to control whether to lint indentation
inside multi-line scalars or not.
When enabled, such YAML source will be detected as a problem:
- C code: void main() {
printf("foo");
}
whereas this one would not:
- C code: void main() {
printf("foo");
}
YAML content like the following one produced an error, because the
multi-line ScalarToken ends at the beginning of the 4th line (the one
with the value):
? >
multi-line
key
: value
YAML content like the following one produced an error, because the
ScalarToken associated whose value is "this is plain text" ends at the
beginning of the 5th line (the one with the comment):
---
string: >
this is plain text
# comment
Using either 'yes', 'no' or 'whatever', the user will be able to choose
whether to force block sequence items to be indented, to force them not
to be indented, or don't care, respectively.
Previously only comments that were indented like the following content
line were allowed, e.g.:
prev: line:
# commented line
current: line
With this change, such new cases are also allowed:
prev: line
# commented line 1
# commented line 2
current: line
`yaml.load()` exceptions are not necessarily syntax errors. For
instance, the following YAML source cannot be `load()`ed into a Python
object, but is valid nonetheless:
? - Detroit Tigers
- Chicago cubs
:
- 2001-07-23
? [ New York Yankees,
Atlanta Braves ]
: [ 2001-07-02, 2001-08-12,
2001-08-14 ]
This commit detects syntax errors from `yaml.parse()` exceptions rather
than `yaml.load_all()`.