v1.3.0
# styler:sort Styler's first comment directive
Styler will now keep a user-designated list or wordlist (~w sigil) sorted as part of formatting via the use of "comment directives". Elements of the list are sorted by their string representation.
The intention is to remove comments to humans, like # Please keep this list sorted!, in favor of comments to robots: # styler:sort. Personally speaking, Styler is much better at alphabetical-order than I ever will be.
To use the new directive, put it on the line before a list or wordlist.
This example:
# styler:sort
[:c, :a, :b]
# styler:sort
~w(a list of words)
# styler:sort
@country_codes ~w(
en_US
po_PO
fr_CA
ja_JP
)
# styler:sort
a_var =
[
Modules,
In,
A,
List
]Would yield:
# styler:sort
[:a, :b, :c]
# styler:sort
~w(a list of words)
# styler:sort
@country_codes ~w(
en_US
fr_CA
ja_JP
po_PO
)
# styler:sort
a_var =
[
A,
In,
List,
Modules
]