Closed domluna closed 5 years ago
rewrites= in for loops to in
Is that a good idea? Using =
in for loops is perfectly legit in julia, why would a document formatter change that? I think we should restrict document formatting to essentially white space changes, but nothing else.
Some styles guides advocate for in
instead of =
It's also more consistent with other languages. Fair enough though, it could be put in a style linter or something like that.
I think having optional, configurable, more invasive and opinionated style formatting would be great! But as a default it seems we should be more conservative.
doc format doesn't work for single quote global docs, i.e.:
"Test for function definition expressions."
isdef(ex) = ismatch(or_(:(function _(__) _ end),
:(f_(__) = _)),
ex)
I agree on the need for this to be optional, could you add a struct that gets passed to the various pass
functions? i.e. a struct with a convert_iterator_ops
field.
For the above what do you expect the formatter to do?
@ZacLN it should align to
"""
Test for function definition expressions.
"""
isdef(ex) = ismatch(or_(:(function _(__) _ end),
:(f_(__) = _)),
ex)
which it now does.
Added a for loop option and docstrings with escapes that turn into CSTParser.EXPR{CSTParse.StringH}
are correctly formatted. I added methods to CSTParser.str_value
to do this, https://github.com/ZacLN/DocumentFormat.jl/pull/26/files#diff-8f8b649677f922163282f3d951be629aR107.
Side note, any objections to having a more functional CSTParser.str_value
? Essentially getting closer to CSTParser.str_value(CSTParse.parse(s)) == s
.
I've been using https://raw.githubusercontent.com/MikeInnes/MacroTools.jl/master/src/utils.jl to test the output and it formats the entire file now.
@ZacLN this should be g2g pending comments.
Side note: I'm working on a width aware formatter in the same vein as http://homepages.inf.ed.ac.uk/wadler/papers/prettier/prettier.pdf in a separate branch.
Thans Dom, I'll have a look at this tomorrow
@ZacLN thanks, I've merged your changes.
add for loop pass, rewrites
=
in for loops toin
add docstring pass which normalizes all global docstrings tothe above also simplifies indenting the initial line of the docstring.