Improve support for trailing commas in macro signatures, calls & with statements
This change improves support for trailing commas on macros & with statements by adding tests for already supported trailing commas and adding support & tests for "new" trailing commas.
The support for trailing commas is implemented as follows: By checking at the beginning of a loop but after parsing a comma if the current statement is already closed and ignoring/accepting this, trailing commas become supported. This technique is already used by other parsers in Jinja (e.g. for list & dictionaries). It was copied from other implementations already comitted here and from @njl's implemention from #107, which was probably not merged due to the misunderstanding that #100 was already fixed.
I took the freedom to add support for trailing commas in with statements here as well without creating a concrete issue before. I hope that's okay, otherwise I'm willing to open an issue if one is required. I can also split this change from this PR if that is required.
I also commented the code which adds support for trailing spaces for lists & dictionaries so these are explained like other similar code already is.
- fixes #100
- the issue is already closed, however it wasn't really fixed for macro signatures
Checklist:
- [x] Add tests that demonstrate the correct behavior of the change. Tests should fail without the change.
- [x] Add or update relevant docs, in the docs folder and in code.
- [x] Add an entry in
CHANGES.rstsummarizing the change and linking to the issue. - [x] Add
.. versionchanged::entries in any relevant code docs. - [x] Run
pre-commithooks and fix any issues. - [x] Run
pytestandtox, no tests failed.