jsduck 4.10.4 → 5.0.0.beta01

Sign up to get free protection for your applications and to get access to all the features.
Files changed (183) hide show
  1. data/.travis.yml +0 -1
  2. data/README.md +32 -6
  3. data/Rakefile +10 -18
  4. data/bin/compare +5 -5
  5. data/bin/jsduck +2 -3
  6. data/jsduck.gemspec +3 -4
  7. data/lib/jsduck/aggregator.rb +21 -80
  8. data/lib/jsduck/app.rb +7 -14
  9. data/lib/jsduck/app_data.rb +4 -5
  10. data/lib/jsduck/assets.rb +4 -7
  11. data/lib/jsduck/base_type.rb +53 -0
  12. data/lib/jsduck/batch_parser.rb +8 -87
  13. data/lib/jsduck/batch_processor.rb +77 -0
  14. data/lib/jsduck/categories/auto.rb +83 -0
  15. data/lib/jsduck/categories/class_name.rb +63 -0
  16. data/lib/jsduck/categories/factory.rb +113 -0
  17. data/lib/jsduck/categories/file.rb +75 -0
  18. data/lib/jsduck/class.rb +3 -9
  19. data/lib/jsduck/class_doc_expander.rb +1 -1
  20. data/lib/jsduck/css/lexer.rb +203 -0
  21. data/lib/jsduck/css/parser.rb +121 -0
  22. data/lib/jsduck/doc/comment.rb +40 -0
  23. data/lib/jsduck/doc/map.rb +23 -0
  24. data/lib/jsduck/doc/parser.rb +128 -0
  25. data/lib/jsduck/doc/processor.rb +52 -0
  26. data/lib/jsduck/doc/scanner.rb +76 -0
  27. data/lib/jsduck/doc/standard_tag_parser.rb +154 -0
  28. data/lib/jsduck/doc/subproperties.rb +64 -0
  29. data/lib/jsduck/docs_code_comparer.rb +31 -0
  30. data/lib/jsduck/export_writer.rb +2 -2
  31. data/lib/jsduck/exporter/app.rb +16 -4
  32. data/lib/jsduck/exporter/full.rb +2 -2
  33. data/lib/jsduck/format/batch.rb +58 -0
  34. data/lib/jsduck/format/class.rb +62 -0
  35. data/lib/jsduck/format/doc.rb +172 -0
  36. data/lib/jsduck/format/html_stack.rb +109 -0
  37. data/lib/jsduck/format/shortener.rb +55 -0
  38. data/lib/jsduck/format/subproperties.rb +64 -0
  39. data/lib/jsduck/guides.rb +32 -14
  40. data/lib/jsduck/index_html.rb +3 -1
  41. data/lib/jsduck/inline/auto_link.rb +2 -2
  42. data/lib/jsduck/inline/link.rb +4 -3
  43. data/lib/jsduck/inline/link_renderer.rb +2 -2
  44. data/lib/jsduck/inline/video.rb +8 -2
  45. data/lib/jsduck/js/ast.rb +361 -0
  46. data/lib/jsduck/js/esprima.rb +39 -0
  47. data/lib/jsduck/{esprima → js/esprima}/esprima.js +0 -0
  48. data/lib/jsduck/js/evaluator.rb +70 -0
  49. data/lib/jsduck/js/ext_patterns.rb +70 -0
  50. data/lib/jsduck/js/function.rb +206 -0
  51. data/lib/jsduck/js/node.rb +194 -0
  52. data/lib/jsduck/js/node_array.rb +36 -0
  53. data/lib/jsduck/js/parser.rb +223 -0
  54. data/lib/jsduck/js/serializer.rb +263 -0
  55. data/lib/jsduck/js/utils.rb +21 -0
  56. data/lib/jsduck/logger.rb +3 -13
  57. data/lib/jsduck/members_index.rb +3 -4
  58. data/lib/jsduck/merger.rb +25 -145
  59. data/lib/jsduck/options.rb +29 -132
  60. data/lib/jsduck/parser.rb +76 -0
  61. data/lib/jsduck/process/accessors.rb +133 -0
  62. data/lib/jsduck/process/circular_deps.rb +58 -0
  63. data/lib/jsduck/process/enums.rb +91 -0
  64. data/lib/jsduck/process/ext4_events.rb +43 -0
  65. data/lib/jsduck/process/global_members.rb +36 -0
  66. data/lib/jsduck/process/ignored_classes.rb +16 -0
  67. data/lib/jsduck/process/importer.rb +58 -0
  68. data/lib/jsduck/process/inherit_doc.rb +197 -0
  69. data/lib/jsduck/process/lint.rb +135 -0
  70. data/lib/jsduck/process/overrides.rb +99 -0
  71. data/lib/jsduck/process/return_values.rb +72 -0
  72. data/lib/jsduck/process/versions.rb +102 -0
  73. data/lib/jsduck/relations.rb +5 -0
  74. data/lib/jsduck/render/class.rb +144 -0
  75. data/lib/jsduck/render/sidebar.rb +97 -0
  76. data/lib/jsduck/render/signature.rb +94 -0
  77. data/lib/jsduck/render/subproperties.rb +99 -0
  78. data/lib/jsduck/render/tags.rb +38 -0
  79. data/lib/jsduck/search_data.rb +19 -13
  80. data/lib/jsduck/source/file.rb +8 -17
  81. data/lib/jsduck/tag/abstract.rb +4 -7
  82. data/lib/jsduck/tag/accessor.rb +10 -0
  83. data/lib/jsduck/tag/alias.rb +61 -0
  84. data/lib/jsduck/tag/alternate_class_names.rb +17 -0
  85. data/lib/jsduck/tag/aside.rb +28 -31
  86. data/lib/jsduck/tag/author.rb +9 -5
  87. data/lib/jsduck/tag/boolean_tag.rb +24 -0
  88. data/lib/jsduck/tag/cfg.rb +45 -0
  89. data/lib/jsduck/tag/chainable.rb +5 -7
  90. data/lib/jsduck/tag/class.rb +28 -0
  91. data/lib/jsduck/tag/class_list_tag.rb +40 -0
  92. data/lib/jsduck/tag/constructor.rb +24 -0
  93. data/lib/jsduck/tag/css_mixin.rb +17 -0
  94. data/lib/jsduck/tag/css_var.rb +29 -0
  95. data/lib/jsduck/tag/default.rb +31 -0
  96. data/lib/jsduck/tag/deprecated.rb +13 -27
  97. data/lib/jsduck/tag/deprecated_tag.rb +58 -0
  98. data/lib/jsduck/tag/doc.rb +32 -0
  99. data/lib/jsduck/tag/docauthor.rb +4 -5
  100. data/lib/jsduck/tag/enum.rb +70 -0
  101. data/lib/jsduck/tag/event.rb +28 -0
  102. data/lib/jsduck/tag/evented.rb +10 -0
  103. data/lib/jsduck/tag/extends.rb +45 -0
  104. data/lib/jsduck/tag/ftype.rb +18 -0
  105. data/lib/jsduck/tag/hide.rb +4 -11
  106. data/lib/jsduck/tag/ignore.rb +6 -7
  107. data/lib/jsduck/tag/inheritable.rb +10 -0
  108. data/lib/jsduck/tag/inheritdoc.rb +48 -0
  109. data/lib/jsduck/tag/markdown.rb +8 -6
  110. data/lib/jsduck/tag/member.rb +24 -0
  111. data/lib/jsduck/tag/method.rb +35 -0
  112. data/lib/jsduck/tag/mixins.rb +26 -0
  113. data/lib/jsduck/tag/name.rb +36 -0
  114. data/lib/jsduck/tag/new.rb +13 -27
  115. data/lib/jsduck/tag/override.rb +37 -0
  116. data/lib/jsduck/tag/overrides.rb +29 -0
  117. data/lib/jsduck/tag/param.rb +87 -0
  118. data/lib/jsduck/tag/preventable.rb +19 -10
  119. data/lib/jsduck/tag/private.rb +28 -13
  120. data/lib/jsduck/tag/property.rb +39 -0
  121. data/lib/jsduck/tag/protected.rb +5 -7
  122. data/lib/jsduck/tag/ptype.rb +18 -0
  123. data/lib/jsduck/tag/readonly.rb +4 -7
  124. data/lib/jsduck/tag/removed.rb +21 -29
  125. data/lib/jsduck/tag/required.rb +11 -9
  126. data/lib/jsduck/tag/requires.rb +12 -0
  127. data/lib/jsduck/tag/return.rb +47 -0
  128. data/lib/jsduck/tag/since.rb +19 -11
  129. data/lib/jsduck/tag/singleton.rb +15 -0
  130. data/lib/jsduck/tag/static.rb +5 -7
  131. data/lib/jsduck/tag/subproperties.rb +23 -0
  132. data/lib/jsduck/tag/tag.rb +208 -0
  133. data/lib/jsduck/tag/template.rb +14 -9
  134. data/lib/jsduck/tag/throws.rb +38 -0
  135. data/lib/jsduck/tag/type.rb +48 -0
  136. data/lib/jsduck/tag/uses.rb +12 -0
  137. data/lib/jsduck/tag/xtype.rb +30 -0
  138. data/lib/jsduck/tag_loader.rb +39 -0
  139. data/lib/jsduck/tag_registry.rb +189 -0
  140. data/lib/jsduck/type_parser.rb +3 -3
  141. data/lib/jsduck/web_writer.rb +2 -2
  142. data/lib/jsduck/welcome.rb +1 -1
  143. metadata +578 -538
  144. data/lib/jsduck/accessors.rb +0 -136
  145. data/lib/jsduck/ast.rb +0 -524
  146. data/lib/jsduck/auto_categories.rb +0 -80
  147. data/lib/jsduck/batch_formatter.rb +0 -60
  148. data/lib/jsduck/categories.rb +0 -73
  149. data/lib/jsduck/categories_class_name.rb +0 -37
  150. data/lib/jsduck/circular_deps.rb +0 -56
  151. data/lib/jsduck/class_formatter.rb +0 -102
  152. data/lib/jsduck/columns.rb +0 -56
  153. data/lib/jsduck/css_lexer.rb +0 -201
  154. data/lib/jsduck/css_parser.rb +0 -119
  155. data/lib/jsduck/doc_ast.rb +0 -319
  156. data/lib/jsduck/doc_formatter.rb +0 -142
  157. data/lib/jsduck/doc_parser.rb +0 -611
  158. data/lib/jsduck/doc_type.rb +0 -59
  159. data/lib/jsduck/enum.rb +0 -73
  160. data/lib/jsduck/esprima.rb +0 -51
  161. data/lib/jsduck/evaluator.rb +0 -69
  162. data/lib/jsduck/ext_patterns.rb +0 -58
  163. data/lib/jsduck/file_categories.rb +0 -76
  164. data/lib/jsduck/function_ast.rb +0 -206
  165. data/lib/jsduck/guide_anchors.rb +0 -32
  166. data/lib/jsduck/guide_toc.rb +0 -49
  167. data/lib/jsduck/html_stack.rb +0 -105
  168. data/lib/jsduck/importer.rb +0 -121
  169. data/lib/jsduck/inherit_doc.rb +0 -193
  170. data/lib/jsduck/js_parser.rb +0 -221
  171. data/lib/jsduck/lint.rb +0 -133
  172. data/lib/jsduck/meta_tag.rb +0 -88
  173. data/lib/jsduck/meta_tag_loader.rb +0 -67
  174. data/lib/jsduck/meta_tag_registry.rb +0 -111
  175. data/lib/jsduck/meta_tag_renderer.rb +0 -34
  176. data/lib/jsduck/news.rb +0 -128
  177. data/lib/jsduck/override.rb +0 -87
  178. data/lib/jsduck/renderer.rb +0 -361
  179. data/lib/jsduck/return_values.rb +0 -72
  180. data/lib/jsduck/serializer.rb +0 -262
  181. data/lib/jsduck/shortener.rb +0 -58
  182. data/lib/jsduck/signature_renderer.rb +0 -91
  183. data/lib/jsduck/source/file_parser.rb +0 -72
@@ -0,0 +1,76 @@
1
+ require 'jsduck/js/parser'
2
+ require 'jsduck/js/ast'
3
+ require 'jsduck/css/parser'
4
+ require 'jsduck/doc/parser'
5
+ require 'jsduck/doc/processor'
6
+ require 'jsduck/doc/map'
7
+ require 'jsduck/merger'
8
+ require 'jsduck/base_type'
9
+ require 'jsduck/class_doc_expander'
10
+
11
+ module JsDuck
12
+ # Performs the actual parsing of CSS or JS source.
13
+ #
14
+ # This is the class that brings together all the different steps of
15
+ # parsing the source.
16
+ class Parser
17
+
18
+ def initialize
19
+ @doc_parser = Doc::Parser.new
20
+ @class_doc_expander = ClassDocExpander.new
21
+ @doc_processor = Doc::Processor.new
22
+ @merger = Merger.new
23
+ @filename = ""
24
+ end
25
+
26
+ # Parses file into final docset that can be fed into Aggregator
27
+ def parse(contents, filename="", options={})
28
+ @doc_processor.filename = @filename = filename
29
+
30
+ parse_js_or_css(contents, filename, options).map do |docset|
31
+ expand(docset)
32
+ end.flatten.map do |docset|
33
+ merge(docset)
34
+ end
35
+ end
36
+
37
+ private
38
+
39
+ # Parses the file depending on filename as JS or CSS
40
+ def parse_js_or_css(contents, filename, options)
41
+ if filename =~ /\.s?css$/
42
+ docs = Css::Parser.new(contents, options).parse
43
+ else
44
+ docs = Js::Parser.new(contents, options).parse
45
+ docs = Js::Ast.new(docs).detect_all!
46
+ end
47
+ end
48
+
49
+ # Parses the docs, detects tagname and expands class docset
50
+ def expand(docset)
51
+ docset[:comment] = @doc_parser.parse(docset[:comment], @filename, docset[:linenr])
52
+ docset[:doc_map] = Doc::Map.build(docset[:comment])
53
+ docset[:tagname] = BaseType.detect(docset[:doc_map], docset[:code])
54
+
55
+ if docset[:tagname] == :class
56
+ # expand class into several docsets, and rebuild doc-maps for all of them.
57
+ @class_doc_expander.expand(docset).map do |ds|
58
+ ds[:doc_map] = Doc::Map.build(ds[:comment])
59
+ ds
60
+ end
61
+ else
62
+ docset
63
+ end
64
+ end
65
+
66
+ # Merges comment and code parts of docset
67
+ def merge(docset)
68
+ @doc_processor.linenr = docset[:linenr]
69
+ docset[:comment] = @doc_processor.process(docset[:tagname], docset[:doc_map])
70
+ docset.delete(:doc_map)
71
+
72
+ @merger.merge(docset, @filename, docset[:linenr])
73
+ end
74
+ end
75
+
76
+ end
@@ -0,0 +1,133 @@
1
+ require 'jsduck/logger'
2
+
3
+ module JsDuck
4
+ module Process
5
+
6
+ class Accessors
7
+ def initialize(classes)
8
+ @classes = classes
9
+ end
10
+
11
+ # Generates accessors in all classes.
12
+ def process_all!
13
+ @classes.each_value {|cls| process(cls) }
14
+ end
15
+
16
+ # Given a class, generates accessor methods to configs with
17
+ # @accessor tag. Modifies the class by adding these methods.
18
+ # When class already contains a getter or setter, the method is
19
+ # not added.
20
+ def process(cls)
21
+ # Grab all configs tagged as @accessor
22
+ accessors = cls[:members].find_all {|m| m[:tagname] == :cfg && m[:accessor] }
23
+
24
+ # Build lookup tables of method and event names
25
+ methods = build_lookup_table(cls[:members], :method)
26
+ events = build_lookup_table(cls[:members], :event)
27
+
28
+ accessors.each do |cfg|
29
+ # add getter if no method with same name exists
30
+ get = create_getter(cfg)
31
+ if !methods[get[:name]]
32
+ cls[:members] << get
33
+ end
34
+ # add setter if no method with same name exists
35
+ set = create_setter(cfg)
36
+ if !methods[set[:name]]
37
+ cls[:members] << set
38
+ end
39
+ # for evented accessors
40
+ if cfg[:evented]
41
+ # add event if no event with same name exists
42
+ ev = create_event(cfg)
43
+ if !events[ev[:name]]
44
+ cls[:members] << ev
45
+ end
46
+ end
47
+ end
48
+ end
49
+
50
+ def build_lookup_table(members, tagname)
51
+ map = {}
52
+ members.each do |m|
53
+ map[m[:name]] = m if m[:tagname] == tagname
54
+ end
55
+ map
56
+ end
57
+
58
+ def create_getter(cfg)
59
+ name = "get" + upcase_first(cfg[:name])
60
+ return add_shared({
61
+ :tagname => :method,
62
+ :name => name,
63
+ :doc => "Returns the value of {@link #cfg-#{cfg[:name]}}.",
64
+ :params => [],
65
+ :return => {
66
+ :type => cfg[:type],
67
+ :doc => "",
68
+ },
69
+ :id => "method-" + name,
70
+ }, cfg)
71
+ end
72
+
73
+ def create_setter(cfg)
74
+ name = "set" + upcase_first(cfg[:name]);
75
+ return add_shared({
76
+ :tagname => :method,
77
+ :name => name,
78
+ :doc => "Sets the value of {@link #cfg-#{cfg[:name]}}.",
79
+ :params => [{
80
+ :type => cfg[:type],
81
+ :name => cfg[:name],
82
+ :doc => "",
83
+ }],
84
+ :id => "method-" + name,
85
+ }, cfg)
86
+ end
87
+
88
+ def create_event(cfg)
89
+ name = cfg[:name].downcase + "change"
90
+ setter_name = "set" + upcase_first(cfg[:name]);
91
+ return add_shared({
92
+ :tagname => :event,
93
+ :name => name,
94
+ :doc => "Fires when the {@link ##{cfg[:id]}} configuration is changed by {@link #method-#{setter_name}}.",
95
+ :params => [
96
+ {
97
+ :name => "this",
98
+ :type => cfg[:owner],
99
+ :doc => "The #{cfg[:owner]} instance."
100
+ },
101
+ {
102
+ :name => "value",
103
+ :type => cfg[:type],
104
+ :doc => "The new value being set."
105
+ },
106
+ {
107
+ :name => "oldValue",
108
+ :type => cfg[:type],
109
+ :doc => "The existing value."
110
+ },
111
+ ],
112
+ :id => "event-" + name,
113
+ }, cfg)
114
+ end
115
+
116
+ def add_shared(hash, cfg)
117
+ hash.merge!({
118
+ :owner => cfg[:owner],
119
+ :files => cfg[:files],
120
+ :private => cfg[:private],
121
+ :protected => cfg[:protected],
122
+ :autodetected => cfg[:autodetected],
123
+ :hide => cfg[:hide],
124
+ })
125
+ end
126
+
127
+ def upcase_first(str)
128
+ str[0,1].upcase + str[1..-1]
129
+ end
130
+ end
131
+
132
+ end
133
+ end
@@ -0,0 +1,58 @@
1
+ require 'jsduck/logger'
2
+
3
+ module JsDuck
4
+ module Process
5
+
6
+ # Checks for circular dependencies
7
+ class CircularDeps
8
+ def initialize(classes)
9
+ @classes = classes
10
+ end
11
+
12
+ # Checks all classes for circular dependencies.
13
+ #
14
+ # When found, exits with a fatal error message.
15
+ def process_all!
16
+ @classes.each do |cls|
17
+ if chain = check(cls)
18
+ Logger.fatal("Class #{cls[:name]} has a circular dependency: #{chain}")
19
+ exit 1
20
+ end
21
+ end
22
+ end
23
+
24
+ # Checks class for circular dependencies.
25
+ #
26
+ # When all OK, returns false.
27
+ #
28
+ # When circular dependencies found returns a string describing the
29
+ # problematic dependency chain e.g. "Foo extends Bar mixins Foo".
30
+ def check(cls, names = [])
31
+ names += [cls[:name]]
32
+
33
+ if cls.parent && chain = track_circular(" extends ", cls.parent, names)
34
+ return chain
35
+ end
36
+
37
+ cls.mixins.each do |mixin|
38
+ if chain = track_circular(" mixins ", mixin, names)
39
+ return chain
40
+ end
41
+ end
42
+
43
+ false
44
+ end
45
+
46
+ def track_circular(type, cls, names)
47
+ names += [type]
48
+ if names.include?(cls[:name])
49
+ (names + [cls[:name]]).join("")
50
+ else
51
+ check(cls, names)
52
+ end
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,91 @@
1
+ require 'jsduck/logger'
2
+
3
+ module JsDuck
4
+ module Process
5
+
6
+ class Enums
7
+ def initialize(classes_hash)
8
+ @classes_hash = classes_hash
9
+ end
10
+
11
+ # Applies additional processing to all enum-classes.
12
+ def process_all!
13
+ @classes_hash.each_value do |cls|
14
+ if cls[:enum]
15
+ process(cls)
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ # processes single class
23
+ def process(cls)
24
+ expand_default(cls)
25
+ reject_not_properties(cls)
26
+ strip_inheritdoc(cls)
27
+ cls[:enum][:type] = infer_type(cls) unless cls[:enum][:type]
28
+ end
29
+
30
+ # Expands default value like widget.* into list of properties
31
+ def expand_default(cls)
32
+ if cls[:enum][:default] =~ /\A(.*)\.\*\z/
33
+ each_alias($1) do |name, owner|
34
+ cls[:members] << {
35
+ :tagname => :property,
36
+ :id => 'property-' + name,
37
+ :name => name,
38
+ :default => "'" + name + "'",
39
+ :type => "String",
40
+ :private => owner[:private],
41
+ :files => cls[:files],
42
+ :owner => cls[:name],
43
+ :doc => "Alias for {@link #{owner[:name]}}.",
44
+ }
45
+ end
46
+ end
47
+ end
48
+
49
+ def each_alias(prefix)
50
+ @classes_hash.each_value do |cls|
51
+ if cls[:aliases] && cls[:aliases][prefix]
52
+ cls[:aliases][prefix].each {|name| yield(name, cls) }
53
+ end
54
+ end
55
+ end
56
+
57
+ # Only allow properties as members, throw away all others.
58
+ def reject_not_properties(cls)
59
+ cls[:members].reject! do |m|
60
+ if m[:tagname] == :property
61
+ false
62
+ else
63
+ f = m[:files][0]
64
+ Logger.warn(:enum, "Enums can only contain properties, #{m[:tagname]} found instead.", f[:filename], f[:linenr])
65
+ true
66
+ end
67
+ end
68
+ end
69
+
70
+ # Remove the auto-inserted inheritdoc tag so the auto-detected enum
71
+ # values default to being public.
72
+ def strip_inheritdoc(cls)
73
+ cls[:members].each do |p|
74
+ p[:inheritdoc] = nil if p[:autodetected]
75
+ end
76
+ end
77
+
78
+ # Given an enum class, returns the type infered from its values.
79
+ def infer_type(cls)
80
+ if cls[:members].length > 0
81
+ types = cls[:members].map {|p| p[:type] }
82
+ types.sort.uniq.join("/")
83
+ else
84
+ "Object"
85
+ end
86
+ end
87
+
88
+ end
89
+
90
+ end
91
+ end
@@ -0,0 +1,43 @@
1
+ module JsDuck
2
+ module Process
3
+
4
+ # Appends Ext4 options parameter to the parameter list of each event
5
+ # in each class.
6
+ #
7
+ # But only does so when :ext4_events option is set to true or the
8
+ # code itself is detected as being writted in Ext4 style.
9
+ class Ext4Events
10
+ def initialize(classes, opts={})
11
+ @classes = classes
12
+ @opts = opts
13
+ end
14
+
15
+ def process_all!
16
+ if @opts[:ext4_events] == true || (@opts[:ext4_events] == nil && ext4_style_code?)
17
+ @classes.each_value {|cls| process(cls) }
18
+ end
19
+ end
20
+
21
+ # Are we dealing with code looking like ExtJS 4?
22
+ # True if any of the classes is defined with Ext.define()
23
+ def ext4_style_code?
24
+ @classes.values.any? {|cls| cls[:code_type] == :ext_define }
25
+ end
26
+
27
+ def process(cls)
28
+ cls[:members].each do |m|
29
+ m[:params] << OPTIONS if m[:tagname] == :event
30
+ end
31
+ end
32
+
33
+ OPTIONS = {
34
+ :tagname => :params,
35
+ :name => "eOpts",
36
+ :type => "Object",
37
+ :doc => "The options object passed to {@link Ext.util.Observable#addListener}."
38
+ }
39
+
40
+ end
41
+
42
+ end
43
+ end
@@ -0,0 +1,36 @@
1
+ require 'jsduck/logger'
2
+
3
+ module JsDuck
4
+ module Process
5
+
6
+ # Prints warning for each global member.
7
+ # Removes "global" class when --ignore-global option used.
8
+ # Warnings for global members are printed regardless of that setting,
9
+ # but of course can be turned off using --warnings=-global
10
+ class GlobalMembers
11
+ def initialize(classes_hash, opts)
12
+ @classes_hash = classes_hash
13
+ @opts = opts
14
+ end
15
+
16
+ def process_all!
17
+ # Do nothing when there's no "global" class.
18
+ return unless @classes_hash["global"]
19
+
20
+ # Warnings for each global member
21
+ @classes_hash["global"][:members].each do |m|
22
+ type = m[:tagname].to_s
23
+ name = m[:name]
24
+ file = m[:files][0]
25
+ Logger.warn(:global, "Global #{type}: #{name}", file[:filename], file[:linenr])
26
+ end
27
+
28
+ # Throw away the "global" class when --ignore-global option used
29
+ if @opts.ignore_global
30
+ @classes_hash.delete("global")
31
+ end
32
+ end
33
+ end
34
+
35
+ end
36
+ end
@@ -0,0 +1,16 @@
1
+ module JsDuck
2
+ module Process
3
+
4
+ # Gets rid of classes marked with @ignore
5
+ class IgnoredClasses
6
+ def initialize(classes_hash)
7
+ @classes_hash = classes_hash
8
+ end
9
+
10
+ def process_all!
11
+ @classes_hash.delete_if {|name, cls| cls[:ignore] }
12
+ end
13
+ end
14
+
15
+ end
16
+ end