jsduck 5.0.0.beta01 → 5.0.0.beta2

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.
Files changed (95) hide show
  1. data/.travis.yml +1 -0
  2. data/README.md +6 -32
  3. data/Rakefile +5 -5
  4. data/bin/jsduck +0 -1
  5. data/js-classes/String.js +3 -5
  6. data/jsduck.gemspec +3 -2
  7. data/lib/jsduck/aggregator.rb +1 -3
  8. data/lib/jsduck/app.rb +2 -2
  9. data/lib/jsduck/categories/file.rb +0 -6
  10. data/lib/jsduck/class.rb +1 -2
  11. data/lib/jsduck/doc/parser.rb +12 -5
  12. data/lib/jsduck/doc/scanner.rb +6 -0
  13. data/lib/jsduck/doc/standard_tag_parser.rb +10 -5
  14. data/lib/jsduck/doc/subproperties.rb +9 -2
  15. data/lib/jsduck/docs_code_comparer.rb +20 -7
  16. data/lib/jsduck/exporter/app.rb +18 -13
  17. data/lib/jsduck/exporter/full.rb +18 -21
  18. data/lib/jsduck/format/doc.rb +0 -1
  19. data/lib/jsduck/format/html_stack.rb +1 -2
  20. data/lib/jsduck/format/subproperties.rb +2 -2
  21. data/lib/jsduck/inline/auto_link.rb +1 -1
  22. data/lib/jsduck/inline/img.rb +1 -1
  23. data/lib/jsduck/inline/link.rb +4 -6
  24. data/lib/jsduck/inline/video.rb +1 -2
  25. data/lib/jsduck/js/ast.rb +1 -1
  26. data/lib/jsduck/js/esprima.rb +24 -9
  27. data/lib/jsduck/logger.rb +50 -12
  28. data/lib/jsduck/members_index.rb +1 -2
  29. data/lib/jsduck/merger.rb +20 -2
  30. data/lib/jsduck/options.rb +125 -24
  31. data/lib/jsduck/process/accessors.rb +21 -8
  32. data/lib/jsduck/process/enums.rb +2 -3
  33. data/lib/jsduck/process/ext4_events.rb +2 -1
  34. data/lib/jsduck/process/global_members.rb +1 -2
  35. data/lib/jsduck/process/importer.rb +2 -6
  36. data/lib/jsduck/process/inherit_class.rb +58 -0
  37. data/lib/jsduck/process/inherit_doc.rb +6 -175
  38. data/lib/jsduck/process/inherit_members.rb +257 -0
  39. data/lib/jsduck/process/lint.rb +18 -7
  40. data/lib/jsduck/process/overrides.rb +1 -2
  41. data/lib/jsduck/render/class.rb +1 -1
  42. data/lib/jsduck/tag/alias.rb +2 -1
  43. data/lib/jsduck/tag/alternate_class_names.rb +1 -0
  44. data/lib/jsduck/tag/aside.rb +3 -3
  45. data/lib/jsduck/tag/author.rb +18 -3
  46. data/lib/jsduck/tag/autodetected.rb +21 -0
  47. data/lib/jsduck/tag/boolean_tag.rb +1 -1
  48. data/lib/jsduck/tag/cfg.rb +7 -3
  49. data/lib/jsduck/tag/class.rb +1 -1
  50. data/lib/jsduck/tag/class_list_tag.rb +1 -1
  51. data/lib/jsduck/tag/constructor.rb +1 -1
  52. data/lib/jsduck/tag/css_var.rb +1 -1
  53. data/lib/jsduck/tag/default.rb +1 -1
  54. data/lib/jsduck/tag/deprecated_tag.rb +1 -1
  55. data/lib/jsduck/tag/docauthor.rb +2 -0
  56. data/lib/jsduck/tag/enum.rb +2 -2
  57. data/lib/jsduck/tag/event.rb +1 -1
  58. data/lib/jsduck/tag/extends.rb +1 -1
  59. data/lib/jsduck/tag/ftype.rb +2 -1
  60. data/lib/jsduck/tag/inheritdoc.rb +1 -1
  61. data/lib/jsduck/tag/localdoc.rb +33 -0
  62. data/lib/jsduck/tag/markdown.rb +1 -1
  63. data/lib/jsduck/tag/member.rb +1 -1
  64. data/lib/jsduck/tag/method.rb +1 -1
  65. data/lib/jsduck/tag/mixins.rb +1 -0
  66. data/lib/jsduck/tag/override.rb +1 -1
  67. data/lib/jsduck/tag/param.rb +16 -5
  68. data/lib/jsduck/tag/preventable.rb +1 -1
  69. data/lib/jsduck/tag/property.rb +7 -3
  70. data/lib/jsduck/tag/ptype.rb +2 -1
  71. data/lib/jsduck/tag/requires.rb +1 -0
  72. data/lib/jsduck/tag/return.rb +2 -1
  73. data/lib/jsduck/tag/since.rb +1 -5
  74. data/lib/jsduck/tag/tag.rb +21 -12
  75. data/lib/jsduck/tag/throws.rb +2 -1
  76. data/lib/jsduck/tag/type.rb +2 -2
  77. data/lib/jsduck/tag/uses.rb +1 -0
  78. data/lib/jsduck/tag/xtype.rb +2 -1
  79. data/lib/jsduck/tag_loader.rb +26 -15
  80. data/lib/jsduck/tag_registry.rb +20 -11
  81. data/lib/jsduck/web/css.rb +22 -0
  82. data/lib/jsduck/web/data.rb +50 -0
  83. data/lib/jsduck/web/icons.rb +31 -0
  84. data/lib/jsduck/web/index_html.rb +88 -0
  85. data/lib/jsduck/web/search.rb +148 -0
  86. data/lib/jsduck/{source/writer.rb → web/source.rb} +2 -2
  87. data/lib/jsduck/web/template.rb +52 -0
  88. data/lib/jsduck/web/writer.rb +84 -0
  89. metadata +513 -488
  90. data/lib/jsduck/app_data.rb +0 -41
  91. data/lib/jsduck/icons.rb +0 -29
  92. data/lib/jsduck/index_html.rb +0 -84
  93. data/lib/jsduck/search_data.rb +0 -146
  94. data/lib/jsduck/template_dir.rb +0 -50
  95. data/lib/jsduck/web_writer.rb +0 -87
@@ -1,41 +0,0 @@
1
- require 'jsduck/util/json'
2
- require 'jsduck/icons'
3
- require 'jsduck/search_data'
4
- require 'jsduck/tag_registry'
5
-
6
- module JsDuck
7
-
8
- # Creates big JS file with data for Docs app.
9
- class AppData
10
- def initialize(relations, assets, opts)
11
- @relations = relations
12
- @assets = assets
13
- @opts = opts
14
- end
15
-
16
- # Writes classes, guides, videos, and search data to one big .js file
17
- def write(filename)
18
- js = "Docs = " + Util::Json.generate({
19
- :data => {
20
- :classes => Icons.new.create(@relations.classes),
21
- :guides => @assets.guides.to_array,
22
- :videos => @assets.videos.to_array,
23
- :examples => @assets.examples.to_array,
24
- :search => SearchData.new.create(@relations.classes, @assets),
25
- :tests => @opts.tests,
26
- :signatures => TagRegistry.signatures,
27
- :memberTypes => TagRegistry.member_types,
28
- :localStorageDb => @opts.local_storage_db,
29
- :showPrintButton => @opts.seo,
30
- :touchExamplesUi => @opts.touch_examples_ui,
31
- :source => @opts.source,
32
- :commentsUrl => @opts.comments_url,
33
- :commentsDomain => @opts.comments_domain,
34
- }
35
- }) + ";\n"
36
- File.open(filename, 'w') {|f| f.write(js) }
37
- end
38
-
39
- end
40
-
41
- end
data/lib/jsduck/icons.rb DELETED
@@ -1,29 +0,0 @@
1
- module JsDuck
2
-
3
- # Creates an array of small hashes documenting name, parent class
4
- # and icon of a class.
5
- class Icons
6
- def create(classes)
7
- classes.map do |cls|
8
- {
9
- :name => cls[:name],
10
- :extends => cls[:extends],
11
- :private => cls[:private],
12
- :icon => Icons::class_icon(cls),
13
- }
14
- end
15
- end
16
-
17
- # Returns CSS class name for an icon of class
18
- def self.class_icon(cls)
19
- if cls[:singleton]
20
- "icon-singleton"
21
- elsif cls.inherits_from?("Ext.Component")
22
- "icon-component"
23
- else
24
- "icon-class"
25
- end
26
- end
27
- end
28
-
29
- end
@@ -1,84 +0,0 @@
1
- require 'jsduck/logger'
2
- require 'jsduck/util/io'
3
- require 'fileutils'
4
-
5
- module JsDuck
6
-
7
- # Deals with creation of main HTML or PHP files.
8
- class IndexHtml
9
- def initialize(assets, opts)
10
- @assets = assets
11
- @opts = opts
12
- end
13
-
14
- # In normal mode creates index.html.
15
- #
16
- # When --seo enabled, creates index.php, template.html and print-template.html.
17
- def write
18
- if @opts.seo
19
- FileUtils.cp(@opts.template_dir+"/index.php", @opts.output_dir+"/index.php")
20
- create_template_html(@opts.template_dir+"/template.html", @opts.output_dir+"/template.html")
21
- create_print_template_html(@opts.template_dir+"/print-template.html", @opts.output_dir+"/print-template.html")
22
- create_index_template_html(@opts.template_dir+"/index-template.html", @opts.output_dir+"/index-template.html")
23
- else
24
- create_template_html(@opts.template_dir+"/template.html", @opts.output_dir+"/index.html")
25
- end
26
- end
27
-
28
- private
29
-
30
- def create_template_html(in_file, out_file)
31
- write_template(in_file, out_file, {
32
- "{title}" => @opts.title,
33
- "{mobile_redirect}" => @opts.seo ? include_script(@opts.template_dir+"/mobile-redirect.js") : "",
34
- "{header}" => @opts.header,
35
- "{footer}" => "<div id='footer-content' style='display: none'>#{@opts.footer}</div>",
36
- "{extjs_path}" => @opts.extjs_path,
37
- "{data_path}" => File.basename(@opts.data_path),
38
- "{welcome}" => @assets.welcome.to_html("display:none"),
39
- "{categories}" => @assets.categories.to_html("display:none"),
40
- "{guides}" => @assets.guides.to_html("display:none"),
41
- "{head_html}" => @opts.head_html,
42
- "{body_html}" => @opts.body_html,
43
- "{head_css}" => TagRegistry.css,
44
- })
45
- end
46
-
47
- def create_print_template_html(in_file, out_file)
48
- write_template(in_file, out_file, {
49
- "{title}" => @opts.title,
50
- "{header}" => @opts.header,
51
- "{head_css}" => TagRegistry.css,
52
- })
53
- end
54
-
55
- def create_index_template_html(in_file, out_file)
56
- categories = @assets.categories.to_html
57
- guides = @assets.guides.to_html
58
-
59
- write_template(in_file, out_file, {
60
- "{title}" => @opts.title,
61
- "{header}" => @opts.header,
62
- "{categories}" => categories ? "<h1>API Documentation</h1> #{categories}" : "",
63
- "{guides}" => guides ? "<h1>Guides</h1> #{guides}" : "",
64
- "{head_css}" => TagRegistry.css,
65
- })
66
- end
67
-
68
- def include_script(filename)
69
- "<script type='text/javascript'>\n" + Util::IO.read(filename) + "\n</script>"
70
- end
71
-
72
- # Opens in_file, replaces {keys} inside it, writes to out_file
73
- def write_template(in_file, out_file, replacements)
74
- Logger.log("Writing", out_file)
75
- html = Util::IO.read(in_file)
76
- html.gsub!(/\{\w+\}/) do |key|
77
- replacements[key] ? replacements[key] : key
78
- end
79
- File.open(out_file, 'w') {|f| f.write(html) }
80
- end
81
-
82
- end
83
-
84
- end
@@ -1,146 +0,0 @@
1
- require 'jsduck/icons'
2
- require 'jsduck/class_name'
3
- require 'jsduck/tag_registry'
4
-
5
- module JsDuck
6
-
7
- # Creates list of all members in all classes that is used by the
8
- # searching feature in UI.
9
- class SearchData
10
- # Given list of classes and other assets, returns an array of
11
- # hashes describing the search data.
12
- def create(classes, assets)
13
- list = []
14
-
15
- classes.each do |cls|
16
- list << class_node(cls)
17
-
18
- cls[:alternateClassNames].each do |name|
19
- list << alt_node(name, cls)
20
- end
21
-
22
- cls[:aliases].each_pair do |key, items|
23
- items.each do |name|
24
- list << alias_node(key, name, cls)
25
- end
26
- end
27
-
28
- # add all local members, but skip constructors
29
- cls[:members].each do |m|
30
- list << member_node(m, cls) unless m[:name] == ClassName.short(cls[:name])
31
- end
32
- end
33
-
34
- assets.guides.each_item {|g| list << guide_node(g) }
35
-
36
- assets.videos.each_item {|v| list << video_node(v) }
37
-
38
- assets.examples.each_item {|e| list << example_node(e) }
39
-
40
- list
41
- end
42
-
43
- private
44
-
45
- def alias_node(key, name, cls)
46
- return {
47
- :name => name,
48
- :fullName => alias_display_name(key)+": "+name,
49
- :icon => Icons::class_icon(cls) + "-redirect",
50
- :url => "#!/api/" + cls[:name],
51
- :meta => combine_meta(cls),
52
- :sort => 0,
53
- }
54
- end
55
-
56
- def class_node(cls)
57
- return {
58
- :name => ClassName.short(cls[:name]),
59
- :fullName => cls[:name],
60
- :icon => Icons::class_icon(cls),
61
- :url => "#!/api/" + cls[:name],
62
- :meta => combine_meta(cls),
63
- :sort => 1,
64
- }
65
- end
66
-
67
- def alt_node(name, cls)
68
- return {
69
- :name => ClassName.short(name),
70
- :fullName => name,
71
- :type => :class,
72
- :icon => Icons::class_icon(cls) + "-redirect",
73
- :url => "#!/api/" + cls[:name],
74
- :meta => combine_meta(cls),
75
- :sort => 2,
76
- }
77
- end
78
-
79
- def member_node(member, cls)
80
- return {
81
- :name => member[:name],
82
- :fullName => cls[:name] + "." + member[:name],
83
- :icon => "icon-" + member[:tagname].to_s,
84
- :url => "#!/api/" + cls[:name] + "-" + member[:id],
85
- :meta => combine_meta(member),
86
- :sort => 3,
87
- }
88
- end
89
-
90
- def guide_node(guide)
91
- return {
92
- :name => guide["title"],
93
- :fullName => "guide: " + guide["title"],
94
- :icon => "icon-guide",
95
- :url => "#!/guide/" + guide["name"],
96
- :meta => {},
97
- :sort => 4,
98
- }
99
- end
100
-
101
- def video_node(video)
102
- return {
103
- :name => video["title"],
104
- :fullName => "video: " + video["title"],
105
- :icon => "icon-video",
106
- :url => "#!/video/" + video["name"],
107
- :meta => {},
108
- :sort => 4,
109
- }
110
- end
111
-
112
- def example_node(example)
113
- return {
114
- :name => example["title"],
115
- :fullName => "example: " + example["title"],
116
- :icon => "icon-example",
117
- :url => "#!/example/" + example["name"],
118
- :meta => {},
119
- :sort => 4,
120
- }
121
- end
122
-
123
- # Add data for builtin tags with signatures to :meta field.
124
- def combine_meta(hash)
125
- meta = {}
126
- TagRegistry.signatures.each do |s|
127
- name = s[:tagname]
128
- meta[name] = hash[name] if hash[name]
129
- end
130
- meta
131
- end
132
-
133
- # Some alias types are shown differently.
134
- # e.g. instead of "widget:" we show "xtype:"
135
- def alias_display_name(key)
136
- titles = {
137
- "widget" => "xtype",
138
- "plugin" => "ptype",
139
- "feature" => "ftype",
140
- }
141
- titles[key] || key
142
- end
143
-
144
- end
145
-
146
- end
@@ -1,50 +0,0 @@
1
- require 'jsduck/logger'
2
- require 'fileutils'
3
-
4
- module JsDuck
5
-
6
- # Copies over the template directory.
7
- #
8
- # Or links when --template-links option specified.
9
- class TemplateDir
10
- def initialize(opts)
11
- @opts = opts
12
- @files = [
13
- "app",
14
- "app*.js",
15
- "favicon.ico",
16
- "extjs",
17
- "resources",
18
- ]
19
- end
20
-
21
- def write
22
- FileUtils.mkdir(@opts.output_dir)
23
- if @opts.template_links
24
- Logger.log("Linking template files to", @opts.output_dir)
25
- move_files(:symlink)
26
- else
27
- Logger.log("Copying template files to", @opts.output_dir)
28
- move_files(:cp_r)
29
- end
30
-
31
- # always copy the eg-iframe file.
32
- eg_iframe = @opts.eg_iframe || @opts.template_dir+"/eg-iframe.html"
33
- FileUtils.cp(eg_iframe, @opts.output_dir+"/eg-iframe.html")
34
- end
35
-
36
- private
37
-
38
- # moves files from one dir to another using a method of FileUtils module.
39
- def move_files(method)
40
- @files.each do |file|
41
- target = File.expand_path(@opts.output_dir)
42
- Dir.glob(File.expand_path(@opts.template_dir+"/"+file)).each do |source|
43
- FileUtils.send(method, source, target)
44
- end
45
- end
46
- end
47
-
48
- end
49
-
50
- end
@@ -1,87 +0,0 @@
1
- require 'jsduck/exporter/app'
2
- require 'jsduck/format/batch'
3
- require 'jsduck/template_dir'
4
- require 'jsduck/index_html'
5
- require 'jsduck/app_data'
6
- require 'jsduck/class_writer'
7
- require 'jsduck/source/writer'
8
- require 'jsduck/inline_examples'
9
- require 'jsduck/util/md5'
10
- require 'fileutils'
11
-
12
- module JsDuck
13
-
14
- # Performs the generation of docs web app.
15
- class WebWriter
16
- def initialize(relations, assets, parsed_files, opts)
17
- @relations = relations
18
- @assets = assets
19
- @parsed_files = parsed_files
20
- @opts = opts
21
- end
22
-
23
- def write
24
- clean_output_dir
25
-
26
- write_template_files
27
- write_app_data
28
- write_index_html
29
-
30
- # class-formatting is done in parallel which breaks the links
31
- # between source files and classes. Therefore it MUST to be done
32
- # after writing sources which needs the links to work.
33
- write_source if @opts.source
34
- format_classes
35
-
36
- write_inline_examples if @opts.tests
37
-
38
- write_classes
39
-
40
- @assets.write
41
- end
42
-
43
- def write_template_files
44
- TemplateDir.new(@opts).write
45
- end
46
-
47
- def write_app_data
48
- filename = @opts.output_dir+"/data.js"
49
- AppData.new(@relations, @assets, @opts).write(filename)
50
- # Rename the file and remember the name for use in IndexHtml.write
51
- @opts.data_path = Util::MD5.rename(filename)
52
- end
53
-
54
- def write_index_html
55
- IndexHtml.new(@assets, @opts).write
56
- end
57
-
58
- def write_source
59
- source_writer = Source::Writer.new(@parsed_files)
60
- source_writer.write(@opts.output_dir + "/source")
61
- end
62
-
63
- def write_inline_examples
64
- examples = InlineExamples.new
65
- examples.add_classes(@relations)
66
- examples.add_guides(@assets.guides)
67
- examples.write(@opts.output_dir+"/inline-examples.js")
68
- end
69
-
70
- def write_classes
71
- class_writer = ClassWriter.new(Exporter::App, @relations, @opts)
72
- class_writer.write(@opts.output_dir+"/output", ".js")
73
- end
74
-
75
- # -- util routines --
76
-
77
- def clean_output_dir
78
- FileUtils.rm_rf(@opts.output_dir)
79
- end
80
-
81
- def format_classes
82
- Format::Batch.format_all!(@relations, @assets, @opts)
83
- end
84
-
85
- end
86
-
87
- end