Module alphabetical

Module alphabetical 

Source
Expand description

Checks that a list of items is in alphabetical order

Use the following marker in the code:

// tidy-alphabetical-start
fn aaa() {}
fn eee() {}
fn z() {}
// tidy-alphabetical-end

Empty lines and lines starting (ignoring spaces) with // or # (except those starting with #!) are considered comments are are sorted together with the next line (but do not affect sorting).

If the following lines have higher indentation we effectively join them with the current line before comparing it. If the next line with the same indentation starts (ignoring spaces) with a closing delimiter (), [, }) it is joined as well.

E.g.

โ“˜
foo(a,
    b);
bar(
  a,
  b
);
// are treated for sorting purposes as
foo(a, b);
bar(a, b);

Constantsยง

END_MARKER ๐Ÿ”’
START_MARKER ๐Ÿ”’

Functionsยง

check
check_lines ๐Ÿ”’
consume_numeric_prefix ๐Ÿ”’
indentation ๐Ÿ”’
is_close_bracket ๐Ÿ”’
is_empty_or_comment ๐Ÿ”’
sort_section ๐Ÿ”’
Given contents of a section that is enclosed between START_MARKER and END_MARKER, sorts them according to the rules described at the top of the module.
sub_find ๐Ÿ”’
Finds pat in s[range] and returns a range such that s[ret] == pat.
version_sort ๐Ÿ”’