sc-docs 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/.gitmodules +3 -0
- data/Gemfile +5 -0
- data/Gemfile.lock +48 -0
- data/LICENSE +21 -0
- data/README.md +59 -0
- data/bin/sc-docs +5 -0
- data/lib/sc_docs.rb +3 -0
- data/lib/sc_docs/cli.rb +54 -0
- data/lib/sc_docs/docs/Buildfile +8 -0
- data/lib/sc_docs/docs/README +8 -0
- data/lib/sc_docs/docs/apps/docs/Buildfile +15 -0
- data/lib/sc_docs/docs/apps/docs/controllers/classes.js +27 -0
- data/lib/sc_docs/docs/apps/docs/controllers/search_controller.js +62 -0
- data/lib/sc_docs/docs/apps/docs/controllers/selected_class.js +143 -0
- data/lib/sc_docs/docs/apps/docs/core.js +148 -0
- data/lib/sc_docs/docs/apps/docs/main.js +41 -0
- data/lib/sc_docs/docs/apps/docs/models/class.js +63 -0
- data/lib/sc_docs/docs/apps/docs/models/entity.js +29 -0
- data/lib/sc_docs/docs/apps/docs/models/method.js +79 -0
- data/lib/sc_docs/docs/apps/docs/models/property.js +48 -0
- data/lib/sc_docs/docs/apps/docs/resources/images/method_icon.png +0 -0
- data/lib/sc_docs/docs/apps/docs/resources/images/property_icon.png +0 -0
- data/lib/sc_docs/docs/apps/docs/resources/loading.rhtml +9 -0
- data/lib/sc_docs/docs/apps/docs/resources/main_page.css +156 -0
- data/lib/sc_docs/docs/apps/docs/resources/main_page.js +91 -0
- data/lib/sc_docs/docs/apps/docs/resources/templates/details.handlebars +81 -0
- data/lib/sc_docs/docs/apps/docs/resources/templates/extensions/signature.js +0 -0
- data/lib/sc_docs/docs/apps/docs/system/jquery_ui.js +62 -0
- data/lib/sc_docs/docs/apps/docs/system/showdown.js +1297 -0
- data/lib/sc_docs/docs/apps/docs/theme.js +29 -0
- data/lib/sc_docs/docs/apps/docs/views/detail_list.js +24 -0
- data/lib/sc_docs/docs/apps/docs/views/master_list.js +35 -0
- data/lib/sc_docs/docs/apps/docs/views/methods_collection.js +80 -0
- data/lib/sc_docs/docs/apps/docs/views/properties_collection.js +9 -0
- data/lib/sc_docs/generator.rb +145 -0
- data/lib/sc_docs/server.rb +21 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/allclasses.tmpl +31 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/allfiles.tmpl +66 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/class.tmpl +437 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/index.tmpl +52 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/css/api.css +619 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/img/apidocs.jpg +0 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/img/apidocs.png +0 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/img/clearinput.png +0 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/img/cross.png +0 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/img/ddiagonal.png +0 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/img/diagonal.png +0 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/img/docbullet.jpg +0 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/img/docbullet.png +0 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/img/glow.png +0 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/img/logo.png +0 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/img/pixels.png +0 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/img/search.png +0 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/js/api.js +134 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/js/jquery-bbq.js +18 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/js/lib/jquery-1.5.1.min.js +16 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/js/lib/modernizr-1.7.min.js +2 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/js/plugin.js +1 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/output/js/script.js +5 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/publish.js +200 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/static/default.css +300 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/static/header.html +19 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/static/index.html +19 -0
- data/lib/sc_docs/templates/docs.sproutcore.com/symbol.tmpl +35 -0
- data/lib/sc_docs/templates/sc_fixture/publish.js +632 -0
- data/lib/sc_docs/version.rb +4 -0
- data/sc_docs.gemspec +27 -0
- data/vendor/jsdoc/README.txt +109 -0
- data/vendor/jsdoc/app/frame.js +33 -0
- data/vendor/jsdoc/app/frame/Chain.js +102 -0
- data/vendor/jsdoc/app/frame/Dumper.js +144 -0
- data/vendor/jsdoc/app/frame/Hash.js +84 -0
- data/vendor/jsdoc/app/frame/Link.js +173 -0
- data/vendor/jsdoc/app/frame/Namespace.js +10 -0
- data/vendor/jsdoc/app/frame/Opt.js +134 -0
- data/vendor/jsdoc/app/frame/Reflection.js +26 -0
- data/vendor/jsdoc/app/frame/String.js +93 -0
- data/vendor/jsdoc/app/frame/Testrun.js +129 -0
- data/vendor/jsdoc/app/handlers/FOODOC.js +26 -0
- data/vendor/jsdoc/app/handlers/XMLDOC.js +26 -0
- data/vendor/jsdoc/app/handlers/XMLDOC/DomReader.js +159 -0
- data/vendor/jsdoc/app/handlers/XMLDOC/XMLDoc.js +16 -0
- data/vendor/jsdoc/app/handlers/XMLDOC/XMLParse.js +292 -0
- data/vendor/jsdoc/app/lib/JSDOC.js +106 -0
- data/vendor/jsdoc/app/lib/JSDOC/DocComment.js +204 -0
- data/vendor/jsdoc/app/lib/JSDOC/DocTag.js +294 -0
- data/vendor/jsdoc/app/lib/JSDOC/JsDoc.js +140 -0
- data/vendor/jsdoc/app/lib/JSDOC/JsPlate.js +109 -0
- data/vendor/jsdoc/app/lib/JSDOC/Lang.js +144 -0
- data/vendor/jsdoc/app/lib/JSDOC/Parser.js +146 -0
- data/vendor/jsdoc/app/lib/JSDOC/PluginManager.js +33 -0
- data/vendor/jsdoc/app/lib/JSDOC/Symbol.js +644 -0
- data/vendor/jsdoc/app/lib/JSDOC/SymbolSet.js +243 -0
- data/vendor/jsdoc/app/lib/JSDOC/TextStream.js +41 -0
- data/vendor/jsdoc/app/lib/JSDOC/Token.js +18 -0
- data/vendor/jsdoc/app/lib/JSDOC/TokenReader.js +332 -0
- data/vendor/jsdoc/app/lib/JSDOC/TokenStream.js +133 -0
- data/vendor/jsdoc/app/lib/JSDOC/Util.js +32 -0
- data/vendor/jsdoc/app/lib/JSDOC/Walker.js +507 -0
- data/vendor/jsdoc/app/main.js +111 -0
- data/vendor/jsdoc/app/plugins/commentSrcJson.js +20 -0
- data/vendor/jsdoc/app/plugins/frameworkPrototype.js +16 -0
- data/vendor/jsdoc/app/plugins/functionCall.js +10 -0
- data/vendor/jsdoc/app/plugins/publishSrcHilite.js +62 -0
- data/vendor/jsdoc/app/plugins/symbolLink.js +10 -0
- data/vendor/jsdoc/app/plugins/tagParamConfig.js +31 -0
- data/vendor/jsdoc/app/plugins/tagSynonyms.js +43 -0
- data/vendor/jsdoc/app/run.js +297 -0
- data/vendor/jsdoc/app/t/TestDoc.js +144 -0
- data/vendor/jsdoc/app/t/runner.js +13 -0
- data/vendor/jsdoc/app/test.js +342 -0
- data/vendor/jsdoc/app/test/addon.js +24 -0
- data/vendor/jsdoc/app/test/anon_inner.js +14 -0
- data/vendor/jsdoc/app/test/augments.js +31 -0
- data/vendor/jsdoc/app/test/augments2.js +26 -0
- data/vendor/jsdoc/app/test/borrows.js +46 -0
- data/vendor/jsdoc/app/test/borrows2.js +23 -0
- data/vendor/jsdoc/app/test/config.js +22 -0
- data/vendor/jsdoc/app/test/constructs.js +18 -0
- data/vendor/jsdoc/app/test/encoding.js +10 -0
- data/vendor/jsdoc/app/test/encoding_other.js +12 -0
- data/vendor/jsdoc/app/test/event.js +54 -0
- data/vendor/jsdoc/app/test/exports.js +14 -0
- data/vendor/jsdoc/app/test/functions_anon.js +39 -0
- data/vendor/jsdoc/app/test/functions_nested.js +33 -0
- data/vendor/jsdoc/app/test/global.js +13 -0
- data/vendor/jsdoc/app/test/globals.js +25 -0
- data/vendor/jsdoc/app/test/ignore.js +10 -0
- data/vendor/jsdoc/app/test/inner.js +16 -0
- data/vendor/jsdoc/app/test/jsdoc_test.js +477 -0
- data/vendor/jsdoc/app/test/lend.js +33 -0
- data/vendor/jsdoc/app/test/memberof.js +19 -0
- data/vendor/jsdoc/app/test/memberof2.js +38 -0
- data/vendor/jsdoc/app/test/memberof3.js +33 -0
- data/vendor/jsdoc/app/test/memberof_constructor.js +17 -0
- data/vendor/jsdoc/app/test/module.js +17 -0
- data/vendor/jsdoc/app/test/multi_methods.js +25 -0
- data/vendor/jsdoc/app/test/name.js +19 -0
- data/vendor/jsdoc/app/test/namespace_nested.js +23 -0
- data/vendor/jsdoc/app/test/nocode.js +13 -0
- data/vendor/jsdoc/app/test/oblit_anon.js +20 -0
- data/vendor/jsdoc/app/test/overview.js +20 -0
- data/vendor/jsdoc/app/test/param_inline.js +37 -0
- data/vendor/jsdoc/app/test/params_optional.js +8 -0
- data/vendor/jsdoc/app/test/prototype.js +17 -0
- data/vendor/jsdoc/app/test/prototype_nested.js +9 -0
- data/vendor/jsdoc/app/test/prototype_oblit.js +13 -0
- data/vendor/jsdoc/app/test/prototype_oblit_constructor.js +24 -0
- data/vendor/jsdoc/app/test/public.js +10 -0
- data/vendor/jsdoc/app/test/scripts/code.js +5 -0
- data/vendor/jsdoc/app/test/scripts/notcode.txt +5 -0
- data/vendor/jsdoc/app/test/shared.js +42 -0
- data/vendor/jsdoc/app/test/shared2.js +2 -0
- data/vendor/jsdoc/app/test/shortcuts.js +22 -0
- data/vendor/jsdoc/app/test/static_this.js +13 -0
- data/vendor/jsdoc/app/test/synonyms.js +31 -0
- data/vendor/jsdoc/app/test/tosource.js +23 -0
- data/vendor/jsdoc/app/test/variable_redefine.js +14 -0
- data/vendor/jsdoc/changes.txt +127 -0
- data/vendor/jsdoc/conf/sample.conf +31 -0
- metadata +240 -0
@@ -0,0 +1,133 @@
|
|
1
|
+
if (typeof JSDOC == "undefined") JSDOC = {};
|
2
|
+
|
3
|
+
/**
|
4
|
+
@constructor
|
5
|
+
*/
|
6
|
+
JSDOC.TokenStream = function(tokens) {
|
7
|
+
this.tokens = (tokens || []);
|
8
|
+
this.rewind();
|
9
|
+
}
|
10
|
+
|
11
|
+
/**
|
12
|
+
@constructor
|
13
|
+
@private
|
14
|
+
*/
|
15
|
+
function VoidToken(/**String*/type) {
|
16
|
+
this.toString = function() {return "<VOID type=\""+type+"\">"};
|
17
|
+
this.is = function(){return false;}
|
18
|
+
}
|
19
|
+
|
20
|
+
JSDOC.TokenStream.prototype.rewind = function() {
|
21
|
+
this.cursor = -1;
|
22
|
+
}
|
23
|
+
|
24
|
+
/**
|
25
|
+
@type JSDOC.Token
|
26
|
+
*/
|
27
|
+
JSDOC.TokenStream.prototype.look = function(/**Number*/n, /**Boolean*/considerWhitespace) {
|
28
|
+
if (typeof n == "undefined") n = 0;
|
29
|
+
|
30
|
+
if (considerWhitespace == true) {
|
31
|
+
if (this.cursor+n < 0 || this.cursor+n > this.tokens.length) return {};
|
32
|
+
return this.tokens[this.cursor+n];
|
33
|
+
}
|
34
|
+
else {
|
35
|
+
var count = 0;
|
36
|
+
var i = this.cursor;
|
37
|
+
|
38
|
+
while (true) {
|
39
|
+
if (i < 0) return new JSDOC.Token("", "VOID", "START_OF_STREAM");
|
40
|
+
else if (i > this.tokens.length) return new JSDOC.Token("", "VOID", "END_OF_STREAM");
|
41
|
+
|
42
|
+
if (i != this.cursor && (this.tokens[i] === undefined || this.tokens[i].is("WHIT"))) {
|
43
|
+
if (n < 0) i--; else i++;
|
44
|
+
continue;
|
45
|
+
}
|
46
|
+
|
47
|
+
if (count == Math.abs(n)) {
|
48
|
+
return this.tokens[i];
|
49
|
+
}
|
50
|
+
count++;
|
51
|
+
(n < 0)? i-- : i++;
|
52
|
+
}
|
53
|
+
|
54
|
+
return new JSDOC.Token("", "VOID", "STREAM_ERROR"); // because null isn't an object and caller always expects an object
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
/**
|
59
|
+
@type JSDOC.Token|JSDOC.Token[]
|
60
|
+
*/
|
61
|
+
JSDOC.TokenStream.prototype.next = function(/**Number*/howMany) {
|
62
|
+
if (typeof howMany == "undefined") howMany = 1;
|
63
|
+
if (howMany < 1) return null;
|
64
|
+
var got = [];
|
65
|
+
|
66
|
+
for (var i = 1; i <= howMany; i++) {
|
67
|
+
if (this.cursor+i >= this.tokens.length) {
|
68
|
+
return null;
|
69
|
+
}
|
70
|
+
got.push(this.tokens[this.cursor+i]);
|
71
|
+
}
|
72
|
+
this.cursor += howMany;
|
73
|
+
|
74
|
+
if (howMany == 1) {
|
75
|
+
return got[0];
|
76
|
+
}
|
77
|
+
else return got;
|
78
|
+
}
|
79
|
+
|
80
|
+
/**
|
81
|
+
@type JSDOC.Token[]
|
82
|
+
*/
|
83
|
+
JSDOC.TokenStream.prototype.balance = function(/**String*/start, /**String*/stop) {
|
84
|
+
if (!stop) stop = JSDOC.Lang.matching(start);
|
85
|
+
|
86
|
+
var depth = 0;
|
87
|
+
var got = [];
|
88
|
+
var started = false;
|
89
|
+
|
90
|
+
while ((token = this.look())) {
|
91
|
+
if (token.is(start)) {
|
92
|
+
depth++;
|
93
|
+
started = true;
|
94
|
+
}
|
95
|
+
|
96
|
+
if (started) {
|
97
|
+
got.push(token);
|
98
|
+
}
|
99
|
+
|
100
|
+
if (token.is(stop)) {
|
101
|
+
depth--;
|
102
|
+
if (depth == 0) return got;
|
103
|
+
}
|
104
|
+
if (!this.next()) break;
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
JSDOC.TokenStream.prototype.getMatchingToken = function(/**String*/start, /**String*/stop) {
|
109
|
+
var depth = 0;
|
110
|
+
var cursor = this.cursor;
|
111
|
+
|
112
|
+
if (!start) {
|
113
|
+
start = JSDOC.Lang.matching(stop);
|
114
|
+
depth = 1;
|
115
|
+
}
|
116
|
+
if (!stop) stop = JSDOC.Lang.matching(start);
|
117
|
+
|
118
|
+
while ((token = this.tokens[cursor])) {
|
119
|
+
if (token.is(start)) {
|
120
|
+
depth++;
|
121
|
+
}
|
122
|
+
|
123
|
+
if (token.is(stop) && cursor) {
|
124
|
+
depth--;
|
125
|
+
if (depth == 0) return this.tokens[cursor];
|
126
|
+
}
|
127
|
+
cursor++;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
|
131
|
+
JSDOC.TokenStream.prototype.insertAhead = function(/**JSDOC.Token*/token) {
|
132
|
+
this.tokens.splice(this.cursor+1, 0, token);
|
133
|
+
}
|
@@ -0,0 +1,32 @@
|
|
1
|
+
/**
|
2
|
+
* @namespace
|
3
|
+
* @deprecated Use {@link FilePath} instead.
|
4
|
+
*/
|
5
|
+
JSDOC.Util = {
|
6
|
+
}
|
7
|
+
|
8
|
+
/**
|
9
|
+
* @deprecated Use {@link FilePath.fileName} instead.
|
10
|
+
*/
|
11
|
+
JSDOC.Util.fileName = function(path) {
|
12
|
+
LOG.warn("JSDOC.Util.fileName is deprecated. Use FilePath.fileName instead.");
|
13
|
+
var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0);
|
14
|
+
return path.substring(nameStart);
|
15
|
+
}
|
16
|
+
|
17
|
+
/**
|
18
|
+
* @deprecated Use {@link FilePath.fileExtension} instead.
|
19
|
+
*/
|
20
|
+
JSDOC.Util.fileExtension = function(filename) {
|
21
|
+
LOG.warn("JSDOC.Util.fileExtension is deprecated. Use FilePath.fileExtension instead.");
|
22
|
+
return filename.split(".").pop().toLowerCase();
|
23
|
+
};
|
24
|
+
|
25
|
+
/**
|
26
|
+
* @deprecated Use {@link FilePath.dir} instead.
|
27
|
+
*/
|
28
|
+
JSDOC.Util.dir = function(path) {
|
29
|
+
LOG.warn("JSDOC.Util.dir is deprecated. Use FilePath.dir instead.");
|
30
|
+
var nameStart = Math.max(path.lastIndexOf("/")+1, path.lastIndexOf("\\")+1, 0);
|
31
|
+
return path.substring(0, nameStart-1);
|
32
|
+
}
|
@@ -0,0 +1,507 @@
|
|
1
|
+
if (typeof JSDOC == "undefined") JSDOC = {};
|
2
|
+
|
3
|
+
/** @constructor */
|
4
|
+
JSDOC.Walker = function(/**JSDOC.TokenStream*/ts) {
|
5
|
+
this.init();
|
6
|
+
if (typeof ts != "undefined") {
|
7
|
+
this.walk(ts);
|
8
|
+
}
|
9
|
+
}
|
10
|
+
|
11
|
+
JSDOC.Walker.prototype.init = function() {
|
12
|
+
this.ts = null;
|
13
|
+
|
14
|
+
var globalSymbol = new JSDOC.Symbol("_global_", [], "GLOBAL", new JSDOC.DocComment(""));
|
15
|
+
globalSymbol.isNamespace = true;
|
16
|
+
globalSymbol.srcFile = "";
|
17
|
+
globalSymbol.isPrivate = false;
|
18
|
+
JSDOC.Parser.addSymbol(globalSymbol);
|
19
|
+
this.lastDoc = null;
|
20
|
+
this.token = null;
|
21
|
+
|
22
|
+
/**
|
23
|
+
The chain of symbols under which we are currently nested.
|
24
|
+
@type Array
|
25
|
+
*/
|
26
|
+
this.namescope = [globalSymbol];
|
27
|
+
this.namescope.last = function(n){ if (!n) n = 0; return this[this.length-(1+n)] || "" };
|
28
|
+
}
|
29
|
+
|
30
|
+
JSDOC.Walker.prototype.walk = function(/**JSDOC.TokenStream*/ts) {
|
31
|
+
this.ts = ts;
|
32
|
+
while (this.token = this.ts.look()) {
|
33
|
+
if (this.token.popNamescope) {
|
34
|
+
|
35
|
+
var symbol = this.namescope.pop();
|
36
|
+
if (symbol.is("FUNCTION")) {
|
37
|
+
if (this.ts.look(1).is("LEFT_PAREN") && symbol.comment.getTag("function").length == 0) {
|
38
|
+
symbol.isa = "OBJECT";
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
this.step();
|
43
|
+
if (!this.ts.next()) break;
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
JSDOC.Walker.prototype.step = function() {
|
48
|
+
if (this.token.is("JSDOC")) { // it's a doc comment
|
49
|
+
|
50
|
+
var doc = new JSDOC.DocComment(this.token.data);
|
51
|
+
|
52
|
+
|
53
|
+
if (doc.getTag("exports").length > 0) {
|
54
|
+
var exports = doc.getTag("exports")[0];
|
55
|
+
|
56
|
+
exports.desc.match(/(\S+) as (\S+)/i);
|
57
|
+
var n1 = RegExp.$1;
|
58
|
+
var n2 = RegExp.$2;
|
59
|
+
|
60
|
+
if (!n1 && n2) throw "@exports tag requires a value like: 'name as ns.name'";
|
61
|
+
|
62
|
+
JSDOC.Parser.rename = (JSDOC.Parser.rename || {});
|
63
|
+
JSDOC.Parser.rename[n1] = n2
|
64
|
+
}
|
65
|
+
|
66
|
+
if (doc.getTag("lends").length > 0) {
|
67
|
+
var lends = doc.getTag("lends")[0];
|
68
|
+
|
69
|
+
var name = lends.desc
|
70
|
+
if (!name) throw "@lends tag requires a value.";
|
71
|
+
|
72
|
+
var symbol = new JSDOC.Symbol(name, [], "OBJECT", doc);
|
73
|
+
|
74
|
+
this.namescope.push(symbol);
|
75
|
+
|
76
|
+
var matching = this.ts.getMatchingToken("LEFT_CURLY");
|
77
|
+
if (matching) matching.popNamescope = name;
|
78
|
+
else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
|
79
|
+
|
80
|
+
this.lastDoc = null;
|
81
|
+
return true;
|
82
|
+
}
|
83
|
+
else if (doc.getTag("name").length > 0 && doc.getTag("overview").length == 0) { // it's a virtual symbol
|
84
|
+
var virtualName = doc.getTag("name")[0].desc;
|
85
|
+
if (!virtualName) throw "@name tag requires a value.";
|
86
|
+
|
87
|
+
if (doc.getTag("memberOf").length > 0) {
|
88
|
+
virtualName = (doc.getTag("memberOf")[0] + "." + virtualName)
|
89
|
+
.replace(/([#.])\./, "$1");
|
90
|
+
doc.deleteTag("memberOf");
|
91
|
+
}
|
92
|
+
|
93
|
+
var symbol = new JSDOC.Symbol(virtualName, [], "VIRTUAL", doc);
|
94
|
+
|
95
|
+
JSDOC.Parser.addSymbol(symbol);
|
96
|
+
|
97
|
+
this.lastDoc = null;
|
98
|
+
return true;
|
99
|
+
}
|
100
|
+
else if (doc.meta) { // it's a meta doclet
|
101
|
+
if (doc.meta == "@+") JSDOC.DocComment.shared = doc.src;
|
102
|
+
else if (doc.meta == "@-") JSDOC.DocComment.shared = "";
|
103
|
+
else if (doc.meta == "nocode+") JSDOC.Parser.conf.ignoreCode = true;
|
104
|
+
else if (doc.meta == "nocode-") JSDOC.Parser.conf.ignoreCode = JSDOC.opt.n;
|
105
|
+
else throw "Unrecognized meta comment: "+doc.meta;
|
106
|
+
|
107
|
+
this.lastDoc = null;
|
108
|
+
return true;
|
109
|
+
}
|
110
|
+
else if (doc.getTag("overview").length > 0) { // it's a file overview
|
111
|
+
symbol = new JSDOC.Symbol("", [], "FILE", doc);
|
112
|
+
|
113
|
+
JSDOC.Parser.addSymbol(symbol);
|
114
|
+
|
115
|
+
this.lastDoc = null;
|
116
|
+
return true;
|
117
|
+
}
|
118
|
+
else {
|
119
|
+
this.lastDoc = doc;
|
120
|
+
return false;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
else if (!JSDOC.Parser.conf.ignoreCode) { // it's code
|
124
|
+
if (this.token.is("NAME")) { // it's the name of something
|
125
|
+
var symbol;
|
126
|
+
var name = this.token.data;
|
127
|
+
var doc = null; if (this.lastDoc) doc = this.lastDoc;
|
128
|
+
var params = [];
|
129
|
+
|
130
|
+
// it's inside an anonymous object
|
131
|
+
if (this.ts.look(1).is("COLON") && this.ts.look(-1).is("LEFT_CURLY") && !(this.ts.look(-2).is("JSDOC") || this.namescope.last().comment.getTag("lends").length || this.ts.look(-2).is("ASSIGN") || this.ts.look(-2).is("COLON"))) {
|
132
|
+
name = "$anonymous";
|
133
|
+
name = this.namescope.last().alias+"-"+name
|
134
|
+
|
135
|
+
params = [];
|
136
|
+
|
137
|
+
symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
|
138
|
+
|
139
|
+
JSDOC.Parser.addSymbol(symbol);
|
140
|
+
|
141
|
+
this.namescope.push(symbol);
|
142
|
+
|
143
|
+
var matching = this.ts.getMatchingToken(null, "RIGHT_CURLY");
|
144
|
+
if (matching) matching.popNamescope = name;
|
145
|
+
else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
|
146
|
+
}
|
147
|
+
// function foo() {}
|
148
|
+
else if (this.ts.look(-1).is("FUNCTION") && this.ts.look(1).is("LEFT_PAREN")) {
|
149
|
+
var isInner;
|
150
|
+
|
151
|
+
if (this.lastDoc) doc = this.lastDoc;
|
152
|
+
|
153
|
+
if (doc && doc.getTag("memberOf").length > 0) {
|
154
|
+
name = (doc.getTag("memberOf")[0]+"."+name).replace("#.", "#");
|
155
|
+
doc.deleteTag("memberOf");
|
156
|
+
}
|
157
|
+
else {
|
158
|
+
name = this.namescope.last().alias+"-"+name;
|
159
|
+
if (!this.namescope.last().is("GLOBAL")) isInner = true;
|
160
|
+
}
|
161
|
+
|
162
|
+
if (!this.namescope.last().is("GLOBAL")) isInner = true;
|
163
|
+
|
164
|
+
params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
|
165
|
+
|
166
|
+
symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
|
167
|
+
if (isInner) symbol.isInner = true;
|
168
|
+
|
169
|
+
if (this.ts.look(1).is("JSDOC")) {
|
170
|
+
var inlineReturn = ""+this.ts.look(1).data;
|
171
|
+
inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, "");
|
172
|
+
symbol.type = inlineReturn;
|
173
|
+
}
|
174
|
+
|
175
|
+
JSDOC.Parser.addSymbol(symbol);
|
176
|
+
|
177
|
+
this.namescope.push(symbol);
|
178
|
+
|
179
|
+
var matching = this.ts.getMatchingToken("LEFT_CURLY");
|
180
|
+
if (matching) matching.popNamescope = name;
|
181
|
+
else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
|
182
|
+
}
|
183
|
+
// foo = function() {}
|
184
|
+
else if (this.ts.look(1).is("ASSIGN") && this.ts.look(2).is("FUNCTION")) {
|
185
|
+
var constructs;
|
186
|
+
var isConstructor = false;
|
187
|
+
if (doc && (constructs = doc.getTag("constructs")) && constructs.length) {
|
188
|
+
if (constructs[0].desc) {
|
189
|
+
name = constructs[0].desc;
|
190
|
+
isConstructor = true;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
var isInner;
|
195
|
+
if (this.ts.look(-1).is("VAR") || this.isInner) {
|
196
|
+
if (doc && doc.getTag("memberOf").length > 0) {
|
197
|
+
name = (doc.getTag("memberOf")[0]+"."+name).replace("#.", "#");
|
198
|
+
doc.deleteTag("memberOf");
|
199
|
+
}
|
200
|
+
else {
|
201
|
+
name = this.namescope.last().alias+"-"+name;
|
202
|
+
if (!this.namescope.last().is("GLOBAL")) isInner = true;
|
203
|
+
}
|
204
|
+
if (!this.namescope.last().is("GLOBAL")) isInner = true;
|
205
|
+
}
|
206
|
+
else if (name.indexOf("this.") == 0) {
|
207
|
+
name = this.resolveThis(name);
|
208
|
+
}
|
209
|
+
|
210
|
+
if (this.lastDoc) doc = this.lastDoc;
|
211
|
+
params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
|
212
|
+
|
213
|
+
symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
|
214
|
+
|
215
|
+
if (isInner) symbol.isInner = true;
|
216
|
+
if (isConstructor) symbol.isa = "CONSTRUCTOR";
|
217
|
+
|
218
|
+
if (this.ts.look(1).is("JSDOC")) {
|
219
|
+
var inlineReturn = ""+this.ts.look(1).data;
|
220
|
+
inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, "");
|
221
|
+
symbol.type = inlineReturn;
|
222
|
+
}
|
223
|
+
|
224
|
+
JSDOC.Parser.addSymbol(symbol);
|
225
|
+
|
226
|
+
this.namescope.push(symbol);
|
227
|
+
|
228
|
+
var matching = this.ts.getMatchingToken("LEFT_CURLY");
|
229
|
+
if (matching) matching.popNamescope = name;
|
230
|
+
else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
|
231
|
+
}
|
232
|
+
// foo = new function() {} or foo = (function() {}
|
233
|
+
else if (this.ts.look(1).is("ASSIGN") && (this.ts.look(2).is("NEW") || this.ts.look(2).is("LEFT_PAREN")) && this.ts.look(3).is("FUNCTION")) {
|
234
|
+
var isInner;
|
235
|
+
if (this.ts.look(-1).is("VAR") || this.isInner) {
|
236
|
+
name = this.namescope.last().alias+"-"+name
|
237
|
+
if (!this.namescope.last().is("GLOBAL")) isInner = true;
|
238
|
+
}
|
239
|
+
else if (name.indexOf("this.") == 0) {
|
240
|
+
name = this.resolveThis(name);
|
241
|
+
}
|
242
|
+
|
243
|
+
this.ts.next(3); // advance past the "new" or "("
|
244
|
+
|
245
|
+
if (this.lastDoc) doc = this.lastDoc;
|
246
|
+
params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
|
247
|
+
|
248
|
+
symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
|
249
|
+
if (isInner) symbol.isInner = true;
|
250
|
+
|
251
|
+
if (this.ts.look(1).is("JSDOC")) {
|
252
|
+
var inlineReturn = ""+this.ts.look(1).data;
|
253
|
+
inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, "");
|
254
|
+
symbol.type = inlineReturn;
|
255
|
+
}
|
256
|
+
|
257
|
+
JSDOC.Parser.addSymbol(symbol);
|
258
|
+
|
259
|
+
symbol.scopeType = "INSTANCE";
|
260
|
+
this.namescope.push(symbol);
|
261
|
+
|
262
|
+
var matching = this.ts.getMatchingToken("LEFT_CURLY");
|
263
|
+
if (matching) matching.popNamescope = name;
|
264
|
+
else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
|
265
|
+
}
|
266
|
+
// foo: function() {}
|
267
|
+
else if (this.ts.look(1).is("COLON") && this.ts.look(2).is("FUNCTION")) {
|
268
|
+
name = (this.namescope.last().alias+"."+name).replace("#.", "#");
|
269
|
+
|
270
|
+
if (this.lastDoc) doc = this.lastDoc;
|
271
|
+
params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
|
272
|
+
|
273
|
+
if (doc && doc.getTag("constructs").length) {
|
274
|
+
name = name.replace(/\.prototype(\.|$)/, "#");
|
275
|
+
|
276
|
+
if (name.indexOf("#") > -1) name = name.match(/(^[^#]+)/)[0];
|
277
|
+
else name = this.namescope.last().alias;
|
278
|
+
|
279
|
+
symbol = new JSDOC.Symbol(name, params, "CONSTRUCTOR", doc);
|
280
|
+
}
|
281
|
+
else {
|
282
|
+
symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
|
283
|
+
}
|
284
|
+
|
285
|
+
if (this.ts.look(1).is("JSDOC")) {
|
286
|
+
var inlineReturn = ""+this.ts.look(1).data;
|
287
|
+
inlineReturn = inlineReturn.replace(/(^\/\*\* *| *\*\/$)/g, "");
|
288
|
+
symbol.type = inlineReturn;
|
289
|
+
}
|
290
|
+
|
291
|
+
JSDOC.Parser.addSymbol(symbol);
|
292
|
+
|
293
|
+
this.namescope.push(symbol);
|
294
|
+
|
295
|
+
var matching = this.ts.getMatchingToken("LEFT_CURLY");
|
296
|
+
if (matching) matching.popNamescope = name;
|
297
|
+
else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
|
298
|
+
}
|
299
|
+
// foo = {}
|
300
|
+
else if (this.ts.look(1).is("ASSIGN") && this.ts.look(2).is("LEFT_CURLY")) {
|
301
|
+
var isInner;
|
302
|
+
if (this.ts.look(-1).is("VAR") || this.isInner) {
|
303
|
+
name = this.namescope.last().alias+"-"+name
|
304
|
+
if (!this.namescope.last().is("GLOBAL")) isInner = true;
|
305
|
+
}
|
306
|
+
else if (name.indexOf("this.") == 0) {
|
307
|
+
name = this.resolveThis(name);
|
308
|
+
}
|
309
|
+
|
310
|
+
if (this.lastDoc) doc = this.lastDoc;
|
311
|
+
|
312
|
+
symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
|
313
|
+
if (isInner) symbol.isInner = true;
|
314
|
+
|
315
|
+
|
316
|
+
if (doc) JSDOC.Parser.addSymbol(symbol);
|
317
|
+
|
318
|
+
this.namescope.push(symbol);
|
319
|
+
|
320
|
+
var matching = this.ts.getMatchingToken("LEFT_CURLY");
|
321
|
+
if (matching) matching.popNamescope = name;
|
322
|
+
else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
|
323
|
+
}
|
324
|
+
// var foo;
|
325
|
+
else if (this.ts.look(1).is("SEMICOLON")) {
|
326
|
+
var isInner;
|
327
|
+
|
328
|
+
if (this.ts.look(-1).is("VAR") || this.isInner) {
|
329
|
+
name = this.namescope.last().alias+"-"+name
|
330
|
+
if (!this.namescope.last().is("GLOBAL")) isInner = true;
|
331
|
+
|
332
|
+
if (this.lastDoc) doc = this.lastDoc;
|
333
|
+
|
334
|
+
symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
|
335
|
+
if (isInner) symbol.isInner = true;
|
336
|
+
|
337
|
+
|
338
|
+
if (doc) JSDOC.Parser.addSymbol(symbol);
|
339
|
+
}
|
340
|
+
}
|
341
|
+
// foo = x
|
342
|
+
else if (this.ts.look(1).is("ASSIGN")) {
|
343
|
+
var isInner;
|
344
|
+
if (this.ts.look(-1).is("VAR") || this.isInner) {
|
345
|
+
name = this.namescope.last().alias+"-"+name
|
346
|
+
if (!this.namescope.last().is("GLOBAL")) isInner = true;
|
347
|
+
}
|
348
|
+
else if (name.indexOf("this.") == 0) {
|
349
|
+
name = this.resolveThis(name);
|
350
|
+
}
|
351
|
+
|
352
|
+
if (this.lastDoc) doc = this.lastDoc;
|
353
|
+
|
354
|
+
symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
|
355
|
+
if (isInner) symbol.isInner = true;
|
356
|
+
|
357
|
+
|
358
|
+
if (doc) JSDOC.Parser.addSymbol(symbol);
|
359
|
+
}
|
360
|
+
// foo: {}
|
361
|
+
else if (this.ts.look(1).is("COLON") && this.ts.look(2).is("LEFT_CURLY")) {
|
362
|
+
name = (this.namescope.last().alias+"."+name).replace("#.", "#");
|
363
|
+
|
364
|
+
if (this.lastDoc) doc = this.lastDoc;
|
365
|
+
|
366
|
+
symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
|
367
|
+
|
368
|
+
|
369
|
+
if (doc) JSDOC.Parser.addSymbol(symbol);
|
370
|
+
|
371
|
+
this.namescope.push(symbol);
|
372
|
+
|
373
|
+
var matching = this.ts.getMatchingToken("LEFT_CURLY");
|
374
|
+
if (matching) matching.popNamescope = name;
|
375
|
+
else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
|
376
|
+
}
|
377
|
+
// foo: x
|
378
|
+
else if (this.ts.look(1).is("COLON")) {
|
379
|
+
name = (this.namescope.last().alias+"."+name).replace("#.", "#");;
|
380
|
+
|
381
|
+
if (this.lastDoc) doc = this.lastDoc;
|
382
|
+
|
383
|
+
symbol = new JSDOC.Symbol(name, params, "OBJECT", doc);
|
384
|
+
|
385
|
+
|
386
|
+
if (doc) JSDOC.Parser.addSymbol(symbol);
|
387
|
+
}
|
388
|
+
// foo(...)
|
389
|
+
else if (this.ts.look(1).is("LEFT_PAREN")) {
|
390
|
+
if (typeof JSDOC.PluginManager != "undefined") {
|
391
|
+
var functionCall = {name: name};
|
392
|
+
|
393
|
+
var cursor = this.ts.cursor;
|
394
|
+
params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
|
395
|
+
this.ts.cursor = cursor;
|
396
|
+
|
397
|
+
for (var i = 0; i < params.length; i++)
|
398
|
+
functionCall["arg" + (i + 1)] = params[i].name;
|
399
|
+
|
400
|
+
JSDOC.PluginManager.run("onFunctionCall", functionCall);
|
401
|
+
if (functionCall.doc) {
|
402
|
+
this.ts.insertAhead(new JSDOC.Token(functionCall.doc, "COMM", "JSDOC"));
|
403
|
+
}
|
404
|
+
}
|
405
|
+
}
|
406
|
+
this.lastDoc = null;
|
407
|
+
}
|
408
|
+
else if (this.token.is("FUNCTION")) { // it's an anonymous function
|
409
|
+
if (
|
410
|
+
(!this.ts.look(-1).is("COLON") || !this.ts.look(-1).is("ASSIGN"))
|
411
|
+
&& !this.ts.look(1).is("NAME")
|
412
|
+
) {
|
413
|
+
if (this.lastDoc) doc = this.lastDoc;
|
414
|
+
|
415
|
+
name = "$anonymous";
|
416
|
+
name = this.namescope.last().alias+"-"+name
|
417
|
+
|
418
|
+
params = JSDOC.Walker.onParamList(this.ts.balance("LEFT_PAREN"));
|
419
|
+
|
420
|
+
symbol = new JSDOC.Symbol(name, params, "FUNCTION", doc);
|
421
|
+
|
422
|
+
JSDOC.Parser.addSymbol(symbol);
|
423
|
+
|
424
|
+
this.namescope.push(symbol);
|
425
|
+
|
426
|
+
var matching = this.ts.getMatchingToken("LEFT_CURLY");
|
427
|
+
if (matching) matching.popNamescope = name;
|
428
|
+
else LOG.warn("Mismatched } character. Can't parse code in file " + symbol.srcFile + ".");
|
429
|
+
}
|
430
|
+
}
|
431
|
+
}
|
432
|
+
return true;
|
433
|
+
}
|
434
|
+
|
435
|
+
/**
|
436
|
+
Resolves what "this." means when it appears in a name.
|
437
|
+
@param name The name that starts with "this.".
|
438
|
+
@returns The name with "this." resolved.
|
439
|
+
*/
|
440
|
+
JSDOC.Walker.prototype.resolveThis = function(name) {
|
441
|
+
name.match(/^this\.(.+)$/)
|
442
|
+
var nameFragment = RegExp.$1;
|
443
|
+
if (!nameFragment) return name;
|
444
|
+
|
445
|
+
var symbol = this.namescope.last();
|
446
|
+
var scopeType = symbol.scopeType || symbol.isa;
|
447
|
+
|
448
|
+
// if we are in a constructor function, `this` means the instance
|
449
|
+
if (scopeType == "CONSTRUCTOR") {
|
450
|
+
name = symbol.alias+"#"+nameFragment;
|
451
|
+
}
|
452
|
+
|
453
|
+
// if we are in an anonymous constructor function, `this` means the instance
|
454
|
+
else if (scopeType == "INSTANCE") {
|
455
|
+
name = symbol.alias+"."+nameFragment;
|
456
|
+
}
|
457
|
+
|
458
|
+
// if we are in a function, `this` means the container (possibly the global)
|
459
|
+
else if (scopeType == "FUNCTION") {
|
460
|
+
// in a method of a prototype, so `this` means the constructor
|
461
|
+
if (symbol.alias.match(/(^.*)[#.-][^#.-]+/)) {
|
462
|
+
var parentName = RegExp.$1;
|
463
|
+
var parent = JSDOC.Parser.symbols.getSymbol(parentName);
|
464
|
+
|
465
|
+
if (!parent) {
|
466
|
+
if (JSDOC.Lang.isBuiltin(parentName)) parent = JSDOC.Parser.addBuiltin(parentName);
|
467
|
+
else {
|
468
|
+
if (symbol.alias.indexOf("$anonymous") < 0) // these will be ignored eventually
|
469
|
+
LOG.warn("Trying to document "+symbol.alias+" without first documenting "+parentName+".");
|
470
|
+
}
|
471
|
+
}
|
472
|
+
if (parent) name = parentName+(parent.is("CONSTRUCTOR")?"#":".")+nameFragment;
|
473
|
+
}
|
474
|
+
else {
|
475
|
+
parent = this.namescope.last(1);
|
476
|
+
name = parent.alias+(parent.is("CONSTRUCTOR")?"#":".")+nameFragment;
|
477
|
+
}
|
478
|
+
}
|
479
|
+
// otherwise it means the global
|
480
|
+
else {
|
481
|
+
name = nameFragment;
|
482
|
+
}
|
483
|
+
|
484
|
+
return name;
|
485
|
+
}
|
486
|
+
|
487
|
+
JSDOC.Walker.onParamList = function(/**Array*/paramTokens) {
|
488
|
+
if (!paramTokens) {
|
489
|
+
LOG.warn("Malformed parameter list. Can't parse code.");
|
490
|
+
return [];
|
491
|
+
}
|
492
|
+
var params = [];
|
493
|
+
for (var i = 0, l = paramTokens.length; i < l; i++) {
|
494
|
+
if (paramTokens[i].is("JSDOC")) {
|
495
|
+
var paramType = paramTokens[i].data.replace(/(^\/\*\* *| *\*\/$)/g, "");
|
496
|
+
|
497
|
+
if (paramTokens[i+1] && paramTokens[i+1].is("NAME")) {
|
498
|
+
i++;
|
499
|
+
params.push({type: paramType, name: paramTokens[i].data});
|
500
|
+
}
|
501
|
+
}
|
502
|
+
else if (paramTokens[i].is("NAME")) {
|
503
|
+
params.push({name: paramTokens[i].data});
|
504
|
+
}
|
505
|
+
}
|
506
|
+
return params;
|
507
|
+
}
|