-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdoc.awk
56 lines (46 loc) · 1.39 KB
/
doc.awk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
IN_SCRIPT == 0 && /#!/ {
PRINT = 1;
if (SCOLON > 0) {
print("");
SCOLON = 0;
INDENT = 0;
}
}
IN_SCRIPT == 0 && /#:!/ {
PRINT = 1;
COLON = 1;
}
IN_SCRIPT == 0 && COLON == 1 && /}:/ {
PRINT = 0;
COLON = 0;
SCOLON = 0;
INDENT = 0;
print("}: { ... };\n");
}
{ COMMENT = 0 };
/#/ { COMMENT = 1 };
PRINT == 1 && COMMENT == 0 && IN_SCRIPT == 0 && /=/ { SCOLON += 1; }
PRINT == 1 && COMMENT == 0 && IN_SCRIPT == 0 && /with/ { SCOLON += 1; }
PRINT == 1 && COMMENT == 0 && IN_SCRIPT == 0 && /inherit/ { SCOLON += 1; }
INDENT > 0 && COMMENT == 0 && IN_SCRIPT == 0 && /}[);: ]+/ && ! /[ (]+{/ { INDENT -= 1; }
INDENT > 0 && COMMENT == 0 && IN_SCRIPT == 0 && /^[ ]*in[ ]+/ { INDENT -= 1; }
SCOLON > 0 && COMMENT == 0 && IN_SCRIPT == 1 && /'';/ { INDENT -= 1; IN_SCRIPT = 0; }
PRINT == 1 {
gsub(/^[ \t]+/, "", $0);
for (i = 0; i < INDENT; i++) printf(" ");
print($0);
}
SCOLON > 0 && COMMENT == 0 && IN_SCRIPT == 0 && /[ (]+{/ && ! /}[);: ]+/ { INDENT += 1; }A
SCOLON > 0 && COMMENT == 0 && IN_SCRIPT == 0 && /[ ]+let/ { INDENT += 1; }
SCOLON > 0 && COMMENT == 0 && IN_SCRIPT == 0 && /''$/ { INDENT += 1; IN_SCRIPT = 1; }
SCOLON > 0 && COMMENT == 0 && IN_SCRIPT == 0 && /;/ {
SCOLON -= 1;
if (SCOLON == 0) {
PRINT = 0;
INDENT = 0;
print("");
}
}
PRINT == 1 && SCOLON == 0 && IN_SCRIPT == 0 && /^\s*$/ {
PRINT = 0;
}