Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: scripts/doxygen.js

Issue 29350140: Issue 4353 - Remove non standard for each syntax (Closed)
Patch Set: Created Aug. 24, 2016, 11:08 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 // This is a complex script used for producing doxygen-readable input 1 // This is a complex script used for producing doxygen-readable input
2 2
3 /* The following is a sample doxygen input file: 3 /* The following is a sample doxygen input file:
4 FILE doxygen.js 4 FILE doxygen.js
5 // Documentation for thing 5 // Documentation for thing
6 0:0 VARIABLE variable1 6 0:0 VARIABLE variable1
7 // More documentation 7 // More documentation
8 1:0 FUNCTION function ARGS a b c 8 1:0 FUNCTION function ARGS a b c
9 // Yet more documentation 9 // Yet more documentation
10 25:0 CLASS clazz INHERITS base1 base2 10 25:0 CLASS clazz INHERITS base1 base2
11 40:2 CLASS VARIABLE clazzvar 11 40:2 CLASS VARIABLE clazzvar
12 41:2 CLASS METHOD clazzfunc ARGS 12 41:2 CLASS METHOD clazzfunc ARGS
13 52:2 CLASS GETTER vara ARGS 13 52:2 CLASS GETTER vara ARGS
14 // Some Constant 14 // Some Constant
15 101:0 CONSTANT const1 VALUE 10 15 101:0 CONSTANT const1 VALUE 10
16 */ 16 */
17 17
18 include("../utils/dumpast.js"); 18 include("../utils/dumpast.js");
19 include("../utils/cleanast.js"); 19 include("../utils/cleanast.js");
20 include("../utils/comments.js"); 20 include("../utils/comments.js");
21 include("../utils/jstypes.js"); 21 include("../utils/jstypes.js");
22 22
23 function process_js(ast, f) { 23 function process_js(ast, f) {
24 _print("FILE " + f); 24 _print("FILE " + f);
25 function loc(l) { 25 function loc(l) {
26 return l.line + ":" + l.column; 26 return l.line + ":" + l.column;
27 } 27 }
28 let toplevel = clean_ast(ast); 28 let toplevel = clean_ast(ast);
29 associate_comments(f, toplevel); 29 associate_comments(f, toplevel);
30 for each (let v in toplevel.variables) { 30 for (let v of toplevel.variables) {
31 if (v.comment) 31 if (v.comment)
32 _print(v.comment); 32 _print(v.comment);
33 _print(loc(v.loc) + " VARIABLE " + v.name); 33 _print(loc(v.loc) + " VARIABLE " + v.name);
34 } 34 }
35 for each (let v in toplevel.constants) { 35 for (let v of toplevel.constants) {
36 if (v.comment) 36 if (v.comment)
37 _print(v.comment); 37 _print(v.comment);
38 _print(loc(v.loc) + " CONST " + v.name); 38 _print(loc(v.loc) + " CONST " + v.name);
39 } 39 }
40 for each (let v in toplevel.objects) { 40 for (let v of toplevel.objects) {
41 divine_inheritance(v, toplevel.constants); 41 divine_inheritance(v, toplevel.constants);
42 if (v.comment) 42 if (v.comment)
43 _print(v.comment); 43 _print(v.comment);
44 let inherits = v.inherits ? (" INHERITS " + v.inherits.join(", ")) : ""; 44 let inherits = v.inherits ? (" INHERITS " + v.inherits.join(", ")) : "";
45 _print(loc(v.loc) + " CLASS " + v.name + inherits); 45 _print(loc(v.loc) + " CLASS " + v.name + inherits);
46 let attrs = { METHOD: v.functions, VARIABLE: v.variables, GETTER: v.getters, 46 let attrs = { METHOD: v.functions, VARIABLE: v.variables, GETTER: v.getters,
47 SETTER: v.setters }; 47 SETTER: v.setters };
48 for (let attr in attrs) { 48 for (let attr in attrs) {
49 for (let name in attrs[attr]) { 49 for (let name in attrs[attr]) {
50 if (attrs[attr][name].comment) 50 if (attrs[attr][name].comment)
51 _print(attrs[attr][name].comment); 51 _print(attrs[attr][name].comment);
52 _print(loc(attrs[attr][name].loc) + " CLASS " + attr + " " + name); 52 _print(loc(attrs[attr][name].loc) + " CLASS " + attr + " " + name);
53 } 53 }
54 } 54 }
55 _print("CLASS END"); 55 _print("CLASS END");
56 } 56 }
57 for each (let v in toplevel.classes) { 57 for (let v of toplevel.classes) {
58 divine_inheritance(v, toplevel.constants); 58 divine_inheritance(v, toplevel.constants);
59 if (v.constructor && v.constructor.comment) 59 if (v.constructor && v.constructor.comment)
60 _print(v.constructor.comment); 60 _print(v.constructor.comment);
61 if (v.comment) 61 if (v.comment)
62 _print(v.comment); 62 _print(v.comment);
63 let inherits = v.inherits ? (" INHERITS " + v.inherits.join(", ")) : ""; 63 let inherits = v.inherits ? (" INHERITS " + v.inherits.join(", ")) : "";
64 _print(loc(v.loc) + " CLASS " + v.name + inherits); 64 _print(loc(v.loc) + " CLASS " + v.name + inherits);
65 let attrs = { METHOD: v.functions, VARIABLE: v.variables, GETTER: v.getters, 65 let attrs = { METHOD: v.functions, VARIABLE: v.variables, GETTER: v.getters,
66 SETTER: v.setters }; 66 SETTER: v.setters };
67 for (let attr in attrs) { 67 for (let attr in attrs) {
68 for (let name in attrs[attr]) { 68 for (let name in attrs[attr]) {
69 if (attrs[attr][name].comment) 69 if (attrs[attr][name].comment)
70 _print(attrs[attr][name].comment); 70 _print(attrs[attr][name].comment);
71 _print(loc(attrs[attr][name].loc) + " CLASS " + attr + " " + name); 71 _print(loc(attrs[attr][name].loc) + " CLASS " + attr + " " + name);
72 } 72 }
73 } 73 }
74 _print("CLASS END"); 74 _print("CLASS END");
75 } 75 }
76 for each (let v in toplevel.functions) { 76 for (let v of toplevel.functions) {
77 if (v.comment) 77 if (v.comment)
78 _print(v.comment); 78 _print(v.comment);
79 _print(loc(v.loc) + " FUNCTION " + v.name); 79 _print(loc(v.loc) + " FUNCTION " + v.name);
80 } 80 }
81 } 81 }
OLDNEW
« scripts/decompile.js ('K') | « scripts/decompile.js ('k') | scripts/dxr.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld