jsduck 5.3.4 → 6.0.0beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (105) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/bin/jsduck +3 -3
  4. data/lib/jsduck/app.rb +1 -1
  5. data/lib/jsduck/assets.rb +3 -3
  6. data/lib/jsduck/base_type.rb +2 -2
  7. data/lib/jsduck/batch_processor.rb +3 -1
  8. data/lib/jsduck/categories/file.rb +2 -2
  9. data/lib/jsduck/class_doc_expander.rb +1 -1
  10. data/lib/jsduck/css/parser.rb +59 -90
  11. data/lib/jsduck/css/type.rb +55 -0
  12. data/lib/jsduck/doc/parser.rb +1 -1
  13. data/lib/jsduck/doc/scanner.rb +2 -2
  14. data/lib/jsduck/doc/subproperties.rb +1 -1
  15. data/lib/jsduck/export_writer.rb +4 -4
  16. data/lib/jsduck/exporter/app.rb +2 -1
  17. data/lib/jsduck/exporter/full.rb +5 -3
  18. data/lib/jsduck/external_classes.rb +337 -5
  19. data/lib/jsduck/format/class.rb +3 -3
  20. data/lib/jsduck/format/doc.rb +6 -5
  21. data/lib/jsduck/format/subproperties.rb +1 -1
  22. data/lib/jsduck/guide_toc.rb +45 -27
  23. data/lib/jsduck/guide_toc_entry.rb +54 -0
  24. data/lib/jsduck/guides.rb +9 -5
  25. data/lib/jsduck/img/dir.rb +1 -1
  26. data/lib/jsduck/inline/example.rb +3 -1
  27. data/lib/jsduck/inline/img.rb +3 -3
  28. data/lib/jsduck/inline/link.rb +2 -2
  29. data/lib/jsduck/inline/link_renderer.rb +3 -2
  30. data/lib/jsduck/inline/video.rb +2 -1
  31. data/lib/jsduck/js/class.rb +6 -11
  32. data/lib/jsduck/js/ext_define.rb +46 -0
  33. data/lib/jsduck/js/ext_patterns.rb +7 -2
  34. data/lib/jsduck/js/rkelly_adapter.rb +16 -2
  35. data/lib/jsduck/logger.rb +40 -25
  36. data/lib/jsduck/member_registry.rb +41 -0
  37. data/lib/jsduck/news.rb +18 -5
  38. data/lib/jsduck/options/config.rb +35 -0
  39. data/lib/jsduck/options/helpful_parser.rb +111 -0
  40. data/lib/jsduck/options/input_files.rb +60 -0
  41. data/lib/jsduck/options/jsb.rb +25 -0
  42. data/lib/jsduck/{options.rb → options/parser.rb} +436 -484
  43. data/lib/jsduck/options/processor.rb +47 -0
  44. data/lib/jsduck/options/record.rb +51 -0
  45. data/lib/jsduck/output_dir.rb +4 -4
  46. data/lib/jsduck/parser.rb +5 -5
  47. data/lib/jsduck/process/components.rb +19 -0
  48. data/lib/jsduck/process/ext4_events.rb +4 -2
  49. data/lib/jsduck/process/importer.rb +5 -2
  50. data/lib/jsduck/process/inherit_members.rb +2 -0
  51. data/lib/jsduck/process/lint.rb +3 -3
  52. data/lib/jsduck/process/no_doc.rb +1 -1
  53. data/lib/jsduck/process/overrides.rb +4 -3
  54. data/lib/jsduck/process/versions.rb +86 -51
  55. data/lib/jsduck/render/class.rb +3 -2
  56. data/lib/jsduck/render/subproperties.rb +18 -0
  57. data/lib/jsduck/render/tags.rb +13 -1
  58. data/lib/jsduck/source/file.rb +2 -2
  59. data/lib/jsduck/tag/class.rb +6 -0
  60. data/lib/jsduck/tag/component.rb +19 -0
  61. data/lib/jsduck/tag/css_mixin.rb +10 -0
  62. data/lib/jsduck/tag/deprecated.rb +1 -1
  63. data/{template-min/resources/images/class-m.png → lib/jsduck/tag/icons/class-large.png} +0 -0
  64. data/lib/jsduck/tag/icons/class-redirect.png +0 -0
  65. data/lib/jsduck/tag/icons/class.png +0 -0
  66. data/{template-min/resources/images/component-m.png → lib/jsduck/tag/icons/component-large.png} +0 -0
  67. data/lib/jsduck/tag/icons/component-redirect.png +0 -0
  68. data/lib/jsduck/tag/icons/component.png +0 -0
  69. data/{template-min/resources/images/singleton-m.png → lib/jsduck/tag/icons/singleton-large.png} +0 -0
  70. data/lib/jsduck/tag/icons/singleton-redirect.png +0 -0
  71. data/lib/jsduck/tag/icons/singleton.png +0 -0
  72. data/lib/jsduck/tag/inheritdoc.rb +2 -2
  73. data/lib/jsduck/tag/new.rb +13 -0
  74. data/lib/jsduck/tag/since.rb +2 -2
  75. data/lib/jsduck/tag/singleton.rb +13 -0
  76. data/lib/jsduck/tag/tag.rb +19 -0
  77. data/lib/jsduck/tag_registry.rb +20 -81
  78. data/lib/jsduck/util/io.rb +5 -0
  79. data/lib/jsduck/util/json.rb +3 -3
  80. data/lib/jsduck/util/null_object.rb +14 -1
  81. data/lib/jsduck/util/parallel.rb +7 -3
  82. data/lib/jsduck/version.rb +1 -1
  83. data/lib/jsduck/warning/registry.rb +4 -2
  84. data/lib/jsduck/warning/tag.rb +57 -0
  85. data/lib/jsduck/web/class_icons.rb +76 -0
  86. data/lib/jsduck/web/css.rb +12 -1
  87. data/lib/jsduck/web/data.rb +4 -3
  88. data/lib/jsduck/web/index_html.rb +26 -10
  89. data/lib/jsduck/web/member_icons.rb +3 -3
  90. data/lib/jsduck/web/search.rb +4 -4
  91. data/lib/jsduck/web/source.rb +1 -1
  92. data/lib/jsduck/web/template.rb +6 -6
  93. data/lib/jsduck/web/tree.rb +22 -0
  94. data/lib/jsduck/web/writer.rb +11 -9
  95. data/template-min/app-0f524ddd276c4019a11a6128932a9c96.js +1 -0
  96. data/template-min/index-template.html +1 -1
  97. data/template-min/print-template.html +1 -1
  98. data/template-min/resources/css/{app-4689d2a5522dcd3c9e9923ca59c33f27.css → app-de670120f43fdad3091a0cc2c10daadb.css} +1 -1
  99. data/template-min/resources/images/icons.xcf +0 -0
  100. data/template-min/template.html +2 -2
  101. metadata +46 -13
  102. data/lib/jsduck/css/lexer.rb +0 -203
  103. data/lib/jsduck/option_parser.rb +0 -109
  104. data/lib/jsduck/web/icons.rb +0 -31
  105. data/template-min/app-0c945a27f43452df695771ddb60b3d14.js +0 -1
@@ -1,6 +1,7 @@
1
1
  require 'jsduck/render/tags'
2
2
  require 'jsduck/render/sidebar'
3
3
  require 'jsduck/tag_registry'
4
+ require 'jsduck/member_registry'
4
5
 
5
6
  module JsDuck
6
7
  module Render
@@ -38,8 +39,8 @@ module JsDuck
38
39
  end
39
40
 
40
41
  def render_all_sections
41
- TagRegistry.member_types.map do |member_type|
42
- render_section(member_type)
42
+ MemberRegistry.definitions.map do |member_def|
43
+ render_section(member_def)
43
44
  end
44
45
  end
45
46
 
@@ -1,5 +1,6 @@
1
1
  require 'jsduck/util/html'
2
2
  require 'jsduck/util/singleton'
3
+ require 'jsduck/tag_registry'
3
4
 
4
5
  module JsDuck
5
6
  module Render
@@ -54,15 +55,32 @@ module JsDuck
54
55
  "<span class='pre'>#{p[:name]}</span> : ",
55
56
  p[:html_type],
56
57
  p[:optional] ? " (optional)" : "",
58
+ p[:new] ? render_new : "",
57
59
  "<div class='sub-desc'>",
58
60
  p[:doc],
59
61
  p[:default] ? "<p>Defaults to: <code>#{Util::HTML.escape(p[:default])}</code></p>" : "",
62
+ p[:since] ? render_since(p) : "",
60
63
  p[:properties] && p[:properties].length > 0 ? render(p) : "",
61
64
  "</div>",
62
65
  "</li>",
63
66
  ]
64
67
  end
65
68
 
69
+ def render_new
70
+ signature = TagRegistry.get_by_name(:new).signature
71
+ return [
72
+ "<span class='signature'>",
73
+ "<span class='new' title='#{signature[:tooltip]}'>",
74
+ signature[:long],
75
+ "</span>",
76
+ "</span>",
77
+ ]
78
+ end
79
+
80
+ def render_since(param)
81
+ TagRegistry.get_by_name(:since).to_html(param)
82
+ end
83
+
66
84
  def render_return(ret)
67
85
  return [
68
86
  "<h3 class='pa'>Returns</h3>",
@@ -10,7 +10,7 @@ module JsDuck
10
10
  # Takes member or class hash.
11
11
  # Returns array of rendered HTML.
12
12
  def self.render(member)
13
- TagRegistry.html_renderers.map do |tag|
13
+ renderers.map do |tag|
14
14
  if member[tag.tagname]
15
15
  tag.to_html(member)
16
16
  else
@@ -19,6 +19,18 @@ module JsDuck
19
19
  end
20
20
  end
21
21
 
22
+ # Returns tags for rendering HTML, sorted in the order they should
23
+ # appear in final output. Sorting order is determined by the
24
+ # numeric :html_position field.
25
+ def self.renderers
26
+ if !@renderers
27
+ @renderers = TagRegistry.tags.find_all(&:html_position)
28
+ @renderers.sort! {|a, b| a.html_position <=> b.html_position }
29
+ end
30
+
31
+ @renderers
32
+ end
33
+
22
34
  # Renders the signatures for a class member.
23
35
  # Returns a string.
24
36
  def self.render_signature(member)
@@ -3,10 +3,10 @@ require 'jsduck/util/html'
3
3
  module JsDuck
4
4
  module Source
5
5
 
6
- # Represents one JavaScript or CSS source file.
6
+ # Represents one JavaScript or SCSS source file.
7
7
  #
8
8
  # The filename parameter determines whether it's parsed as
9
- # JavaScript (the default) or CSS.
9
+ # JavaScript (the default) or SCSS.
10
10
  class File
11
11
  attr_reader :filename
12
12
  attr_reader :contents
@@ -5,6 +5,12 @@ module JsDuck::Tag
5
5
  def initialize
6
6
  @pattern = "class"
7
7
  @tagname = :class
8
+ @class_icon = {
9
+ :small => File.dirname(__FILE__) + "/icons/class.png",
10
+ :large => File.dirname(__FILE__) + "/icons/class-large.png",
11
+ :redirect => File.dirname(__FILE__) + "/icons/class-redirect.png",
12
+ :priority => PRIORITY_CLASS,
13
+ }
8
14
  end
9
15
 
10
16
  # @class name
@@ -0,0 +1,19 @@
1
+ require "jsduck/tag/boolean_tag"
2
+
3
+ module JsDuck::Tag
4
+ # The @component tag should be rarely used explicitly as it gets
5
+ # auto-detected by Process::Components for any component inheriting
6
+ # from Ext.Component.
7
+ class Component < BooleanTag
8
+ def initialize
9
+ @pattern = "component"
10
+ @class_icon = {
11
+ :small => File.dirname(__FILE__) + "/icons/component.png",
12
+ :large => File.dirname(__FILE__) + "/icons/component-large.png",
13
+ :redirect => File.dirname(__FILE__) + "/icons/component-redirect.png",
14
+ :priority => PRIORITY_COMPONENT,
15
+ }
16
+ super
17
+ end
18
+ end
19
+ end
@@ -14,6 +14,16 @@ module JsDuck::Tag
14
14
  }
15
15
  end
16
16
 
17
+ def process_code(code)
18
+ h = super(code)
19
+ h[:params] = code[:params]
20
+ h
21
+ end
22
+
23
+ def merge(h, docs, code)
24
+ JsDuck::ParamsMerger.merge(h, docs, code)
25
+ end
26
+
17
27
  def to_html(mixin, cls)
18
28
  member_link(mixin) + member_params(mixin[:params])
19
29
  end
@@ -4,7 +4,7 @@ module JsDuck::Tag
4
4
  class Deprecated < DeprecatedTag
5
5
  def initialize
6
6
  @tagname = :deprecated
7
- @msg = "This {TAGNAME} has been <strong>deprected</strong>"
7
+ @msg = "This {TAGNAME} has been <strong>deprecated</strong>"
8
8
  @css = <<-EOCSS
9
9
  .signature .deprecated {
10
10
  background-color: #aa0000;
@@ -1,5 +1,5 @@
1
1
  require "jsduck/tag/tag"
2
- require "jsduck/tag_registry"
2
+ require "jsduck/member_registry"
3
3
 
4
4
  module JsDuck::Tag
5
5
  class Inheritdoc < Tag
@@ -31,7 +31,7 @@ module JsDuck::Tag
31
31
  tag[:static] = true
32
32
  p.match(/static-/)
33
33
  end
34
- if p.look(JsDuck::TagRegistry.member_type_regex)
34
+ if p.look(JsDuck::MemberRegistry.regex)
35
35
  tag[:type] = p.match(/\w+/).to_sym
36
36
  p.match(/-/)
37
37
  end
@@ -15,5 +15,18 @@ module JsDuck::Tag
15
15
  EOCSS
16
16
  super
17
17
  end
18
+
19
+ # Initializes the tooltip text based on the --new-since and
20
+ # --import options passed from command line.
21
+ #
22
+ # NOTE: This method is explicitly called from JsDuck::Options class.
23
+ def init_tooltip!(opts)
24
+ if opts.new_since
25
+ @signature[:tooltip] = "New since #{opts.new_since}"
26
+ elsif opts.import.length > 0
27
+ @signature[:tooltip] = "New since #{opts.import.last[:version]}"
28
+ end
29
+ end
30
+
18
31
  end
19
32
  end
@@ -1,5 +1,5 @@
1
1
  require "jsduck/tag/tag"
2
- require "jsduck/logger"
2
+ require 'jsduck/util/html'
3
3
 
4
4
  module JsDuck::Tag
5
5
  class Since < Tag
@@ -22,7 +22,7 @@ module JsDuck::Tag
22
22
 
23
23
  def to_html(context)
24
24
  <<-EOHTML
25
- <p>Available since: <b>#{context[:since]}</b></p>
25
+ <p>Available since: <b>#{JsDuck::Util::HTML.escape(context[:since])}</b></p>
26
26
  EOHTML
27
27
  end
28
28
 
@@ -5,6 +5,19 @@ module JsDuck::Tag
5
5
  def initialize
6
6
  @pattern = "singleton"
7
7
  @ext_define_pattern = "singleton"
8
+ @class_icon = {
9
+ :small => File.dirname(__FILE__) + "/icons/singleton.png",
10
+ :large => File.dirname(__FILE__) + "/icons/singleton-large.png",
11
+ :redirect => File.dirname(__FILE__) + "/icons/singleton-redirect.png",
12
+ :priority => PRIORITY_SINGLETON,
13
+ }
14
+ @signature = {:long => "singleton", :short => "single"}
15
+ @css = <<-EOCSS
16
+ .signature .singleton {
17
+ background-color: transparent;
18
+ color: #929292;
19
+ }
20
+ EOCSS
8
21
  super
9
22
  end
10
23
 
@@ -133,6 +133,25 @@ module JsDuck::Tag
133
133
  #
134
134
  attr_reader :css
135
135
 
136
+ # Defines custom class icon files.
137
+ #
138
+ # It must be a hash with the following keys:
139
+ #
140
+ # - :large - the large icon used in class header
141
+ # - :small - small icon used in class tree and search
142
+ # - :redirect - redirect icon for alternateClassNames in search.
143
+ # - :priority - a number to determine which icon gets used when
144
+ # a class has several tags that set a custom icon. An icon
145
+ # with a larger priority wins.
146
+ #
147
+ # Used by @class tag to define the default icon.
148
+ # Used by @singleton and @component tags for a different icon.
149
+ attr_reader :class_icon
150
+
151
+ PRIORITY_SINGLETON = 2
152
+ PRIORITY_COMPONENT = 1
153
+ PRIORITY_CLASS = 0
154
+
136
155
  # Returns all descendants of JsDuck::Tag::Tag class.
137
156
  def self.descendants
138
157
  result = []
@@ -2,7 +2,7 @@ require "jsduck/tag_loader"
2
2
 
3
3
  module JsDuck
4
4
 
5
- # Access to builtin @tags
5
+ # Access to all @tag definitions.
6
6
  class TagRegistry
7
7
  # Access to the singleton instance (only used internally)
8
8
  def self.instance
@@ -10,10 +10,21 @@ module JsDuck
10
10
  @instance
11
11
  end
12
12
 
13
- # Reconfigures the registry with additional load paths.
14
- # Used in Options class.
15
- def self.reconfigure(load_paths)
16
- @instance = TagRegistry.new(load_paths)
13
+ # Configures TagRegistry according to the command line options.
14
+ def self.configure(opts)
15
+ if opts.tags.length > 0
16
+ # Reconfigures the registry with additional load paths.
17
+ @instance = TagRegistry.new(opts.tags)
18
+ else
19
+ # Ensure the TagRegistry get instantiated just once.
20
+ # Otherwise the parallel processing causes multiple requests
21
+ # to initialize the TagRegistry, resulting in loading the Tag
22
+ # definitions multiple times.
23
+ instance
24
+ end
25
+
26
+ # The tooltip of @new can now be configured.
27
+ get_by_name(:new).init_tooltip!(opts)
17
28
  end
18
29
 
19
30
  # Redirect calls from TagRegistry.method to TagRegistry.instance.method,
@@ -24,14 +35,9 @@ module JsDuck
24
35
 
25
36
  def initialize(load_paths=[])
26
37
  @patterns = {}
27
- @ext_define_patterns = {}
28
- @ext_define_defaults = {}
29
38
  @tagnames = {}
30
39
  @signatures = []
31
- @html_renderers = []
32
- @html_renderers_sorted = false
33
- @member_types = []
34
- @css = []
40
+ @tags = []
35
41
 
36
42
  instantiate_tags(TagLoader.new(load_paths).load_all)
37
43
  end
@@ -45,35 +51,16 @@ module JsDuck
45
51
  @patterns[pattern] = tag
46
52
  end
47
53
 
48
- Array(tag.ext_define_pattern).each do |pattern|
49
- @ext_define_patterns[pattern] = tag
50
- end
51
-
52
- if tag.ext_define_default
53
- @ext_define_defaults.merge!(tag.ext_define_default)
54
- end
55
-
56
54
  if tag.tagname
57
55
  @tagnames[tag.tagname] = tag
58
56
  end
59
57
 
60
- if tag.respond_to?(:member_type) && tag.member_type
61
- tag.member_type[:name] = tag.tagname
62
- @member_types << tag.member_type
63
- end
64
-
65
58
  if tag.signature
66
59
  tag.signature[:tagname] = tag.tagname
67
60
  @signatures << tag.signature
68
61
  end
69
62
 
70
- if tag.html_position
71
- @html_renderers << tag
72
- end
73
-
74
- if tag.css
75
- @css << tag.css
76
- end
63
+ @tags << tag
77
64
  end
78
65
  end
79
66
 
@@ -81,55 +68,12 @@ module JsDuck
81
68
  # Accessors for lists of tags
82
69
  #
83
70
 
84
- # Default values for class config when Ext.define is encountered.
85
- attr_reader :ext_define_defaults
86
-
87
71
  # Array of attributes to be shown in member signatures
88
72
  # (and in order they should be shown in).
89
73
  attr_reader :signatures
90
74
 
91
- # Same as #member_types, but returns just the names of member types.
92
- def member_type_names
93
- member_types.map {|mt| mt[:name] }
94
- end
95
-
96
- # Returns array of available member types.
97
- # Sorted in the order defined by :position.
98
- def member_types
99
- if !@member_types_sorted
100
- @member_types.sort! {|a, b| a[:position] <=> b[:position] }
101
- @member_types_sorted = true
102
- end
103
-
104
- @member_types
105
- end
106
-
107
- # Regex for matching member type name in member reference.
108
- #
109
- # The regex matches strings like: "method-" or "event-". It
110
- # contains a capture group to capture the actual name of the
111
- # member, leaving out the dash "-".
112
- def member_type_regex
113
- @member_type_regex if @member_type_regex
114
- @member_type_regex = Regexp.new("(?:(" + member_type_names.join("|") + ")-)")
115
- end
116
-
117
- # Returns tags for rendering HTML, sorted in the order they should
118
- # appear in final output. Sorting order is determined by the
119
- # numeric :html_position field.
120
- def html_renderers
121
- if !@html_renderers_sorted
122
- @html_renderers.sort! {|a, b| a.html_position <=> b.html_position }
123
- @html_renderers_sorted = true
124
- end
125
-
126
- @html_renderers
127
- end
128
-
129
- # Returns all the CSS gathered from @css attributes of tags.
130
- def css
131
- @css.join("\n")
132
- end
75
+ # Array of all available tags
76
+ attr_reader :tags
133
77
 
134
78
  #
135
79
  # Accessors for a single tag
@@ -140,11 +84,6 @@ module JsDuck
140
84
  @patterns[name]
141
85
  end
142
86
 
143
- # Accesses tag by Ext.define pattern
144
- def get_by_ext_define_pattern(name)
145
- @ext_define_patterns[name]
146
- end
147
-
148
87
  # Accesses tag by name - the symbol under which the tag data
149
88
  # is stored in final hash.
150
89
  def get_by_name(name)
@@ -13,6 +13,11 @@ module JsDuck
13
13
  class IO
14
14
  @@encoding = "BOM|UTF-8"
15
15
 
16
+ # Configures the encoding from command line options.
17
+ def self.configure(opts)
18
+ encoding = opts.encoding if opts.encoding
19
+ end
20
+
16
21
  # Sets the external encoding to be used for reading files.
17
22
  # When it's different from UTF-8, the input will be converted to UTF-8.
18
23
  def self.encoding=(e)