jsduck 3.0.pre2 → 3.0.pre3
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 +14 -7
- data/Rakefile +277 -24
- data/bin/compare +163 -0
- data/bin/stats +92 -0
- data/jsduck.gemspec +3 -3
- data/lib/jsduck/accessors.rb +64 -8
- data/lib/jsduck/aggregator.rb +10 -6
- data/lib/jsduck/aliases.rb +3 -2
- data/lib/jsduck/app.rb +51 -44
- data/lib/jsduck/author_tag.rb +11 -0
- data/lib/jsduck/categories.rb +14 -8
- data/lib/jsduck/class.rb +2 -1
- data/lib/jsduck/class_formatter.rb +5 -4
- data/lib/jsduck/doc_author_tag.rb +11 -0
- data/lib/jsduck/doc_formatter.rb +17 -37
- data/lib/jsduck/doc_parser.rb +39 -11
- data/lib/jsduck/exporter.rb +11 -0
- data/lib/jsduck/guides.rb +3 -3
- data/lib/jsduck/images.rb +72 -0
- data/lib/jsduck/js_parser.rb +20 -4
- data/lib/jsduck/lexer.rb +2 -8
- data/lib/jsduck/lint.rb +3 -2
- data/lib/jsduck/logger.rb +24 -5
- data/lib/jsduck/merger.rb +38 -8
- data/lib/jsduck/meta_tag.rb +49 -0
- data/lib/jsduck/meta_tag_loader.rb +48 -0
- data/lib/jsduck/options.rb +37 -25
- data/lib/jsduck/os.rb +11 -0
- data/lib/jsduck/renderer.rb +37 -34
- data/lib/jsduck/search_data.rb +1 -1
- data/lib/jsduck/source_file.rb +13 -8
- data/template-min/app.js +1 -1
- data/template-min/{egIframe.html → extIframe.html} +3 -4
- data/template-min/extjs/ext-all-debug.js +3107 -2026
- data/template-min/extjs/ext-all.js +1 -1
- data/template-min/extjs/resources/css/ext-all.css +1 -1
- data/template-min/resources/css/app.css +1 -1
- data/template-min/resources/images/down-arr.png +0 -0
- data/template-min/resources/images/gettingstarted.jpg +0 -0
- data/template-min/resources/images/ipad-l.jpg +0 -0
- data/template-min/resources/images/ipad-p.jpg +0 -0
- data/template-min/resources/images/iphone-l.jpg +0 -0
- data/template-min/resources/images/iphone-p.jpg +0 -0
- data/template-min/resources/images/iphone-small-l.jpg +0 -0
- data/template-min/resources/images/iphone-small-p.jpg +0 -0
- data/template-min/resources/images/link-arrow-next.png +0 -0
- data/template-min/template.html +5 -1
- data/template-min/touch-welcome.html +122 -0
- data/template-min/touchIframe.html +85 -0
- data/template-min/welcome.html +2 -0
- metadata +25 -8
- data/lib/jsduck/page.rb +0 -118
- data/lib/jsduck/timer.rb +0 -44
data/lib/jsduck/options.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'optparse'
|
2
|
+
require 'jsduck/meta_tag_loader'
|
2
3
|
|
3
4
|
module JsDuck
|
4
5
|
|
@@ -24,8 +25,8 @@ module JsDuck
|
|
24
25
|
attr_accessor :videos
|
25
26
|
attr_accessor :examples
|
26
27
|
attr_accessor :categories_path
|
27
|
-
attr_accessor :inline_examples_dir
|
28
28
|
attr_accessor :pretty_json
|
29
|
+
attr_accessor :images
|
29
30
|
attr_accessor :link_tpl
|
30
31
|
attr_accessor :img_tpl
|
31
32
|
attr_accessor :export
|
@@ -37,6 +38,7 @@ module JsDuck
|
|
37
38
|
attr_accessor :template_links
|
38
39
|
attr_accessor :extjs_path
|
39
40
|
attr_accessor :local_storage_db
|
41
|
+
attr_accessor :touch_examples_ui
|
40
42
|
attr_accessor :ext_namespaces
|
41
43
|
|
42
44
|
def initialize
|
@@ -64,15 +66,15 @@ module JsDuck
|
|
64
66
|
"CSSStyleSheet",
|
65
67
|
"CSSStyleRule",
|
66
68
|
"Event",
|
69
|
+
# Special anything-goes type
|
70
|
+
"Mixed",
|
67
71
|
]
|
68
|
-
@meta_tags = [
|
69
|
-
|
70
|
-
{:name => "docauthor", :title => "Documentation author", :strip => / *<.*?> */},
|
71
|
-
]
|
72
|
+
@meta_tags = []
|
73
|
+
@meta_tag_paths = []
|
72
74
|
|
73
75
|
@warnings = true
|
74
76
|
@verbose = false
|
75
|
-
@version = "3.0.
|
77
|
+
@version = "3.0.pre3"
|
76
78
|
|
77
79
|
# Customizing output
|
78
80
|
@title = "Sencha Docs - Ext JS"
|
@@ -85,22 +87,24 @@ module JsDuck
|
|
85
87
|
@videos = nil
|
86
88
|
@examples = nil
|
87
89
|
@categories_path = nil
|
88
|
-
@inline_examples_dir = nil
|
89
90
|
@pretty_json = false
|
91
|
+
@images = []
|
90
92
|
@link_tpl = '<a href="#!/api/%c%-%m" rel="%c%-%m" class="docClass">%a</a>'
|
91
93
|
# Note that we wrap image template inside <p> because {@img} often
|
92
94
|
# appears inline within text, but that just looks ugly in HTML
|
93
|
-
@img_tpl = '<p><img src="
|
95
|
+
@img_tpl = '<p><img src="%u" alt="%a"></p>'
|
94
96
|
@export = nil
|
95
97
|
@seo = false
|
96
98
|
|
97
99
|
# Debugging
|
98
|
-
|
100
|
+
# Turn multiprocessing off by default in Windows
|
101
|
+
@processes = OS::windows? ? 0 : nil
|
99
102
|
@root_dir = File.dirname(File.dirname(File.dirname(__FILE__)))
|
100
103
|
@template_dir = @root_dir + "/template-min"
|
101
104
|
@template_links = false
|
102
105
|
@extjs_path = "extjs/ext-all.js"
|
103
106
|
@local_storage_db = "docs"
|
107
|
+
@touch_examples_ui = false
|
104
108
|
@ext_namespaces = ["Ext"]
|
105
109
|
end
|
106
110
|
|
@@ -111,8 +115,11 @@ module JsDuck
|
|
111
115
|
end
|
112
116
|
|
113
117
|
def parse!(argv)
|
114
|
-
create_option_parser.parse!(argv).each
|
118
|
+
create_option_parser.parse!(argv).each do |fname|
|
119
|
+
read_filenames(canonical(fname))
|
120
|
+
end
|
115
121
|
validate
|
122
|
+
@meta_tags = MetaTagLoader.new.load(@meta_tag_paths)
|
116
123
|
end
|
117
124
|
|
118
125
|
def create_option_parser
|
@@ -141,13 +148,10 @@ module JsDuck
|
|
141
148
|
read_filenames(@root_dir + "/js-classes")
|
142
149
|
end
|
143
150
|
|
144
|
-
opts.on('--meta-tags
|
145
|
-
"
|
146
|
-
"
|
147
|
-
|
148
|
-
t = t.split(/=/)
|
149
|
-
@meta_tags << {:name => t[0].sub(/^@/, ""), :title => t[1]}
|
150
|
-
end
|
151
|
+
opts.on('--meta-tags=PATH',
|
152
|
+
"Path to Ruby file or directory with custom",
|
153
|
+
"meta-tag implementations. Experimantal!", " ") do |path|
|
154
|
+
@meta_tag_paths << path
|
151
155
|
end
|
152
156
|
|
153
157
|
opts.on('--no-warnings', "Turns off warnings.", " ") do
|
@@ -210,14 +214,17 @@ module JsDuck
|
|
210
214
|
@categories_path = canonical(path)
|
211
215
|
end
|
212
216
|
|
213
|
-
opts.on('--inline-examples=PATH', "Path to inline examples directory.", " ") do |path|
|
214
|
-
@inline_examples_dir = canonical(path)
|
215
|
-
end
|
216
|
-
|
217
217
|
opts.on('--pretty-json', "Turn on pretty-printing of JSON.", " ") do
|
218
218
|
@pretty_json = true
|
219
219
|
end
|
220
220
|
|
221
|
+
opts.on('--images=PATH',
|
222
|
+
"Search path for including images referenced by",
|
223
|
+
"{@img} tag. Several paths can be specified by",
|
224
|
+
"using the option multiple times.", " ") do |path|
|
225
|
+
@images << canonical(path)
|
226
|
+
end
|
227
|
+
|
221
228
|
opts.on('--link=TPL',
|
222
229
|
"HTML template for replacing {@link}.",
|
223
230
|
"Possible placeholders:",
|
@@ -258,7 +265,7 @@ module JsDuck
|
|
258
265
|
# For debugging it's often useful to set --processes=0 to get deterministic results.
|
259
266
|
opts.on('-p', '--processes=COUNT',
|
260
267
|
"The number of parallel processes to use.",
|
261
|
-
"Defaults to the number of processors/cores.",
|
268
|
+
OS::windows? ? "Defaults to off in Windows." : "Defaults to the number of processors/cores.",
|
262
269
|
"Set to 0 to disable parallel processing completely.", " ") do |count|
|
263
270
|
@processes = count.to_i
|
264
271
|
end
|
@@ -287,6 +294,11 @@ module JsDuck
|
|
287
294
|
@local_storage_db = name
|
288
295
|
end
|
289
296
|
|
297
|
+
opts.on('--touch-examples-ui',
|
298
|
+
"Use phone/tablet UI for examples.", " ") do
|
299
|
+
@touch_examples_ui = true
|
300
|
+
end
|
301
|
+
|
290
302
|
opts.on('--ext-namespaces=Ext,Foo', Array,
|
291
303
|
"Namespace(s) of ExtJS. Defaults to 'Ext'.", " ") do |ns|
|
292
304
|
@ext_namespaces = ns
|
@@ -364,7 +376,7 @@ module JsDuck
|
|
364
376
|
|
365
377
|
# Runs checks on the options
|
366
378
|
def validate
|
367
|
-
if @input_files.length == 0
|
379
|
+
if @input_files.length == 0 && !@welcome && !@guides && !@videos && !@examples
|
368
380
|
puts "You should specify some input files, otherwise there's nothing I can do :("
|
369
381
|
exit(1)
|
370
382
|
elsif @export != :stdout
|
@@ -377,13 +389,13 @@ module JsDuck
|
|
377
389
|
elsif !File.exists?(File.dirname(@output_dir))
|
378
390
|
puts "Oh noes! The parent directory for #{@output_dir} doesn't exist."
|
379
391
|
exit(1)
|
380
|
-
elsif !File.exists?(@template_dir + "/extjs")
|
392
|
+
elsif !@export && !File.exists?(@template_dir + "/extjs")
|
381
393
|
puts "Oh noes! The template directory does not contain extjs/ directory :("
|
382
394
|
puts "Please copy ExtJS over to template/extjs or create symlink."
|
383
395
|
puts "For example:"
|
384
396
|
puts " $ cp -r /path/to/ext-4.0.0 " + @template_dir + "/extjs"
|
385
397
|
exit(1)
|
386
|
-
elsif !File.exists?(@template_dir + "/resources/css")
|
398
|
+
elsif !@export && !File.exists?(@template_dir + "/resources/css")
|
387
399
|
puts "Oh noes! CSS files for custom ExtJS theme missing :("
|
388
400
|
puts "Please compile SASS files in template/resources/sass with compass."
|
389
401
|
puts "For example:"
|
data/lib/jsduck/os.rb
ADDED
data/lib/jsduck/renderer.rb
CHANGED
@@ -5,16 +5,15 @@ module JsDuck
|
|
5
5
|
# Ruby-side implementation of class docs Renderer.
|
6
6
|
# Uses PhantomJS to run Docs.Renderer JavaScript.
|
7
7
|
class Renderer
|
8
|
-
|
9
|
-
|
10
|
-
end
|
8
|
+
# List of meta-tag implementations
|
9
|
+
attr_accessor :meta_tags
|
11
10
|
|
12
11
|
def render(cls)
|
13
12
|
@cls = cls
|
14
13
|
|
15
14
|
return [
|
16
15
|
"<div>",
|
17
|
-
|
16
|
+
render_sidebar,
|
18
17
|
"<div class='doc-contents'>",
|
19
18
|
render_private_class_notice,
|
20
19
|
@cls[:doc],
|
@@ -37,38 +36,30 @@ module JsDuck
|
|
37
36
|
end
|
38
37
|
|
39
38
|
def render_meta_data
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
items = @cls[:meta].find_all {|m| m[:name] == meta[:name]}.map {|m| m[:content] }
|
47
|
-
content = meta[:strip] ? items.map {|m| m.gsub(meta[:strip], "") } : items
|
48
|
-
if items.length > 0
|
49
|
-
html << "<li><strong>#{CGI.escapeHTML(title)}:</strong> #{CGI.escapeHTML(content.join(', '))}</li>"
|
39
|
+
@meta_tags.map do |tag|
|
40
|
+
contents = @cls[:meta][tag.name]
|
41
|
+
if contents
|
42
|
+
tag.to_html(contents)
|
43
|
+
else
|
44
|
+
nil
|
50
45
|
end
|
51
46
|
end
|
52
|
-
|
53
|
-
html << "</ul>"
|
54
|
-
|
55
|
-
html
|
56
47
|
end
|
57
48
|
|
58
|
-
def
|
59
|
-
|
60
|
-
has_alt_names = @cls[:alternateClassNames].length > 0
|
61
|
-
has_mixins = @cls[:superclasses].length > 0
|
62
|
-
|
63
|
-
return if !has_parents && !has_alt_names && !has_mixins
|
64
|
-
|
65
|
-
return [
|
66
|
-
'<pre class="hierarchy">',
|
49
|
+
def render_sidebar
|
50
|
+
items = [
|
67
51
|
render_alternate_class_names,
|
68
52
|
render_tree,
|
69
|
-
|
70
|
-
|
53
|
+
render_dependencies(:allMixins, "Mixins"),
|
54
|
+
render_dependencies(:requires, "Requires"),
|
55
|
+
render_dependencies(:uses, "Uses"),
|
56
|
+
render_files,
|
71
57
|
]
|
58
|
+
if items.compact.length > 0
|
59
|
+
return ['<pre class="hierarchy">', items, '</pre>']
|
60
|
+
else
|
61
|
+
return nil
|
62
|
+
end
|
72
63
|
end
|
73
64
|
|
74
65
|
def render_alternate_class_names
|
@@ -79,11 +70,23 @@ module JsDuck
|
|
79
70
|
]
|
80
71
|
end
|
81
72
|
|
82
|
-
def
|
83
|
-
return if @cls[
|
73
|
+
def render_dependencies(type, title)
|
74
|
+
return if !@cls[type] || @cls[type].length == 0
|
75
|
+
return [
|
76
|
+
"<h4>#{title}</h4>",
|
77
|
+
@cls[type].map {|name| "<div class='dependency'>#{render_link(name)}</div>" },
|
78
|
+
]
|
79
|
+
end
|
80
|
+
|
81
|
+
def render_files
|
82
|
+
return if @cls[:files].length == 0 || @cls[:files][0][:filename] == ""
|
84
83
|
return [
|
85
|
-
"<h4>
|
86
|
-
@cls[:
|
84
|
+
"<h4>Files</h4>",
|
85
|
+
@cls[:files].map do |file|
|
86
|
+
url = "source/" + file[:href]
|
87
|
+
title = File.basename(file[:filename])
|
88
|
+
"<div class='dependency'><a href='#{url}' target='_blank'>#{title}</a></div>"
|
89
|
+
end
|
87
90
|
]
|
88
91
|
end
|
89
92
|
|
@@ -177,7 +180,7 @@ module JsDuck
|
|
177
180
|
"<div class='title'>",
|
178
181
|
"<div class='meta'>",
|
179
182
|
"<a href='#!/api/#{owner}' rel='#{owner}' class='definedIn docClass'>#{owner}</a><br/>",
|
180
|
-
"<a href='source/#{m[:href]}' target='_blank' class='viewSource'>view source</a>",
|
183
|
+
"<a href='source/#{m[:files][0][:href]}' target='_blank' class='viewSource'>view source</a>",
|
181
184
|
"</div>",
|
182
185
|
# method params signature or property type signature
|
183
186
|
render_signature(m),
|
data/lib/jsduck/search_data.rb
CHANGED
@@ -11,7 +11,7 @@ module JsDuck
|
|
11
11
|
docs.each do |cls|
|
12
12
|
list << class_node(cls)
|
13
13
|
[:members, :statics].each do |group|
|
14
|
-
[
|
14
|
+
cls[group].each_key do |type|
|
15
15
|
cls.members(type, group).each do |m|
|
16
16
|
# skip inherited items and constructors
|
17
17
|
if m[:owner] == cls.full_name && m[:name] != cls.short_name
|
data/lib/jsduck/source_file.rb
CHANGED
@@ -23,7 +23,9 @@ module JsDuck
|
|
23
23
|
@links = {}
|
24
24
|
|
25
25
|
merger = Merger.new
|
26
|
+
merger.filename = @filename
|
26
27
|
@docs = parse.map do |docset|
|
28
|
+
merger.linenr = docset[:linenr]
|
27
29
|
link(docset[:linenr], merger.merge(docset[:comment], docset[:code]))
|
28
30
|
end
|
29
31
|
end
|
@@ -38,9 +40,9 @@ module JsDuck
|
|
38
40
|
def html_filename=(html_filename)
|
39
41
|
@html_filename = html_filename
|
40
42
|
@links.each_value do |line|
|
41
|
-
line.each do |
|
42
|
-
|
43
|
-
|
43
|
+
line.each do |link|
|
44
|
+
link[:file][:html_filename] = @html_filename
|
45
|
+
link[:file][:href] = @html_filename + "#" + id(link[:doc])
|
44
46
|
end
|
45
47
|
end
|
46
48
|
end
|
@@ -55,8 +57,8 @@ module JsDuck
|
|
55
57
|
line = CGI.escapeHTML(line)
|
56
58
|
# wrap the line in as many spans as there are links to this line number.
|
57
59
|
if @links[linenr]
|
58
|
-
@links[linenr].each do |
|
59
|
-
line = "<span id='#{id(doc)}'>#{line}</span>"
|
60
|
+
@links[linenr].each do |link|
|
61
|
+
line = "<span id='#{id(link[:doc])}'>#{line}</span>"
|
60
62
|
end
|
61
63
|
end
|
62
64
|
lines << line
|
@@ -90,9 +92,12 @@ module JsDuck
|
|
90
92
|
# Returns the modified doc-object after done.
|
91
93
|
def link(linenr, doc)
|
92
94
|
@links[linenr] = [] unless @links[linenr]
|
93
|
-
|
94
|
-
|
95
|
-
|
95
|
+
file = {
|
96
|
+
:filename => @filename,
|
97
|
+
:linenr => linenr,
|
98
|
+
}
|
99
|
+
@links[linenr] << {:doc => doc, :file => file}
|
100
|
+
doc[:files] = [file]
|
96
101
|
if doc[:tagname] == :class
|
97
102
|
doc[:members][:cfg].each {|cfg| link(linenr, cfg) }
|
98
103
|
doc[:members][:method].each {|method| link(linenr, method) }
|