docjs 0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CONCEPT.md +80 -0
- data/DOCUMENTATION.md +41 -0
- data/LICENSE.md +19 -0
- data/README.md +19 -0
- data/RENDERING.md +8 -0
- data/bin/docjs +190 -0
- data/docjs.gemspec +32 -0
- data/lib/boot.rb +34 -0
- data/lib/code_object/base.rb +48 -0
- data/lib/code_object/converter.rb +48 -0
- data/lib/code_object/exceptions.rb +5 -0
- data/lib/code_object/function.rb +84 -0
- data/lib/code_object/object.rb +18 -0
- data/lib/code_object/type.rb +43 -0
- data/lib/configs.rb +53 -0
- data/lib/document/document.rb +25 -0
- data/lib/dom/dom.rb +188 -0
- data/lib/dom/exceptions.rb +12 -0
- data/lib/dom/no_doc.rb +26 -0
- data/lib/dom/node.rb +415 -0
- data/lib/helper/helper.rb +120 -0
- data/lib/helper/linker.rb +130 -0
- data/lib/logger.rb +49 -0
- data/lib/parser/comment.rb +69 -0
- data/lib/parser/comment_parser.rb +90 -0
- data/lib/parser/exceptions.rb +6 -0
- data/lib/parser/meta_container.rb +20 -0
- data/lib/parser/parser.rb +269 -0
- data/lib/processor.rb +123 -0
- data/lib/renderer.rb +108 -0
- data/lib/tasks/render_task.rb +112 -0
- data/lib/thor.rb +27 -0
- data/lib/token/container.rb +84 -0
- data/lib/token/exceptions.rb +6 -0
- data/lib/token/handler.rb +242 -0
- data/lib/token/token.rb +46 -0
- data/templates/application.rb +14 -0
- data/templates/helpers/template.rb +66 -0
- data/templates/resources/css/.sass-cache/98c121fba905284c2c8ca6220fe3c590e5c9ec19/application.scssc +0 -0
- data/templates/resources/css/application.css +836 -0
- data/templates/resources/img/arrow_down.png +0 -0
- data/templates/resources/img/arrow_right.png +0 -0
- data/templates/resources/img/arrow_up.png +0 -0
- data/templates/resources/img/bullet_toggle_minus.png +0 -0
- data/templates/resources/img/bullet_toggle_plus.png +0 -0
- data/templates/resources/img/constructor.png +0 -0
- data/templates/resources/img/function.png +0 -0
- data/templates/resources/img/object.png +0 -0
- data/templates/resources/img/page.png +0 -0
- data/templates/resources/img/prototype.png +0 -0
- data/templates/resources/img/tag.png +0 -0
- data/templates/resources/js/application.js +318 -0
- data/templates/resources/js/jcore.js +129 -0
- data/templates/resources/js/jquery.cookie.js +92 -0
- data/templates/resources/js/jquery.js +16 -0
- data/templates/resources/js/jquery.tooltip.js +77 -0
- data/templates/resources/js/jquery.treeview.js +238 -0
- data/templates/resources/scss/_footer.scss +10 -0
- data/templates/resources/scss/_header.scss +184 -0
- data/templates/resources/scss/_helpers.scss +91 -0
- data/templates/resources/scss/_print.scss +20 -0
- data/templates/resources/scss/_resets.scss +132 -0
- data/templates/resources/scss/_tooltip.scss +26 -0
- data/templates/resources/scss/application.scss +442 -0
- data/templates/tasks/api_index_task.rb +26 -0
- data/templates/tasks/docs_task.rb +33 -0
- data/templates/tasks/json_data_task.rb +55 -0
- data/templates/tasks/typed_task.rb +54 -0
- data/templates/tokens/tokens.rb +22 -0
- data/templates/types/prototype.rb +20 -0
- data/templates/views/api_index.html.erb +21 -0
- data/templates/views/doc_page.html.erb +11 -0
- data/templates/views/function/_detail.html.erb +8 -0
- data/templates/views/function/index.html.erb +53 -0
- data/templates/views/index.html.erb +0 -0
- data/templates/views/layout/application.html.erb +73 -0
- data/templates/views/layout/json.html.erb +3 -0
- data/templates/views/object/index.html.erb +63 -0
- data/templates/views/tokens/_default.html.erb +11 -0
- data/templates/views/tokens/_default_token.html.erb +19 -0
- data/templates/views/tokens/_example.html.erb +2 -0
- data/templates/views/tokens/_examples.html.erb +1 -0
- data/test/code_object/converter.rb +78 -0
- data/test/code_object/prototype.rb +70 -0
- data/test/configs.rb +65 -0
- data/test/docs/README.CONCEPT.md +83 -0
- data/test/docs/README.md +14 -0
- data/test/dom/dom.absolute_nodes.rb +40 -0
- data/test/dom/dom.rb +72 -0
- data/test/dom/node.rb +53 -0
- data/test/integration/converter.rb +72 -0
- data/test/integration/parser_factory.rb +28 -0
- data/test/interactive.rb +7 -0
- data/test/js-files/absolute.js +11 -0
- data/test/js-files/comments_in_strings.js +31 -0
- data/test/js-files/core-doc-relative.js +77 -0
- data/test/js-files/core-doc.js +145 -0
- data/test/js-files/nested.js +34 -0
- data/test/js-files/nested_with_strings.js +35 -0
- data/test/js-files/prototype.js +33 -0
- data/test/js-files/simple.js +17 -0
- data/test/js-files/tokens.js +32 -0
- data/test/parser/comments_in_strings.rb +51 -0
- data/test/parser/intelligent_skip_until.rb +110 -0
- data/test/parser/parser.rb +273 -0
- data/test/rspec_helper.rb +23 -0
- data/test/token/handler.rb +136 -0
- data/test/token/tokens.rb +52 -0
- metadata +184 -0
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,318 @@
|
|
1
|
+
J.modules = J.modules || {};
|
2
|
+
|
3
|
+
J.create('Module', {
|
4
|
+
|
5
|
+
constructor: function(name, module_init, options) {
|
6
|
+
|
7
|
+
options = J.merge({
|
8
|
+
|
9
|
+
selector: '__no-valid-selector__',
|
10
|
+
plugins: {}
|
11
|
+
|
12
|
+
}, options || {});
|
13
|
+
|
14
|
+
// register at J.modules
|
15
|
+
return J.modules[name] = {
|
16
|
+
name: name,
|
17
|
+
init: function() {
|
18
|
+
|
19
|
+
sandbox = {
|
20
|
+
dom: $(options.selector)
|
21
|
+
};
|
22
|
+
|
23
|
+
var reveal = module_init(sandbox) || {};
|
24
|
+
|
25
|
+
for(var key in this.plugins) {
|
26
|
+
if(this.plugins.hasOwnProperty(key) && typeof this.plugins[key] === 'function')
|
27
|
+
J.merge(reveal, this.plugins[key](sandbox, reveal) || {});
|
28
|
+
}
|
29
|
+
|
30
|
+
J.merge(this, reveal);
|
31
|
+
|
32
|
+
return this;
|
33
|
+
|
34
|
+
},
|
35
|
+
plugins: options.plugins
|
36
|
+
};
|
37
|
+
}
|
38
|
+
});
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
Module('Header', function(my) {
|
43
|
+
|
44
|
+
my.settings = {};
|
45
|
+
|
46
|
+
return {
|
47
|
+
settings: my.settings
|
48
|
+
};
|
49
|
+
|
50
|
+
}, {
|
51
|
+
|
52
|
+
selector: '#header',
|
53
|
+
plugins: {
|
54
|
+
|
55
|
+
/**
|
56
|
+
* @mixin treeview
|
57
|
+
*/
|
58
|
+
treeview: function(my, reveal) {
|
59
|
+
|
60
|
+
my.settings.treeview = {
|
61
|
+
collapsed: true,
|
62
|
+
animated: 'fast',
|
63
|
+
persist: 'cookie',
|
64
|
+
cookieOptions: {
|
65
|
+
path: '/'
|
66
|
+
}
|
67
|
+
};
|
68
|
+
|
69
|
+
var apiTree = my.dom.find(".api-browser > ul");
|
70
|
+
|
71
|
+
apiTree.treeview(my.settings.treeview);
|
72
|
+
},
|
73
|
+
|
74
|
+
/**
|
75
|
+
* @mixin collapsible
|
76
|
+
*/
|
77
|
+
collapsible: function(my, reveal) {
|
78
|
+
|
79
|
+
// @section Filling private variables
|
80
|
+
|
81
|
+
my.settings.collapsible = {
|
82
|
+
cookieId: 'header-collapsed',
|
83
|
+
cookieSettings: {
|
84
|
+
path: '/'
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
var buttons = {
|
89
|
+
show: my.dom.find('a.expand'),
|
90
|
+
hide: my.dom.find('a.collapse')
|
91
|
+
};
|
92
|
+
|
93
|
+
var settings = my.settings.collapsible;
|
94
|
+
|
95
|
+
// @section Defining functions
|
96
|
+
|
97
|
+
function collapse() {
|
98
|
+
$.cookie(settings.cookieId, 'true', settings.cookieSettings);
|
99
|
+
my.dom.addClass('collapsed');
|
100
|
+
buttons.hide.hide();
|
101
|
+
buttons.show.show();
|
102
|
+
}
|
103
|
+
|
104
|
+
function uncollapse() {
|
105
|
+
$.cookie(settings.cookieId, 'false', settings.cookieSettings);
|
106
|
+
my.dom.removeClass('collapsed');
|
107
|
+
buttons.hide.show();
|
108
|
+
buttons.show.hide();
|
109
|
+
}
|
110
|
+
|
111
|
+
// @section Event Attachment
|
112
|
+
|
113
|
+
buttons.hide.click(collapse);
|
114
|
+
buttons.show.click(uncollapse);
|
115
|
+
|
116
|
+
// @section Initialization
|
117
|
+
|
118
|
+
if($.cookie(settings.cookieId) == 'true')
|
119
|
+
collapse();
|
120
|
+
|
121
|
+
else uncollapse();
|
122
|
+
|
123
|
+
return {
|
124
|
+
collapse: collapse,
|
125
|
+
uncollapse: uncollapse
|
126
|
+
};
|
127
|
+
},
|
128
|
+
|
129
|
+
apisearch: function(my, reveal) {
|
130
|
+
|
131
|
+
// @section Filling private variables
|
132
|
+
|
133
|
+
my.apisearch = {
|
134
|
+
data: JSDOC.data.apisearch
|
135
|
+
};
|
136
|
+
|
137
|
+
my.settings.apisearch = {
|
138
|
+
|
139
|
+
}
|
140
|
+
|
141
|
+
var search_input = my.dom.find('input#search'),
|
142
|
+
function_list = $('<ul>'),
|
143
|
+
object_list = $('<ul>');
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
function createObject(data) {
|
148
|
+
|
149
|
+
var el = $('<li>', {
|
150
|
+
// forward click to first a
|
151
|
+
click: function() {
|
152
|
+
window.location.href = $(this).find('a:first').attr('href');
|
153
|
+
return false;
|
154
|
+
}
|
155
|
+
})
|
156
|
+
.hide()
|
157
|
+
.data(data)
|
158
|
+
.append($('<a>', {
|
159
|
+
href: JSDOC.root + data.path,
|
160
|
+
html: data.name
|
161
|
+
}));
|
162
|
+
|
163
|
+
|
164
|
+
if(data.namespace != '') {
|
165
|
+
el.append($('<span>', {
|
166
|
+
html: ' (' + data.namespace + ')',
|
167
|
+
'class': 'namespace'
|
168
|
+
}));
|
169
|
+
}
|
170
|
+
return el;
|
171
|
+
}
|
172
|
+
|
173
|
+
|
174
|
+
// returns an { included: [], excluded: [] }
|
175
|
+
function filter(list, filterString) {
|
176
|
+
|
177
|
+
var included = [],
|
178
|
+
excluded = [];
|
179
|
+
|
180
|
+
try {
|
181
|
+
var regexp = RegExp(filterString, 'i');
|
182
|
+
|
183
|
+
$.each(list, function(i, el) {
|
184
|
+
// maybe to slow - check for performance improvements later on
|
185
|
+
if(regexp.test($(el).data('fullname')))
|
186
|
+
included.push(el)
|
187
|
+
else
|
188
|
+
excluded.push(el)
|
189
|
+
});
|
190
|
+
} catch(e) {
|
191
|
+
included = list;
|
192
|
+
}
|
193
|
+
|
194
|
+
return {
|
195
|
+
included: included,
|
196
|
+
excluded: excluded
|
197
|
+
};
|
198
|
+
}
|
199
|
+
|
200
|
+
// shuffles the two lists, like two stacks of cards and invokes callback on each element.
|
201
|
+
// the cards are delayed with timer ms.
|
202
|
+
function shuffle(list1, list2, timer, callback) {
|
203
|
+
|
204
|
+
var args = arguments;
|
205
|
+
|
206
|
+
if(list1.length > list2.length)
|
207
|
+
callback(list1.shift());
|
208
|
+
|
209
|
+
else if(list2.length > 0)
|
210
|
+
callback(list2.shift());
|
211
|
+
|
212
|
+
else if(list1.length > 0)
|
213
|
+
callback(list1.shift());
|
214
|
+
|
215
|
+
else return;
|
216
|
+
|
217
|
+
setTimeout(function() {
|
218
|
+
shuffle.apply(this, args);
|
219
|
+
}, timer);
|
220
|
+
}
|
221
|
+
|
222
|
+
// @section Attach events
|
223
|
+
|
224
|
+
search_input.bind('keyup change click', function() {
|
225
|
+
|
226
|
+
var val = search_input.val();
|
227
|
+
|
228
|
+
if(search_input.val() == "") {
|
229
|
+
my.dom.removeClass('search');
|
230
|
+
|
231
|
+
} else {
|
232
|
+
my.dom.addClass('search');
|
233
|
+
|
234
|
+
var filtered_functions = filter(function_list.children(), val);
|
235
|
+
var filtered_objects = filter(object_list.children(), val);
|
236
|
+
|
237
|
+
$(filtered_functions.included).removeClass('last').last().addClass('last');
|
238
|
+
$(filtered_objects.included).removeClass('last').last().addClass('last');
|
239
|
+
|
240
|
+
shuffle(filtered_functions.included, filtered_objects.included, 5, function(el) {
|
241
|
+
el = $(el);
|
242
|
+
if(!el.is(':visible'))
|
243
|
+
el.css({opacity: 1}).slideDown();
|
244
|
+
});
|
245
|
+
|
246
|
+
shuffle(filtered_functions.excluded, filtered_objects.excluded, 5, function(el) {
|
247
|
+
el = $(el);
|
248
|
+
if(el.is(':visible'))
|
249
|
+
$(el).css({opacity: 0.5}).slideUp();
|
250
|
+
});
|
251
|
+
}
|
252
|
+
});
|
253
|
+
|
254
|
+
search_input.keydown(function(evt) {
|
255
|
+
|
256
|
+
switch(evt.keyCode) {
|
257
|
+
|
258
|
+
case 27:
|
259
|
+
$(this).val('').trigger('change');
|
260
|
+
|
261
|
+
case 13:
|
262
|
+
return false;
|
263
|
+
}
|
264
|
+
});
|
265
|
+
|
266
|
+
// @section Initialize
|
267
|
+
|
268
|
+
|
269
|
+
// On initialization create all elements and then filter them
|
270
|
+
$.each(my.apisearch.data.functions, function(i, el) {
|
271
|
+
function_list.append(createObject(el));
|
272
|
+
});
|
273
|
+
$.each(my.apisearch.data.objects, function(i, el) {
|
274
|
+
object_list.append(createObject(el));
|
275
|
+
});
|
276
|
+
|
277
|
+
my.dom.find('.functions').append(function_list);
|
278
|
+
my.dom.find('.objects').append(object_list);
|
279
|
+
}
|
280
|
+
}
|
281
|
+
});
|
282
|
+
|
283
|
+
|
284
|
+
Module('Body', function(my) {
|
285
|
+
|
286
|
+
var tooltip_ables = my.dom.find('.signature .params .param');
|
287
|
+
tooltip_ables.tooltip();
|
288
|
+
|
289
|
+
}, {
|
290
|
+
selector: '#main > article',
|
291
|
+
plugins: {
|
292
|
+
|
293
|
+
source_code: function(my, reveal) {
|
294
|
+
|
295
|
+
my.dom.find('h3.source').each(function(i, el) {
|
296
|
+
|
297
|
+
var header = $(el).addClass('collapsed'),
|
298
|
+
code = header.next('code').hide();
|
299
|
+
|
300
|
+
header.toggle(function(){
|
301
|
+
header.removeClass('collapsed');
|
302
|
+
code.slideDown();
|
303
|
+
}, function() {
|
304
|
+
code.slideUp(function() { header.addClass('collapsed'); });
|
305
|
+
});
|
306
|
+
});
|
307
|
+
}
|
308
|
+
}
|
309
|
+
});
|
310
|
+
|
311
|
+
|
312
|
+
$(function() {
|
313
|
+
// initialize Modules on Page-load
|
314
|
+
for(var key in J.modules) {
|
315
|
+
if(J.modules.hasOwnProperty(key))
|
316
|
+
J.modules[key].init();
|
317
|
+
}
|
318
|
+
});
|
@@ -0,0 +1,129 @@
|
|
1
|
+
/*!
|
2
|
+
* @object jCore
|
3
|
+
* @version 1.0
|
4
|
+
*
|
5
|
+
* I gained much inspiration from Ext 4.0 and YUI. Also much Kudos to Nicolas
|
6
|
+
* Zakas and Douglas Crockford for their amazing Books about the real JavaScript!
|
7
|
+
*
|
8
|
+
* If you like this, maybe you will like {http://code.google.com/p/joose-js/ joose} as well
|
9
|
+
*
|
10
|
+
* @prop [Number] version
|
11
|
+
* @prop [Object] global Reference to the global namespace. Just in case we need it.
|
12
|
+
*/
|
13
|
+
var global = this;
|
14
|
+
|
15
|
+
var jCore = {
|
16
|
+
version: 1.0,
|
17
|
+
global: global
|
18
|
+
};
|
19
|
+
|
20
|
+
var J = J || jCore;
|
21
|
+
|
22
|
+
(function(J) {
|
23
|
+
|
24
|
+
/**
|
25
|
+
* @function jCore.merge
|
26
|
+
*
|
27
|
+
* Copies (or `merges`) all properties of extension to the original Object.
|
28
|
+
*
|
29
|
+
* @overload jCore.merge( original, extension )
|
30
|
+
* Single extension usage
|
31
|
+
* @param [Object] original The original Object you wan't to extend with new properties
|
32
|
+
* @param [Object] extension The Object, whose properties will be copied to `original`
|
33
|
+
*
|
34
|
+
* @overload jCore.merge( original, extension1, extension2, ... )
|
35
|
+
* Multiple extension usage
|
36
|
+
* @param [Object] original The original Object you wan't to extend with new properties
|
37
|
+
* @param [Object, ...] extensions Each of the following options are interpreted as objects,
|
38
|
+
* whose properties are copied to `original`
|
39
|
+
*
|
40
|
+
* @example
|
41
|
+
* var foo = {
|
42
|
+
* bar: 4,
|
43
|
+
* baz: 'poo'
|
44
|
+
* }
|
45
|
+
*
|
46
|
+
* var foo2 = {
|
47
|
+
* bar: 5,
|
48
|
+
* boo: []
|
49
|
+
*
|
50
|
+
* }
|
51
|
+
*
|
52
|
+
* jCore.merge(foo, foo2) //=> { bar: 5, baz: 'poo', boo: [] }
|
53
|
+
*/
|
54
|
+
J.merge = function() {
|
55
|
+
|
56
|
+
var original = Array.prototype.shift.apply(arguments);
|
57
|
+
extensions = arguments;
|
58
|
+
|
59
|
+
if(extensions.length == 0)
|
60
|
+
return original;
|
61
|
+
|
62
|
+
for(var i=0, len=extensions.length; i<len; i++) {
|
63
|
+
for(var key in extensions[i]) {
|
64
|
+
if(extensions[i].hasOwnProperty(key))
|
65
|
+
original[key] = extensions[i][key];
|
66
|
+
}
|
67
|
+
}
|
68
|
+
return original;
|
69
|
+
};
|
70
|
+
|
71
|
+
/**
|
72
|
+
* @function jCore.create
|
73
|
+
*
|
74
|
+
* Also mitigates the problem of using 'new' to create new instances. After
|
75
|
+
* creating the class Foo with creat, the following versions of instantiation
|
76
|
+
* are totally equivalent:
|
77
|
+
*
|
78
|
+
* Foo("bar");
|
79
|
+
* new Foo("bar");
|
80
|
+
*
|
81
|
+
* @overload J.create(path, options)
|
82
|
+
*/
|
83
|
+
J.create = function(path, inherited, options) {
|
84
|
+
|
85
|
+
// implicitly inherits from Object.prototype
|
86
|
+
if(arguments.length == 2) {
|
87
|
+
options = inherited;
|
88
|
+
inherited = Object;
|
89
|
+
}
|
90
|
+
|
91
|
+
var parts = path.split('.'),
|
92
|
+
name = parts.pop(),
|
93
|
+
context = global;
|
94
|
+
|
95
|
+
for(var i=0, len=parts.length; i<len; i++) {
|
96
|
+
var part = parts[i];
|
97
|
+
context[part] = context[part] || {};
|
98
|
+
context = context[part];
|
99
|
+
}
|
100
|
+
|
101
|
+
// We use a temporary object as prototype
|
102
|
+
var F = function(){};
|
103
|
+
F.prototype = inherited.prototype;
|
104
|
+
|
105
|
+
// now we create our subclass and assign the prototype
|
106
|
+
var Class = function() {};
|
107
|
+
Class.prototype = new F();
|
108
|
+
|
109
|
+
// we introduce a second constructor to prevent the need for "new"
|
110
|
+
var constructor = function() {
|
111
|
+
var instance = new Class();
|
112
|
+
if(options.hasOwnProperty('constructor') && typeof options.constructor === 'function')
|
113
|
+
return options.constructor.apply(instance, arguments) || instance;
|
114
|
+
|
115
|
+
return instance;
|
116
|
+
};
|
117
|
+
|
118
|
+
// merge all options to prototype and override special values, if needed
|
119
|
+
J.merge(Class.prototype, options, {
|
120
|
+
constructor: constructor,
|
121
|
+
superclass: inherited.prototype
|
122
|
+
});
|
123
|
+
|
124
|
+
// save to specified context and return constructor
|
125
|
+
context[name] = constructor;
|
126
|
+
return constructor;
|
127
|
+
};
|
128
|
+
|
129
|
+
})(jCore);
|