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.
- data/.travis.yml +0 -1
- data/README.md +32 -6
- data/Rakefile +10 -18
- data/bin/compare +5 -5
- data/bin/jsduck +2 -3
- data/jsduck.gemspec +3 -4
- data/lib/jsduck/aggregator.rb +21 -80
- data/lib/jsduck/app.rb +7 -14
- data/lib/jsduck/app_data.rb +4 -5
- data/lib/jsduck/assets.rb +4 -7
- data/lib/jsduck/base_type.rb +53 -0
- data/lib/jsduck/batch_parser.rb +8 -87
- data/lib/jsduck/batch_processor.rb +77 -0
- data/lib/jsduck/categories/auto.rb +83 -0
- data/lib/jsduck/categories/class_name.rb +63 -0
- data/lib/jsduck/categories/factory.rb +113 -0
- data/lib/jsduck/categories/file.rb +75 -0
- data/lib/jsduck/class.rb +3 -9
- data/lib/jsduck/class_doc_expander.rb +1 -1
- data/lib/jsduck/css/lexer.rb +203 -0
- data/lib/jsduck/css/parser.rb +121 -0
- data/lib/jsduck/doc/comment.rb +40 -0
- data/lib/jsduck/doc/map.rb +23 -0
- data/lib/jsduck/doc/parser.rb +128 -0
- data/lib/jsduck/doc/processor.rb +52 -0
- data/lib/jsduck/doc/scanner.rb +76 -0
- data/lib/jsduck/doc/standard_tag_parser.rb +154 -0
- data/lib/jsduck/doc/subproperties.rb +64 -0
- data/lib/jsduck/docs_code_comparer.rb +31 -0
- data/lib/jsduck/export_writer.rb +2 -2
- data/lib/jsduck/exporter/app.rb +16 -4
- data/lib/jsduck/exporter/full.rb +2 -2
- data/lib/jsduck/format/batch.rb +58 -0
- data/lib/jsduck/format/class.rb +62 -0
- data/lib/jsduck/format/doc.rb +172 -0
- data/lib/jsduck/format/html_stack.rb +109 -0
- data/lib/jsduck/format/shortener.rb +55 -0
- data/lib/jsduck/format/subproperties.rb +64 -0
- data/lib/jsduck/guides.rb +32 -14
- data/lib/jsduck/index_html.rb +3 -1
- data/lib/jsduck/inline/auto_link.rb +2 -2
- data/lib/jsduck/inline/link.rb +4 -3
- data/lib/jsduck/inline/link_renderer.rb +2 -2
- data/lib/jsduck/inline/video.rb +8 -2
- data/lib/jsduck/js/ast.rb +361 -0
- data/lib/jsduck/js/esprima.rb +39 -0
- data/lib/jsduck/{esprima → js/esprima}/esprima.js +0 -0
- data/lib/jsduck/js/evaluator.rb +70 -0
- data/lib/jsduck/js/ext_patterns.rb +70 -0
- data/lib/jsduck/js/function.rb +206 -0
- data/lib/jsduck/js/node.rb +194 -0
- data/lib/jsduck/js/node_array.rb +36 -0
- data/lib/jsduck/js/parser.rb +223 -0
- data/lib/jsduck/js/serializer.rb +263 -0
- data/lib/jsduck/js/utils.rb +21 -0
- data/lib/jsduck/logger.rb +3 -13
- data/lib/jsduck/members_index.rb +3 -4
- data/lib/jsduck/merger.rb +25 -145
- data/lib/jsduck/options.rb +29 -132
- data/lib/jsduck/parser.rb +76 -0
- data/lib/jsduck/process/accessors.rb +133 -0
- data/lib/jsduck/process/circular_deps.rb +58 -0
- data/lib/jsduck/process/enums.rb +91 -0
- data/lib/jsduck/process/ext4_events.rb +43 -0
- data/lib/jsduck/process/global_members.rb +36 -0
- data/lib/jsduck/process/ignored_classes.rb +16 -0
- data/lib/jsduck/process/importer.rb +58 -0
- data/lib/jsduck/process/inherit_doc.rb +197 -0
- data/lib/jsduck/process/lint.rb +135 -0
- data/lib/jsduck/process/overrides.rb +99 -0
- data/lib/jsduck/process/return_values.rb +72 -0
- data/lib/jsduck/process/versions.rb +102 -0
- data/lib/jsduck/relations.rb +5 -0
- data/lib/jsduck/render/class.rb +144 -0
- data/lib/jsduck/render/sidebar.rb +97 -0
- data/lib/jsduck/render/signature.rb +94 -0
- data/lib/jsduck/render/subproperties.rb +99 -0
- data/lib/jsduck/render/tags.rb +38 -0
- data/lib/jsduck/search_data.rb +19 -13
- data/lib/jsduck/source/file.rb +8 -17
- data/lib/jsduck/tag/abstract.rb +4 -7
- data/lib/jsduck/tag/accessor.rb +10 -0
- data/lib/jsduck/tag/alias.rb +61 -0
- data/lib/jsduck/tag/alternate_class_names.rb +17 -0
- data/lib/jsduck/tag/aside.rb +28 -31
- data/lib/jsduck/tag/author.rb +9 -5
- data/lib/jsduck/tag/boolean_tag.rb +24 -0
- data/lib/jsduck/tag/cfg.rb +45 -0
- data/lib/jsduck/tag/chainable.rb +5 -7
- data/lib/jsduck/tag/class.rb +28 -0
- data/lib/jsduck/tag/class_list_tag.rb +40 -0
- data/lib/jsduck/tag/constructor.rb +24 -0
- data/lib/jsduck/tag/css_mixin.rb +17 -0
- data/lib/jsduck/tag/css_var.rb +29 -0
- data/lib/jsduck/tag/default.rb +31 -0
- data/lib/jsduck/tag/deprecated.rb +13 -27
- data/lib/jsduck/tag/deprecated_tag.rb +58 -0
- data/lib/jsduck/tag/doc.rb +32 -0
- data/lib/jsduck/tag/docauthor.rb +4 -5
- data/lib/jsduck/tag/enum.rb +70 -0
- data/lib/jsduck/tag/event.rb +28 -0
- data/lib/jsduck/tag/evented.rb +10 -0
- data/lib/jsduck/tag/extends.rb +45 -0
- data/lib/jsduck/tag/ftype.rb +18 -0
- data/lib/jsduck/tag/hide.rb +4 -11
- data/lib/jsduck/tag/ignore.rb +6 -7
- data/lib/jsduck/tag/inheritable.rb +10 -0
- data/lib/jsduck/tag/inheritdoc.rb +48 -0
- data/lib/jsduck/tag/markdown.rb +8 -6
- data/lib/jsduck/tag/member.rb +24 -0
- data/lib/jsduck/tag/method.rb +35 -0
- data/lib/jsduck/tag/mixins.rb +26 -0
- data/lib/jsduck/tag/name.rb +36 -0
- data/lib/jsduck/tag/new.rb +13 -27
- data/lib/jsduck/tag/override.rb +37 -0
- data/lib/jsduck/tag/overrides.rb +29 -0
- data/lib/jsduck/tag/param.rb +87 -0
- data/lib/jsduck/tag/preventable.rb +19 -10
- data/lib/jsduck/tag/private.rb +28 -13
- data/lib/jsduck/tag/property.rb +39 -0
- data/lib/jsduck/tag/protected.rb +5 -7
- data/lib/jsduck/tag/ptype.rb +18 -0
- data/lib/jsduck/tag/readonly.rb +4 -7
- data/lib/jsduck/tag/removed.rb +21 -29
- data/lib/jsduck/tag/required.rb +11 -9
- data/lib/jsduck/tag/requires.rb +12 -0
- data/lib/jsduck/tag/return.rb +47 -0
- data/lib/jsduck/tag/since.rb +19 -11
- data/lib/jsduck/tag/singleton.rb +15 -0
- data/lib/jsduck/tag/static.rb +5 -7
- data/lib/jsduck/tag/subproperties.rb +23 -0
- data/lib/jsduck/tag/tag.rb +208 -0
- data/lib/jsduck/tag/template.rb +14 -9
- data/lib/jsduck/tag/throws.rb +38 -0
- data/lib/jsduck/tag/type.rb +48 -0
- data/lib/jsduck/tag/uses.rb +12 -0
- data/lib/jsduck/tag/xtype.rb +30 -0
- data/lib/jsduck/tag_loader.rb +39 -0
- data/lib/jsduck/tag_registry.rb +189 -0
- data/lib/jsduck/type_parser.rb +3 -3
- data/lib/jsduck/web_writer.rb +2 -2
- data/lib/jsduck/welcome.rb +1 -1
- metadata +578 -538
- data/lib/jsduck/accessors.rb +0 -136
- data/lib/jsduck/ast.rb +0 -524
- data/lib/jsduck/auto_categories.rb +0 -80
- data/lib/jsduck/batch_formatter.rb +0 -60
- data/lib/jsduck/categories.rb +0 -73
- data/lib/jsduck/categories_class_name.rb +0 -37
- data/lib/jsduck/circular_deps.rb +0 -56
- data/lib/jsduck/class_formatter.rb +0 -102
- data/lib/jsduck/columns.rb +0 -56
- data/lib/jsduck/css_lexer.rb +0 -201
- data/lib/jsduck/css_parser.rb +0 -119
- data/lib/jsduck/doc_ast.rb +0 -319
- data/lib/jsduck/doc_formatter.rb +0 -142
- data/lib/jsduck/doc_parser.rb +0 -611
- data/lib/jsduck/doc_type.rb +0 -59
- data/lib/jsduck/enum.rb +0 -73
- data/lib/jsduck/esprima.rb +0 -51
- data/lib/jsduck/evaluator.rb +0 -69
- data/lib/jsduck/ext_patterns.rb +0 -58
- data/lib/jsduck/file_categories.rb +0 -76
- data/lib/jsduck/function_ast.rb +0 -206
- data/lib/jsduck/guide_anchors.rb +0 -32
- data/lib/jsduck/guide_toc.rb +0 -49
- data/lib/jsduck/html_stack.rb +0 -105
- data/lib/jsduck/importer.rb +0 -121
- data/lib/jsduck/inherit_doc.rb +0 -193
- data/lib/jsduck/js_parser.rb +0 -221
- data/lib/jsduck/lint.rb +0 -133
- data/lib/jsduck/meta_tag.rb +0 -88
- data/lib/jsduck/meta_tag_loader.rb +0 -67
- data/lib/jsduck/meta_tag_registry.rb +0 -111
- data/lib/jsduck/meta_tag_renderer.rb +0 -34
- data/lib/jsduck/news.rb +0 -128
- data/lib/jsduck/override.rb +0 -87
- data/lib/jsduck/renderer.rb +0 -361
- data/lib/jsduck/return_values.rb +0 -72
- data/lib/jsduck/serializer.rb +0 -262
- data/lib/jsduck/shortener.rb +0 -58
- data/lib/jsduck/signature_renderer.rb +0 -91
- data/lib/jsduck/source/file_parser.rb +0 -72
@@ -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
|
data/lib/jsduck/tag/since.rb
CHANGED
@@ -1,26 +1,34 @@
|
|
1
|
-
require "jsduck/
|
1
|
+
require "jsduck/tag/tag"
|
2
2
|
require "jsduck/logger"
|
3
3
|
|
4
4
|
module JsDuck::Tag
|
5
|
-
|
6
|
-
class Since < JsDuck::MetaTag
|
5
|
+
class Since < Tag
|
7
6
|
def initialize
|
8
|
-
@
|
9
|
-
@
|
7
|
+
@pattern = "since"
|
8
|
+
@tagname = :since
|
9
|
+
@html_position = POS_SINCE
|
10
10
|
end
|
11
11
|
|
12
|
-
def
|
13
|
-
|
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
|
-
|
23
|
+
|
24
|
+
h[:since] = tags[0][:version]
|
17
25
|
end
|
18
26
|
|
19
|
-
def to_html(
|
27
|
+
def to_html(context)
|
20
28
|
<<-EOHTML
|
21
|
-
<p>Available since: <b>#{
|
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
|
data/lib/jsduck/tag/static.rb
CHANGED
@@ -1,14 +1,12 @@
|
|
1
|
-
require "jsduck/
|
1
|
+
require "jsduck/tag/boolean_tag"
|
2
2
|
|
3
3
|
module JsDuck::Tag
|
4
|
-
|
5
|
-
class Static < JsDuck::MetaTag
|
4
|
+
class Static < BooleanTag
|
6
5
|
def initialize
|
7
|
-
@
|
8
|
-
@key = :static
|
6
|
+
@pattern = "static"
|
9
7
|
@signature = {:long => "static", :short => "STA"}
|
10
|
-
@
|
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
|
data/lib/jsduck/tag/template.rb
CHANGED
@@ -1,18 +1,24 @@
|
|
1
|
-
require "jsduck/
|
1
|
+
require "jsduck/tag/boolean_tag"
|
2
2
|
|
3
3
|
module JsDuck::Tag
|
4
|
-
|
5
|
-
class Template < JsDuck::MetaTag
|
4
|
+
class Template < BooleanTag
|
6
5
|
def initialize
|
7
|
-
@
|
8
|
-
@key = :template
|
6
|
+
@pattern = "template"
|
9
7
|
@signature = {:long => "template", :short => "TMP"}
|
10
|
-
@
|
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(
|
19
|
+
def to_html(context)
|
14
20
|
<<-EOHTML
|
15
|
-
<div class='
|
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
|