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,12 @@
1
+ require "jsduck/tag/class_list_tag"
2
+
3
+ module JsDuck::Tag
4
+ class Requires < ClassListTag
5
+ def initialize
6
+ @pattern = "requires"
7
+ @tagname = :requires
8
+ @ext_define_pattern = "requires"
9
+ @ext_define_default = {:requires => []}
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,47 @@
1
+ require "jsduck/tag/tag"
2
+ require "jsduck/doc/subproperties"
3
+ require "jsduck/render/subproperties"
4
+
5
+ module JsDuck::Tag
6
+ class Return < Tag
7
+ def initialize
8
+ @pattern = ["return", "returns"]
9
+ @tagname = :return
10
+ @html_position = POS_RETURN
11
+ end
12
+
13
+ # @return {Type} return.name ...
14
+ def parse_doc(p)
15
+ tag = p.standard_tag({:tagname => :return, :type => true})
16
+ tag[:name] = subproperty_name(p)
17
+ tag[:doc] = :multiline
18
+ tag
19
+ end
20
+
21
+ def subproperty_name(p)
22
+ if p.hw.look(/return\.\w/)
23
+ p.ident_chain
24
+ else
25
+ "return"
26
+ end
27
+ end
28
+
29
+ def process_doc(h, tags, pos)
30
+ ret = tags[0]
31
+ h[:return] = {
32
+ :type => ret[:type] || "Object",
33
+ :name => ret[:name] || "return",
34
+ :doc => ret[:doc] || "",
35
+ :properties => JsDuck::Doc::Subproperties.nest(tags, pos)[0][:properties],
36
+ }
37
+ end
38
+
39
+ def format(m, formatter)
40
+ formatter.format_subproperty(m[:return])
41
+ end
42
+
43
+ def to_html(m)
44
+ JsDuck::Render::Subproperties.render_return(m[:return])
45
+ end
46
+ end
47
+ end
@@ -1,26 +1,34 @@
1
- require "jsduck/meta_tag"
1
+ require "jsduck/tag/tag"
2
2
  require "jsduck/logger"
3
3
 
4
4
  module JsDuck::Tag
5
- # Implementation of @since tag.
6
- class Since < JsDuck::MetaTag
5
+ class Since < Tag
7
6
  def initialize
8
- @name = "since"
9
- @key = :since
7
+ @pattern = "since"
8
+ @tagname = :since
9
+ @html_position = POS_SINCE
10
10
  end
11
11
 
12
- def to_value(contents)
13
- if contents.length > 1
12
+ def parse_doc(p)
13
+ {
14
+ :tagname => :since,
15
+ :version => p.match(/.*$/).strip,
16
+ }
17
+ end
18
+
19
+ def process_doc(h, tags, pos)
20
+ if tags.length > 1
14
21
  JsDuck::Logger.warn(nil, "Only one @since tag allowed per class/member.")
15
22
  end
16
- contents[0]
23
+
24
+ h[:since] = tags[0][:version]
17
25
  end
18
26
 
19
- def to_html(version)
27
+ def to_html(context)
20
28
  <<-EOHTML
21
- <p>Available since: <b>#{version}</b></p>
29
+ <p>Available since: <b>#{context[:since]}</b></p>
22
30
  EOHTML
23
31
  end
32
+
24
33
  end
25
34
  end
26
-
@@ -0,0 +1,15 @@
1
+ require "jsduck/tag/boolean_tag"
2
+
3
+ module JsDuck::Tag
4
+ class Singleton < BooleanTag
5
+ def initialize
6
+ @pattern = "singleton"
7
+ @ext_define_pattern = "singleton"
8
+ super
9
+ end
10
+
11
+ def parse_ext_define(cls, ast)
12
+ cls[:singleton] = (ast.to_value == true)
13
+ end
14
+ end
15
+ end
@@ -1,14 +1,12 @@
1
- require "jsduck/meta_tag"
1
+ require "jsduck/tag/boolean_tag"
2
2
 
3
3
  module JsDuck::Tag
4
- # Implementation of @static tag
5
- class Static < JsDuck::MetaTag
4
+ class Static < BooleanTag
6
5
  def initialize
7
- @name = "static"
8
- @key = :static
6
+ @pattern = "static"
9
7
  @signature = {:long => "static", :short => "STA"}
10
- @boolean = true
8
+ @css = ".signature .static { background-color: #484848 }" # Docs text color
9
+ super
11
10
  end
12
11
  end
13
12
  end
14
-
@@ -0,0 +1,23 @@
1
+ require "jsduck/tag/tag"
2
+ require "jsduck/render/subproperties"
3
+
4
+ module JsDuck::Tag
5
+ # There is no @subproperties tag.
6
+ #
7
+ # This tag class exists solely to implement rendering of :properties
8
+ # field which can exist in :cfg, :property or :css_var members.
9
+ class Subproperties < Tag
10
+ def initialize
11
+ @tagname = :properties
12
+ @html_position = POS_SUBPROPERTIES
13
+ end
14
+
15
+ def format(m, formatter)
16
+ m[:properties].each {|p| formatter.format_subproperty(p) }
17
+ end
18
+
19
+ def to_html(m)
20
+ JsDuck::Render::Subproperties.render(m)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,208 @@
1
+ module JsDuck::Tag
2
+ # Base class for all builtin tags.
3
+ class Tag
4
+ # Defines the name of the @tag.
5
+ # The name itself must not contain the "@" sign.
6
+ # For example: "cfg"
7
+ attr_reader :pattern
8
+
9
+ # Called by DocParser when the @tag is reached to do the parsing
10
+ # from that point forward. Gets passed an instance of DocScanner.
11
+ #
12
+ # Can return a hash or array of hashes representing the detected
13
+ # @tag data. Each returned hash must contain the :tagname key,
14
+ # e.g.:
15
+ #
16
+ # {:tagname => :protected, :foo => "blah"}
17
+ #
18
+ # All hashes with the same :tagname will later be combined
19
+ # together and passed on to #process_doc method of this Tag class
20
+ # that has @tagname field set to that tagname.
21
+ #
22
+ # The hash can also contain :doc => :multiline, in which case all
23
+ # the documentation following this tag will get added to the :doc
24
+ # field of the tag and will later be accessible in #process_doc
25
+ # method.
26
+ def parse_doc(p)
27
+ end
28
+
29
+ # Defines the symbol under which the tag data is stored in final
30
+ # member/class hash.
31
+ attr_reader :tagname
32
+
33
+ # Gets called with the resulting class/member hash and array of
34
+ # @tag data that was generated by #parse_doc. Also a hash with
35
+ # position information {:filename, :linenr} is passed in.
36
+ #
37
+ # It can then add a new field to the class/member hash or
38
+ # transform it in any other way desired.
39
+ def process_doc(hash, docs, position)
40
+ end
41
+
42
+ # Defines a class member type and specifies a name and several
43
+ # other settings. For example:
44
+ #
45
+ # {
46
+ # :name => :event,
47
+ # :category => :method_like,
48
+ # :title => "Events",
49
+ # :position => MEMBER_POS_EVENT,
50
+ # # The following are optional
51
+ # :toolbar_title => "Events",
52
+ # :subsections => [
53
+ # {:title => "Static events",
54
+ # :filter => {:static => false},
55
+ # :default => true},
56
+ # {:title => "Instance events",
57
+ # :filter => {:static => true}},
58
+ # ]
59
+ # }
60
+ #
61
+ # The category must be either :property_like or :method_like.
62
+ #
63
+ # Position defines the ordering of member section in final HTML
64
+ # output.
65
+ #
66
+ # Title is shown at the top of each such section and also as a
67
+ # label on Docs app toolbar button unless :toolbar_title is
68
+ # specified.
69
+ #
70
+ # Subsections allows splitting the list of members to several
71
+ # subgroups. For example methods get split into static and
72
+ # instance methods.
73
+ #
74
+ # - The :filter field defines how to filter out the members for
75
+ # this subcategory. :static=>true filters out all members that
76
+ # have a :static field with a truthy value. Conversely,
77
+ # :static=>false filters out members not having a :static field
78
+ # or having it with a falsy value.
79
+ #
80
+ # - Setting :default=>true will hide the subsection title when all
81
+ # the members end up in that subsection. For example when there
82
+ # are only instance methods, the docs will only contain the
83
+ # section title "Methods", as by default one should assume all
84
+ # methods are instance methods if not stated otherwise.
85
+ #
86
+ attr_reader :member_type
87
+
88
+ MEMBER_POS_CFG = 1
89
+ MEMBER_POS_PROPERTY = 2
90
+ MEMBER_POS_METHOD = 3
91
+ MEMBER_POS_EVENT = 4
92
+ MEMBER_POS_CSS_VAR = 5
93
+ MEMBER_POS_CSS_MIXIN = 6
94
+
95
+ # The text to display in member signature. Must be a hash
96
+ # defining the short and long versions of the signature text:
97
+ #
98
+ # {:long => "something", :short => "SOM"}
99
+ #
100
+ # Additionally the hash can contain a :tooltip which is the text
101
+ # to be shown when the signature bubble is hovered over in docs.
102
+ attr_reader :signature
103
+
104
+ # Defines the name of object property in Ext.define()
105
+ # configuration which, when encountered, will cause the
106
+ # #parse_ext_define method to be invoked.
107
+ attr_reader :ext_define_pattern
108
+
109
+ # The default value to use when Ext.define is encountered, but the
110
+ # key in the config object itself is not found.
111
+ # This must be a Hash defining the key and value.
112
+ attr_reader :ext_define_default
113
+
114
+ # Called by Ast class to parse a config in Ext.define().
115
+ # @param {Hash} cls A simple Hash representing a class on which
116
+ # various properties can be set.
117
+ # @param {AstNode} ast Value of the config in Ext.define().
118
+ def parse_ext_define(cls, ast)
119
+ end
120
+
121
+ # In the context of which members or classes invoke the #merge
122
+ # method. This can be either a single tagname like :class,
123
+ # :method, :cfg or an array of these.
124
+ #
125
+ # Additionally a few special symbols can be used to register a
126
+ # merger for a set of member types:
127
+ #
128
+ # - :member - all members.
129
+ # - :method_like - members like :method, :event, :css_mixin
130
+ # - :property_like - members like :cfg, :property, :css_var
131
+ #
132
+ # For example to register a merger for everyting:
133
+ #
134
+ # @merge_context = [:class, :member]
135
+ #
136
+ attr_reader :merge_context
137
+
138
+ # Merges documentation and code hashes into the result hash.
139
+ def merge(hash, docs, code)
140
+ end
141
+
142
+ # The position for outputting the HTML for the tag in final
143
+ # documentation.
144
+ #
145
+ # Must be defined together with #to_html method. Additionally the
146
+ # #format method can be defined to perform rendering of Markdown
147
+ # before #to_html is called.
148
+ #
149
+ # All builtin tags have a position that's defined by one of the
150
+ # constants listed below. For user-defined tags it's recommended
151
+ # to define your position relative to one of the builtin tags.
152
+ # For example if you want your tag to output HTML right after the
153
+ # return value documentation, use something like:
154
+ #
155
+ # @html_position = POS_RETURN + 0.1
156
+ #
157
+ # Later versions of JSDuck might change the actual values of these
158
+ # constants, so don't rely on the concrete values, reference the
159
+ # constants and add/substract fractions smaller than 1 from them.
160
+ #
161
+ attr_accessor :html_position
162
+
163
+ POS_ASIDE = 1
164
+ POS_PRIVATE = 2
165
+ POS_DOC = 3
166
+ POS_DEFAULT = 4
167
+ POS_SINCE = 5
168
+ POS_DEPRECATED = 6
169
+ POS_ENUM = 7
170
+ POS_TEMPLATE = 8
171
+ POS_PREVENTABLE = 9
172
+ POS_PARAM = 10
173
+ POS_SUBPROPERTIES = 11
174
+ POS_RETURN = 12
175
+ POS_THROWS = 13
176
+ POS_OVERRIDES = 14
177
+
178
+ # Called before #to_html to allow rendering of Markdown content.
179
+ # For this an instance of DocFormatter is passed in, on which one
180
+ # can call the #format method to turn Markdown into HTML.
181
+ def format(context, formatter)
182
+ end
183
+
184
+ # Implement #to_html to transform tag data to HTML to be included
185
+ # into documentation.
186
+ #
187
+ # It gets passed the full class/member hash. It should return an
188
+ # HTML string to inject into document.
189
+ def to_html(context)
190
+ end
191
+
192
+ # A string of CSS to add to the builtin CSS of the generated docs.
193
+ # For example, to style a signature label:
194
+ #
195
+ # @css = ".signature .mytag { color: red }"
196
+ #
197
+ attr_reader :css
198
+
199
+ # Returns all descendants of JsDuck::Tag::Tag class.
200
+ def self.descendants
201
+ result = []
202
+ ObjectSpace.each_object(::Class) do |cls|
203
+ result << cls if cls < self
204
+ end
205
+ result
206
+ end
207
+ end
208
+ end
@@ -1,18 +1,24 @@
1
- require "jsduck/meta_tag"
1
+ require "jsduck/tag/boolean_tag"
2
2
 
3
3
  module JsDuck::Tag
4
- # Implementation of @template tag
5
- class Template < JsDuck::MetaTag
4
+ class Template < BooleanTag
6
5
  def initialize
7
- @name = "template"
8
- @key = :template
6
+ @pattern = "template"
9
7
  @signature = {:long => "template", :short => "TMP"}
10
- @boolean = true
8
+ @html_position = POS_TEMPLATE
9
+ # Box with light gray background
10
+ @css = <<-EOCSS
11
+ .template-box {
12
+ text-align: center;
13
+ background-color: #eee;
14
+ }
15
+ EOCSS
16
+ super
11
17
  end
12
18
 
13
- def to_html(contents)
19
+ def to_html(context)
14
20
  <<-EOHTML
15
- <div class='signature-box template'>
21
+ <div class='rounded-box template-box'>
16
22
  <p>This is a <a href="#!/guide/components">template method</a>.
17
23
  a hook into the functionality of this class.
18
24
  Feel free to override it in child classes.</p>
@@ -21,4 +27,3 @@ module JsDuck::Tag
21
27
  end
22
28
  end
23
29
  end
24
-
@@ -0,0 +1,38 @@
1
+ require "jsduck/tag/tag"
2
+ require "jsduck/render/subproperties"
3
+
4
+ module JsDuck::Tag
5
+ class Throws < Tag
6
+ def initialize
7
+ @pattern = "throws"
8
+ @tagname = :throws
9
+ @html_position = POS_THROWS
10
+ end
11
+
12
+ # @throws {Type} ...
13
+ def parse_doc(p)
14
+ tag = p.standard_tag({:tagname => :throws, :type => true})
15
+ tag[:doc] = :multiline
16
+ tag
17
+ end
18
+
19
+ def process_doc(h, tags, pos)
20
+ result = tags.map do |throws|
21
+ {
22
+ :type => throws[:type] || "Object",
23
+ :doc => throws[:doc] || "",
24
+ }
25
+ end
26
+
27
+ h[:throws] = result
28
+ end
29
+
30
+ def format(m, formatter)
31
+ m[:throws].each {|t| formatter.format_subproperty(t) }
32
+ end
33
+
34
+ def to_html(m)
35
+ JsDuck::Render::Subproperties.render_throws(m[:throws])
36
+ end
37
+ end
38
+ end