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,70 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
|
3
|
+
module JsDuck::Tag
|
4
|
+
class Enum < Tag
|
5
|
+
def initialize
|
6
|
+
@pattern = "enum"
|
7
|
+
@tagname = :enum
|
8
|
+
@merge_context = :class
|
9
|
+
@html_position = POS_ENUM
|
10
|
+
# Green box
|
11
|
+
@css = <<-EOCSS
|
12
|
+
.enum-box {
|
13
|
+
color: #060;
|
14
|
+
background-color: #efe;
|
15
|
+
text-align: center;
|
16
|
+
}
|
17
|
+
EOCSS
|
18
|
+
end
|
19
|
+
|
20
|
+
# @enum {Type} [name=default] ...
|
21
|
+
def parse_doc(p)
|
22
|
+
enum = p.standard_tag({:tagname => :enum, :type => true, :name => true})
|
23
|
+
|
24
|
+
# @enum is a special case of class, so we also generate a class
|
25
|
+
# tag with the same name as given for @enum.
|
26
|
+
cls = {:tagname => :class, :name => enum[:name]}
|
27
|
+
|
28
|
+
return [cls, enum]
|
29
|
+
end
|
30
|
+
|
31
|
+
def process_doc(h, tags, pos)
|
32
|
+
h[:enum] = {
|
33
|
+
:type => tags[0][:type],
|
34
|
+
:default => tags[0][:default],
|
35
|
+
:doc_only => !!tags[0][:default],
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Takes the :enum always from docs, but the :doc_only can come
|
40
|
+
# from either code or docs.
|
41
|
+
def merge(h, docs, code)
|
42
|
+
return unless docs[:enum]
|
43
|
+
h[:enum] = docs[:enum]
|
44
|
+
h[:enum][:doc_only] = docs[:enum][:doc_only] || (code[:enum] && code[:enum][:doc_only])
|
45
|
+
end
|
46
|
+
|
47
|
+
def to_html(cls)
|
48
|
+
if cls[:enum][:doc_only]
|
49
|
+
first = cls[:members][:property][0] || {:name => 'foo', :default => '"foo"'}
|
50
|
+
[
|
51
|
+
"<div class='rounded-box enum-box'>",
|
52
|
+
"<p><strong>ENUM:</strong> ",
|
53
|
+
"This enumeration defines a set of String values. ",
|
54
|
+
"It exists primarily for documentation purposes - ",
|
55
|
+
"in code use the actual string values like #{first[:default]}, ",
|
56
|
+
"don't reference them through this class like #{cls[:name]}.#{first[:name]}.</p>",
|
57
|
+
"</div>",
|
58
|
+
]
|
59
|
+
else
|
60
|
+
[
|
61
|
+
"<div class='rounded-box enum-box'>",
|
62
|
+
"<p><strong>ENUM:</strong> ",
|
63
|
+
"This enumeration defines a set of #{cls[:enum][:type]} values.</p>",
|
64
|
+
"</div>",
|
65
|
+
]
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
|
3
|
+
module JsDuck::Tag
|
4
|
+
class Event < Tag
|
5
|
+
def initialize
|
6
|
+
@pattern = "event"
|
7
|
+
@tagname = :event
|
8
|
+
@member_type = {
|
9
|
+
:name => :event,
|
10
|
+
:category => :method_like,
|
11
|
+
:title => "Events",
|
12
|
+
:position => MEMBER_POS_EVENT,
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
16
|
+
# @event name ...
|
17
|
+
def parse_doc(p)
|
18
|
+
{
|
19
|
+
:tagname => :event,
|
20
|
+
:name => p.ident,
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
def process_doc(h, tags, pos)
|
25
|
+
h[:name] = tags[0][:name]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
require "jsduck/js/utils"
|
3
|
+
|
4
|
+
module JsDuck::Tag
|
5
|
+
class Extends < Tag
|
6
|
+
def initialize
|
7
|
+
@pattern = ["extend", "extends"]
|
8
|
+
@tagname = :extends
|
9
|
+
@ext_define_pattern = "extend"
|
10
|
+
@ext_define_default = {:extends => "Ext.Base"}
|
11
|
+
@merge_context = :class
|
12
|
+
end
|
13
|
+
|
14
|
+
# @extends classname
|
15
|
+
# or
|
16
|
+
# @extends {classname}
|
17
|
+
def parse_doc(p)
|
18
|
+
if p.match(/\{/)
|
19
|
+
cls = p.ident_chain
|
20
|
+
p.match(/\}/)
|
21
|
+
else
|
22
|
+
cls = p.ident_chain
|
23
|
+
end
|
24
|
+
|
25
|
+
{
|
26
|
+
:tagname => :extends,
|
27
|
+
:extends => cls,
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def process_doc(h, tags, pos)
|
32
|
+
h[:extends] = tags[0][:extends]
|
33
|
+
end
|
34
|
+
|
35
|
+
def parse_ext_define(cls, ast)
|
36
|
+
cls[:extends] = JsDuck::Js::Utils.make_string(ast)
|
37
|
+
end
|
38
|
+
|
39
|
+
# Ignore extending of the Object class
|
40
|
+
def merge(h, docs, code)
|
41
|
+
h[:extends] = docs[:extends] || code[:extends]
|
42
|
+
h[:extends] = nil if h[:extends] == "Object"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require "jsduck/tag/xtype"
|
2
|
+
|
3
|
+
module JsDuck::Tag
|
4
|
+
class Ftype < Xtype
|
5
|
+
def initialize
|
6
|
+
@pattern = "ftype"
|
7
|
+
end
|
8
|
+
|
9
|
+
# @ftype name
|
10
|
+
def parse_doc(p)
|
11
|
+
{
|
12
|
+
:tagname => :aliases,
|
13
|
+
:name => parse_alias_shorthand(p, "feature")
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
data/lib/jsduck/tag/hide.rb
CHANGED
@@ -1,18 +1,11 @@
|
|
1
|
-
require "jsduck/
|
1
|
+
require "jsduck/tag/boolean_tag"
|
2
2
|
|
3
3
|
module JsDuck::Tag
|
4
|
-
# Implementation of @hide tag.
|
5
|
-
#
|
6
4
|
# Hides a member in parent class.
|
7
|
-
|
8
|
-
# The core of the implementation is built into jsduck.
|
9
|
-
#
|
10
|
-
class Hide < JsDuck::MetaTag
|
5
|
+
class Hide < BooleanTag
|
11
6
|
def initialize
|
12
|
-
@
|
13
|
-
|
14
|
-
@boolean = true
|
7
|
+
@pattern = "hide"
|
8
|
+
super
|
15
9
|
end
|
16
10
|
end
|
17
11
|
end
|
18
|
-
|
data/lib/jsduck/tag/ignore.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
|
-
require "jsduck/
|
1
|
+
require "jsduck/tag/boolean_tag"
|
2
2
|
|
3
3
|
module JsDuck::Tag
|
4
|
-
#
|
5
|
-
|
4
|
+
# Causes a member or entire class documentation to be completely
|
5
|
+
# excluded from docs.
|
6
|
+
class Ignore < BooleanTag
|
6
7
|
def initialize
|
7
|
-
@
|
8
|
-
|
9
|
-
@boolean = true
|
8
|
+
@pattern = "ignore"
|
9
|
+
super
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
13
|
-
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
require "jsduck/tag_registry"
|
3
|
+
|
4
|
+
module JsDuck::Tag
|
5
|
+
class Inheritdoc < Tag
|
6
|
+
def initialize
|
7
|
+
@pattern = ["inheritdoc", "inheritDoc"]
|
8
|
+
@tagname = :inheritdoc
|
9
|
+
end
|
10
|
+
|
11
|
+
# @inheritdoc class.name#static-type-member
|
12
|
+
def parse_doc(p)
|
13
|
+
parse_as_inheritdoc(p)
|
14
|
+
end
|
15
|
+
|
16
|
+
# This separate method exits to allow it to be also called from
|
17
|
+
# @alias tag implementation.
|
18
|
+
#
|
19
|
+
# Matches a member reference: <class.name> "#" <static> "-" <type> "-" <member>
|
20
|
+
#
|
21
|
+
# Returns :inheritdoc tag definition with corresponding fields.
|
22
|
+
def parse_as_inheritdoc(p)
|
23
|
+
tag = {
|
24
|
+
:tagname => :inheritdoc,
|
25
|
+
:cls => p.ident_chain,
|
26
|
+
}
|
27
|
+
|
28
|
+
if p.look(/#\w/)
|
29
|
+
p.match(/#/)
|
30
|
+
if p.look(/static-/)
|
31
|
+
tag[:static] = true
|
32
|
+
p.match(/static-/)
|
33
|
+
end
|
34
|
+
if p.look(JsDuck::TagRegistry.member_type_regex)
|
35
|
+
tag[:type] = p.match(/\w+/).to_sym
|
36
|
+
p.match(/-/)
|
37
|
+
end
|
38
|
+
tag[:member] = p.ident
|
39
|
+
end
|
40
|
+
|
41
|
+
tag
|
42
|
+
end
|
43
|
+
|
44
|
+
def process_doc(h, docs, pos)
|
45
|
+
h[:inheritdoc] = docs.first
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
data/lib/jsduck/tag/markdown.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
require "jsduck/
|
1
|
+
require "jsduck/tag/tag"
|
2
2
|
|
3
3
|
module JsDuck::Tag
|
4
|
-
|
5
|
-
class Markdown < JsDuck::MetaTag
|
4
|
+
class Markdown < Tag
|
6
5
|
def initialize
|
7
|
-
@
|
8
|
-
|
6
|
+
@pattern = "markdown"
|
7
|
+
end
|
8
|
+
|
9
|
+
# @markdown
|
10
|
+
def parse_doc(p)
|
11
|
+
# Just completely ignore this tag.
|
9
12
|
end
|
10
13
|
end
|
11
14
|
end
|
12
|
-
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
|
3
|
+
module JsDuck::Tag
|
4
|
+
class Member < Tag
|
5
|
+
# This is an odd case where tag itself is @member, but the value
|
6
|
+
# of it gets stored in :owner.
|
7
|
+
def initialize
|
8
|
+
@pattern = "member"
|
9
|
+
@tagname = :owner
|
10
|
+
end
|
11
|
+
|
12
|
+
# @member classname
|
13
|
+
def parse_doc(p)
|
14
|
+
{
|
15
|
+
:tagname => :owner,
|
16
|
+
:owner => p.ident_chain,
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def process_doc(h, tags, pos)
|
21
|
+
h[:owner] = tags[0][:owner]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
|
3
|
+
module JsDuck::Tag
|
4
|
+
# Implementation of @method tag.
|
5
|
+
class Method < Tag
|
6
|
+
def initialize
|
7
|
+
@pattern = "method"
|
8
|
+
@tagname = :method
|
9
|
+
@member_type = {
|
10
|
+
:name => :method,
|
11
|
+
:category => :method_like,
|
12
|
+
:title => "Methods",
|
13
|
+
:position => MEMBER_POS_METHOD,
|
14
|
+
:subsections => [
|
15
|
+
{:title => "Instance methods", :filter => {:static => false}, :default => true},
|
16
|
+
{:title => "Static methods", :filter => {:static => true}},
|
17
|
+
]
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
# @method name ...
|
22
|
+
def parse_doc(p)
|
23
|
+
{
|
24
|
+
:tagname => :method,
|
25
|
+
:name => p.ident,
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
# Onle sets the name when it's actually specified.
|
30
|
+
# Otherwise we might overwrite name coming from @constructor.
|
31
|
+
def process_doc(h, tags, pos)
|
32
|
+
h[:name] = tags[0][:name] if tags[0][:name]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "jsduck/tag/class_list_tag"
|
2
|
+
|
3
|
+
module JsDuck::Tag
|
4
|
+
class Mixins < ClassListTag
|
5
|
+
def initialize
|
6
|
+
@pattern = ["mixin", "mixins"]
|
7
|
+
@tagname = :mixins
|
8
|
+
@ext_define_pattern = "mixins"
|
9
|
+
@ext_define_default = {:mixins => []}
|
10
|
+
end
|
11
|
+
|
12
|
+
# Override definition in parent class. In addition to Array
|
13
|
+
# literal, mixins can be defined with an object literal.
|
14
|
+
def parse_ext_define(cls, ast)
|
15
|
+
cls[:mixins] = to_mixins_array(ast)
|
16
|
+
end
|
17
|
+
|
18
|
+
# converts AstNode, whether it's a string, array or hash into
|
19
|
+
# array of strings (when possible).
|
20
|
+
def to_mixins_array(ast)
|
21
|
+
v = ast.to_value
|
22
|
+
mixins = v.is_a?(Hash) ? v.values : Array(v)
|
23
|
+
mixins.all? {|mx| mx.is_a? String } ? mixins : []
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
|
3
|
+
module JsDuck::Tag
|
4
|
+
# There is no @name tag.
|
5
|
+
#
|
6
|
+
# The :name field is generated by several tags like @class, @method,
|
7
|
+
# @cfg, ...
|
8
|
+
#
|
9
|
+
# This class exists to take care of the merging of :name field.
|
10
|
+
class Name < Tag
|
11
|
+
def initialize
|
12
|
+
@merge_context = [:class, :member]
|
13
|
+
end
|
14
|
+
|
15
|
+
# When docs contains :name, it's taken from there.
|
16
|
+
#
|
17
|
+
# When code contains :name, we only take the full name when
|
18
|
+
# dealing with a class, otherwise we just take the last part of
|
19
|
+
# the dot.separate.name.
|
20
|
+
#
|
21
|
+
# :name defaults to empty string.
|
22
|
+
def merge(h, docs, code)
|
23
|
+
if docs[:name]
|
24
|
+
h[:name] = docs[:name]
|
25
|
+
elsif code[:name]
|
26
|
+
if h[:tagname] == :class
|
27
|
+
h[:name] = code[:name]
|
28
|
+
else
|
29
|
+
h[:name] = code[:name].split(/\./).last
|
30
|
+
end
|
31
|
+
else
|
32
|
+
h[:name] = ""
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/jsduck/tag/new.rb
CHANGED
@@ -1,33 +1,19 @@
|
|
1
|
-
require "jsduck/
|
2
|
-
require "jsduck/logger"
|
1
|
+
require "jsduck/tag/boolean_tag"
|
3
2
|
|
4
3
|
module JsDuck::Tag
|
5
|
-
|
6
|
-
class New < JsDuck::MetaTag
|
4
|
+
class New < BooleanTag
|
7
5
|
def initialize
|
8
|
-
@
|
9
|
-
|
10
|
-
@signature = {:long => "★", :short => "★"}
|
11
|
-
|
6
|
+
@pattern = "new"
|
7
|
+
# A :tooltip field gets injected to this signature in Process::Versions
|
8
|
+
@signature = {:long => "★", :short => "★"}
|
9
|
+
# black (docs text color) unicode star on yellow background
|
10
|
+
@css = <<-EOCSS
|
11
|
+
.signature .new {
|
12
|
+
color: #484848;
|
13
|
+
background-color: #F5D833;
|
14
|
+
}
|
15
|
+
EOCSS
|
16
|
+
super
|
12
17
|
end
|
13
|
-
|
14
|
-
# Initializes the tooltip text.
|
15
|
-
#
|
16
|
-
# HACK: This is a special method that's only called for the @new
|
17
|
-
# tag. It doesn't fit well into the current meta-tags system. But
|
18
|
-
# until we rework the meta-tags system, this will have to do.
|
19
|
-
def create_tooltip!(imports, new_since)
|
20
|
-
if new_since
|
21
|
-
@signature[:tooltip] = "New since #{new_since}"
|
22
|
-
elsif imports.length > 0
|
23
|
-
@signature[:tooltip] = "New since #{imports.last[:version]}"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def to_value(contents)
|
28
|
-
true
|
29
|
-
end
|
30
|
-
|
31
18
|
end
|
32
19
|
end
|
33
|
-
|