jsduck 0.5 → 0.6
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/README.md +30 -2
- data/bin/jsduck +24 -2
- data/jsduck.gemspec +2 -2
- data/lib/jsduck/aggregator.rb +53 -32
- data/lib/jsduck/app.rb +71 -22
- data/lib/jsduck/cfg_table.rb +2 -2
- data/lib/jsduck/class.rb +5 -0
- data/lib/jsduck/css_parser.rb +75 -0
- data/lib/jsduck/doc_formatter.rb +111 -20
- data/lib/jsduck/doc_parser.rb +64 -4
- data/lib/jsduck/event_table.rb +3 -3
- data/lib/jsduck/exporter.rb +11 -9
- data/lib/jsduck/inheritance_tree.rb +2 -7
- data/lib/jsduck/{parser.rb → js_parser.rb} +20 -4
- data/lib/jsduck/lexer.rb +1 -2
- data/lib/jsduck/long_params.rb +4 -8
- data/lib/jsduck/members.rb +15 -1
- data/lib/jsduck/merger.rb +50 -5
- data/lib/jsduck/method_table.rb +4 -8
- data/lib/jsduck/page.rb +20 -9
- data/lib/jsduck/property_table.rb +2 -2
- data/lib/jsduck/relations.rb +4 -0
- data/lib/jsduck/source_file.rb +101 -0
- data/lib/jsduck/{source_formatter.rb → source_writer.rb} +14 -27
- data/lib/jsduck/table.rb +12 -11
- data/template/resources/docs.js +43 -51
- metadata +8 -6
data/lib/jsduck/table.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'jsduck/doc_formatter'
|
2
|
-
|
3
1
|
module JsDuck
|
4
2
|
|
5
3
|
# Base class for creating HTML tables of class members.
|
@@ -12,18 +10,17 @@ module JsDuck
|
|
12
10
|
#
|
13
11
|
# - cls : the class for which to generate the table.
|
14
12
|
#
|
13
|
+
# - formatter : instance of JsDuck::DocFormatter
|
14
|
+
#
|
15
15
|
# - cache : shared cache of already generated HTML rows. If Foo
|
16
16
|
# inherits from Bar and we have already generated members table
|
17
17
|
# for Bar, then we don't have to re-render all the HTML the
|
18
18
|
# methods from Bar, but can just look them up from cache.
|
19
19
|
#
|
20
|
-
def initialize(cls, cache={})
|
20
|
+
def initialize(cls, formatter, cache={})
|
21
21
|
@cls = cls
|
22
|
+
@formatter = formatter
|
22
23
|
@cache = cache
|
23
|
-
@formatter = DocFormatter.new
|
24
|
-
@formatter.context = cls.full_name
|
25
|
-
@formatter.css_class = 'docClass'
|
26
|
-
@formatter.url_template = 'output/%cls%.html'
|
27
24
|
end
|
28
25
|
|
29
26
|
def to_html
|
@@ -57,8 +54,12 @@ module JsDuck
|
|
57
54
|
html = @cache[cache_key] = create_row(item)
|
58
55
|
end
|
59
56
|
inherited = inherited?(item) ? 'inherited' : ''
|
60
|
-
|
61
|
-
|
57
|
+
owner_link = inherited?(item) ? member_link(item) : Class.short_name(item[:member])
|
58
|
+
owner_class = @cls.full_name
|
59
|
+
html = html.sub(/!!--inherited--!!/, inherited)
|
60
|
+
html = html.sub(/!!--owner-link--!!/, owner_link)
|
61
|
+
html = html.sub(/!!--owner-class--!!/, owner_class)
|
62
|
+
html
|
62
63
|
end
|
63
64
|
|
64
65
|
# Generates HTML for the row, leaving in placeholders for owner
|
@@ -72,7 +73,7 @@ module JsDuck
|
|
72
73
|
<tr class='#{@row_class} #{expandable} !!--inherited--!!'>
|
73
74
|
<td class='micon'><a href='#expand' class='exi'> </a></td>
|
74
75
|
<td class='sig'>#{signature(item)}<div class='mdesc'>#{description}</div></td>
|
75
|
-
<td class='msource'>!!--owner-
|
76
|
+
<td class='msource'>!!--owner-link--!!</td>
|
76
77
|
</tr>
|
77
78
|
EOHTML
|
78
79
|
end
|
@@ -82,7 +83,7 @@ module JsDuck
|
|
82
83
|
end
|
83
84
|
|
84
85
|
def signature(item)
|
85
|
-
id =
|
86
|
+
id = "!!--owner-class--!!-" + item[:name]
|
86
87
|
src = "source/#{item[:href]}"
|
87
88
|
return "<a id='#{id}'></a><b><a href='#{src}'>#{item[:name]}</a></b>" + signature_suffix(item)
|
88
89
|
end
|
data/template/resources/docs.js
CHANGED
@@ -235,10 +235,9 @@ MainPanel = function(){
|
|
235
235
|
fields: ['cls', 'member', 'type', 'doc']
|
236
236
|
})
|
237
237
|
});
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
});
|
238
|
+
this.searchStore.loadData(Docs.membersData);
|
239
|
+
var records = this.searchStore.getRange();
|
240
|
+
this.searchStore.removeAll();
|
242
241
|
|
243
242
|
|
244
243
|
MainPanel.superclass.constructor.call(this, {
|
@@ -258,25 +257,14 @@ MainPanel = function(){
|
|
258
257
|
autoLoad: {url: 'welcome.html', callback: this.initSearch, scope: this, delay: 100},
|
259
258
|
iconCls:'icon-docs',
|
260
259
|
autoScroll: true,
|
261
|
-
|
262
|
-
|
263
|
-
new Ext.ux.SelectBox({
|
264
|
-
listClass:'x-combo-list-small',
|
265
|
-
width:90,
|
266
|
-
value:'Starts with',
|
267
|
-
id:'search-type',
|
268
|
-
store: new Ext.data.SimpleStore({
|
269
|
-
fields: ['text'],
|
270
|
-
expandData: true,
|
271
|
-
data : ['Starts with', 'Ends with', 'Any match']
|
272
|
-
}),
|
273
|
-
displayField: 'text'
|
274
|
-
}), ' ',
|
260
|
+
tbar: [
|
261
|
+
'Search: ', ' ',
|
275
262
|
new Ext.app.SearchField({
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
263
|
+
width: 340,
|
264
|
+
records: records,
|
265
|
+
store: this.searchStore,
|
266
|
+
paramName: 'q'
|
267
|
+
})
|
280
268
|
]
|
281
269
|
}
|
282
270
|
});
|
@@ -341,12 +329,18 @@ Ext.extend(MainPanel, Ext.TabPanel, {
|
|
341
329
|
var resultTpl = new Ext.XTemplate(
|
342
330
|
'<tpl for=".">',
|
343
331
|
'<div class="search-item">',
|
344
|
-
'<a class="member docClass" rel="{
|
332
|
+
'<a class="member docClass" rel="{[this.rel(values)]}" href="output/{cls}.html">',
|
345
333
|
'<img src="resources/images/default/s.gif" class="item-icon icon-{type}"/>{member}',
|
346
334
|
'</a> ',
|
347
335
|
'<a class="cls docClass" rel="{cls}" href="output/{cls}.html">{cls}</a>',
|
348
336
|
'<p>{doc}</p>',
|
349
|
-
'</div></tpl>'
|
337
|
+
'</div></tpl>',
|
338
|
+
{
|
339
|
+
// Different links to classes and members
|
340
|
+
rel: function(values) {
|
341
|
+
return (values.type === "cls") ? values.cls : values.cls+"#"+values.member;
|
342
|
+
}
|
343
|
+
}
|
350
344
|
);
|
351
345
|
|
352
346
|
var p = new Ext.DataView({
|
@@ -358,20 +352,6 @@ Ext.extend(MainPanel, Ext.TabPanel, {
|
|
358
352
|
itemSelector: 'div.search-item',
|
359
353
|
emptyText: '<h3>Use the search field above to search the Ext API for classes, properties, config options, methods and events.</h3>'
|
360
354
|
});
|
361
|
-
},
|
362
|
-
|
363
|
-
doSearch : function(e){
|
364
|
-
var k = e.getKey();
|
365
|
-
if(!e.isSpecialKey()){
|
366
|
-
var text = e.target.value;
|
367
|
-
if(!text){
|
368
|
-
this.searchStore.baseParams.q = '';
|
369
|
-
this.searchStore.removeAll();
|
370
|
-
}else{
|
371
|
-
this.searchStore.baseParams.q = text;
|
372
|
-
this.searchStore.reload();
|
373
|
-
}
|
374
|
-
}
|
375
355
|
}
|
376
356
|
});
|
377
357
|
|
@@ -451,9 +431,7 @@ Ext.app.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
|
|
451
431
|
|
452
432
|
onTrigger1Click : function(){
|
453
433
|
if(this.hasSearch){
|
454
|
-
this.store.
|
455
|
-
return false;
|
456
|
-
});
|
434
|
+
this.store.removeAll();
|
457
435
|
this.el.dom.value = '';
|
458
436
|
this.triggers[0].hide();
|
459
437
|
this.hasSearch = false;
|
@@ -472,23 +450,37 @@ Ext.app.SearchField = Ext.extend(Ext.form.TwinTriggerField, {
|
|
472
450
|
return;
|
473
451
|
}
|
474
452
|
|
475
|
-
|
476
|
-
|
453
|
+
this.store.removeAll();
|
454
|
+
this.store.add(this.search(v));
|
477
455
|
|
478
456
|
this.hasSearch = true;
|
479
457
|
this.triggers[0].show();
|
480
458
|
this.focus();
|
481
459
|
},
|
482
460
|
|
483
|
-
|
461
|
+
search: function(text) {
|
462
|
+
var results = [[], [], []];
|
484
463
|
var safeText = Ext.escapeRe(text);
|
485
|
-
|
486
|
-
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
|
491
|
-
|
464
|
+
var re0 = new RegExp("^" + safeText + "$", "i");
|
465
|
+
var re1 = new RegExp("^" + safeText, "i");
|
466
|
+
var re2 = new RegExp(safeText, "i");
|
467
|
+
this.records.forEach(function(r) {
|
468
|
+
var member = r.get("member");
|
469
|
+
if (re0.test(member)) {
|
470
|
+
results[0].push(r);
|
471
|
+
}
|
472
|
+
else if (re1.test(member)) {
|
473
|
+
results[1].push(r);
|
474
|
+
}
|
475
|
+
else if (re2.test(member)) {
|
476
|
+
results[2].push(r);
|
477
|
+
}
|
478
|
+
});
|
479
|
+
// flatten results array
|
480
|
+
var arr = [];
|
481
|
+
results = arr.concat.apply(arr, results);
|
482
|
+
// only pick first n results
|
483
|
+
return results.slice(0, 50);
|
492
484
|
}
|
493
485
|
});
|
494
486
|
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsduck
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: "0.
|
8
|
+
- 6
|
9
|
+
version: "0.6"
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Rene Saarsoo
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-04-27 00:00:00 +03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -78,11 +78,13 @@ files:
|
|
78
78
|
- lib/jsduck/app.rb
|
79
79
|
- lib/jsduck/cfg_table.rb
|
80
80
|
- lib/jsduck/class.rb
|
81
|
+
- lib/jsduck/css_parser.rb
|
81
82
|
- lib/jsduck/doc_formatter.rb
|
82
83
|
- lib/jsduck/doc_parser.rb
|
83
84
|
- lib/jsduck/event_table.rb
|
84
85
|
- lib/jsduck/exporter.rb
|
85
86
|
- lib/jsduck/inheritance_tree.rb
|
87
|
+
- lib/jsduck/js_parser.rb
|
86
88
|
- lib/jsduck/lexer.rb
|
87
89
|
- lib/jsduck/long_params.rb
|
88
90
|
- lib/jsduck/members.rb
|
@@ -90,11 +92,11 @@ files:
|
|
90
92
|
- lib/jsduck/method_table.rb
|
91
93
|
- lib/jsduck/page.rb
|
92
94
|
- lib/jsduck/parallel_wrap.rb
|
93
|
-
- lib/jsduck/parser.rb
|
94
95
|
- lib/jsduck/property_table.rb
|
95
96
|
- lib/jsduck/relations.rb
|
96
97
|
- lib/jsduck/short_params.rb
|
97
|
-
- lib/jsduck/
|
98
|
+
- lib/jsduck/source_file.rb
|
99
|
+
- lib/jsduck/source_writer.rb
|
98
100
|
- lib/jsduck/table.rb
|
99
101
|
- lib/jsduck/timer.rb
|
100
102
|
- lib/jsduck/tree.rb
|