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
data/lib/jsduck/tag/author.rb
CHANGED
@@ -1,11 +1,15 @@
|
|
1
|
-
require "jsduck/
|
1
|
+
require "jsduck/tag/tag"
|
2
2
|
|
3
3
|
module JsDuck::Tag
|
4
|
-
|
5
|
-
class Author < JsDuck::MetaTag
|
4
|
+
class Author < Tag
|
6
5
|
def initialize
|
7
|
-
@
|
6
|
+
@pattern = "author"
|
7
|
+
end
|
8
|
+
|
9
|
+
# @author Name of Author <email@example.com> ...
|
10
|
+
# Everything until the end of line gets just ignored.
|
11
|
+
def parse_doc(p)
|
12
|
+
p.match(/.*$/)
|
8
13
|
end
|
9
14
|
end
|
10
15
|
end
|
11
|
-
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
|
3
|
+
module JsDuck::Tag
|
4
|
+
# Base class for simple boolean @tags.
|
5
|
+
# Subclasses should only define @pattern and call #super,
|
6
|
+
# which will take care of setting up @tagname with the same name.
|
7
|
+
class BooleanTag < Tag
|
8
|
+
def initialize
|
9
|
+
if @pattern
|
10
|
+
@tagname = @pattern.to_sym
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Parses just the name of the tag.
|
15
|
+
def parse_doc(p)
|
16
|
+
{:tagname => @tagname}
|
17
|
+
end
|
18
|
+
|
19
|
+
# When the tag is found, its value will always be true.
|
20
|
+
def process_doc(h, docs, pos)
|
21
|
+
h[@tagname] = true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
require "jsduck/doc/subproperties"
|
3
|
+
|
4
|
+
module JsDuck::Tag
|
5
|
+
class Cfg < Tag
|
6
|
+
def initialize
|
7
|
+
@pattern = "cfg"
|
8
|
+
@tagname = :cfg
|
9
|
+
@member_type = {
|
10
|
+
:name => :cfg,
|
11
|
+
:category => :property_like,
|
12
|
+
:title => "Config options",
|
13
|
+
:toolbar_title => "Configs",
|
14
|
+
:position => MEMBER_POS_CFG,
|
15
|
+
:subsections => [
|
16
|
+
{:title => "Required config options", :filter => {:required => true}},
|
17
|
+
{:title => "Optional config options", :filter => {:required => false}, :default => true},
|
18
|
+
]
|
19
|
+
}
|
20
|
+
end
|
21
|
+
|
22
|
+
# @cfg {Type} [name=default] (required) ...
|
23
|
+
def parse_doc(p)
|
24
|
+
tag = p.standard_tag({:tagname => :cfg, :type => true, :name => true})
|
25
|
+
tag[:optional] = false if parse_required(p)
|
26
|
+
tag[:doc] = :multiline
|
27
|
+
tag
|
28
|
+
end
|
29
|
+
|
30
|
+
def parse_required(p)
|
31
|
+
p.hw.match(/\(required\)/i)
|
32
|
+
end
|
33
|
+
|
34
|
+
def process_doc(h, tags, pos)
|
35
|
+
p = tags[0]
|
36
|
+
h[:name] = p[:name]
|
37
|
+
h[:type] = p[:type]
|
38
|
+
h[:default] = p[:default]
|
39
|
+
h[:properties] = JsDuck::Doc::Subproperties.nest(tags, pos)[0][:properties]
|
40
|
+
h[:required] = true if p[:optional] == false
|
41
|
+
# Documentation after the first @cfg is part of the top-level docs.
|
42
|
+
h[:doc] += p[:doc]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/jsduck/tag/chainable.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 Chainable < JsDuck::MetaTag
|
4
|
+
class Chainable < BooleanTag
|
6
5
|
def initialize
|
7
|
-
@
|
8
|
-
@key = :chainable
|
6
|
+
@pattern = "chainable"
|
9
7
|
@signature = {:long => "chainable", :short => ">"} # show small right-arrow
|
10
|
-
@
|
8
|
+
@css = ".signature .chainable { background-color: #00aa00 }" # green
|
9
|
+
super
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
14
|
-
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
|
3
|
+
module JsDuck::Tag
|
4
|
+
class Class < Tag
|
5
|
+
def initialize
|
6
|
+
@pattern = "class"
|
7
|
+
@tagname = :class
|
8
|
+
@merge_context = :class
|
9
|
+
end
|
10
|
+
|
11
|
+
# @class name
|
12
|
+
def parse_doc(p)
|
13
|
+
{
|
14
|
+
:tagname => :class,
|
15
|
+
:name => p.ident_chain,
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
def process_doc(h, tags, pos)
|
20
|
+
h[:name] = tags[0][:name]
|
21
|
+
end
|
22
|
+
|
23
|
+
# Ensure the empty members array.
|
24
|
+
def merge(h, docs, code)
|
25
|
+
h[:members] = []
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
require "jsduck/js/utils"
|
3
|
+
|
4
|
+
module JsDuck::Tag
|
5
|
+
# Base class for tags like @mixins, @uses, etc
|
6
|
+
# Which take the following form:
|
7
|
+
#
|
8
|
+
# @tagname classname1 classname2 ...
|
9
|
+
#
|
10
|
+
# Subclasses need to define the @patterns and @tagname fields for
|
11
|
+
# the #parse_doc and #process_doc methods to work. Plus
|
12
|
+
# @ext_define_pattern and @ext_define_default for the
|
13
|
+
# #parse_ext_define to work.
|
14
|
+
#
|
15
|
+
class ClassListTag < Tag
|
16
|
+
def parse_doc(p)
|
17
|
+
{
|
18
|
+
:tagname => @tagname,
|
19
|
+
:classes => classname_list(p),
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
23
|
+
# matches <ident_chain> <ident_chain> ... until line end
|
24
|
+
def classname_list(p)
|
25
|
+
classes = []
|
26
|
+
while cls = p.hw.ident_chain
|
27
|
+
classes << cls
|
28
|
+
end
|
29
|
+
classes
|
30
|
+
end
|
31
|
+
|
32
|
+
def process_doc(h, tags, pos)
|
33
|
+
h[@tagname] = tags.map {|d| d[:classes] }.flatten
|
34
|
+
end
|
35
|
+
|
36
|
+
def parse_ext_define(cls, ast)
|
37
|
+
cls[@tagname] = JsDuck::Js::Utils.make_string_list(ast)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
|
3
|
+
module JsDuck::Tag
|
4
|
+
class Constructor < Tag
|
5
|
+
def initialize
|
6
|
+
@pattern = "constructor"
|
7
|
+
@tagname = :constructor
|
8
|
+
end
|
9
|
+
|
10
|
+
# @constructor
|
11
|
+
def parse_doc(p)
|
12
|
+
{:tagname => :constructor, :doc => :multiline}
|
13
|
+
end
|
14
|
+
|
15
|
+
# The method name will become "constructor" unless a separate
|
16
|
+
# @method tag already supplied the name.
|
17
|
+
def process_doc(h, tags, pos)
|
18
|
+
h[:name] = "constructor" unless h[:name]
|
19
|
+
# Documentation after @constructor is part of the constructor
|
20
|
+
# method top-level docs.
|
21
|
+
h[:doc] += tags[0][:doc]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
|
3
|
+
module JsDuck::Tag
|
4
|
+
# As of now there is no @css_mixin tag available in CSS files. This
|
5
|
+
# class just exists to define that we have a member type called
|
6
|
+
# :css_mixin.
|
7
|
+
class CssMixin < Tag
|
8
|
+
def initialize
|
9
|
+
@member_type = {
|
10
|
+
:name => :css_mixin,
|
11
|
+
:category => :method_like,
|
12
|
+
:title => "CSS Mixins",
|
13
|
+
:position => MEMBER_POS_CSS_MIXIN,
|
14
|
+
}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
|
3
|
+
module JsDuck::Tag
|
4
|
+
class CssVar < Tag
|
5
|
+
def initialize
|
6
|
+
@pattern = "var"
|
7
|
+
@tagname = :css_var
|
8
|
+
@member_type = {
|
9
|
+
:name => :css_var,
|
10
|
+
:category => :property_like,
|
11
|
+
:title => "CSS Variables",
|
12
|
+
:toolbar_title => "CSS Vars",
|
13
|
+
:position => MEMBER_POS_CSS_VAR,
|
14
|
+
}
|
15
|
+
end
|
16
|
+
|
17
|
+
# @var {Type} [name=default] ...
|
18
|
+
def parse_doc(p)
|
19
|
+
p.standard_tag({:tagname => :css_var, :type => true, :name => true})
|
20
|
+
end
|
21
|
+
|
22
|
+
def process_doc(h, tags, pos)
|
23
|
+
p = tags[0]
|
24
|
+
h[:name] = p[:name]
|
25
|
+
h[:type] = p[:type]
|
26
|
+
h[:default] = p[:default]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
require "jsduck/docs_code_comparer"
|
3
|
+
require "jsduck/util/html"
|
4
|
+
|
5
|
+
module JsDuck::Tag
|
6
|
+
# There is no @default tag.
|
7
|
+
#
|
8
|
+
# Default values are detected from syntax like this:
|
9
|
+
#
|
10
|
+
# @cfg [blah=somedefault]
|
11
|
+
#
|
12
|
+
# This tag class exists to take care of the merging of :default
|
13
|
+
# fields and to generate the "Defaults to:" text in final HTML.
|
14
|
+
class Default < Tag
|
15
|
+
def initialize
|
16
|
+
@tagname = :default
|
17
|
+
@merge_context = :property_like
|
18
|
+
@html_position = POS_DEFAULT
|
19
|
+
end
|
20
|
+
|
21
|
+
def merge(h, docs, code)
|
22
|
+
h[:default] = JsDuck::DocsCodeComparer.merge_if_matches(:default, docs, code)
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_html(m)
|
26
|
+
return if m[:default] == "undefined"
|
27
|
+
|
28
|
+
"<p>Defaults to: <code>" + JsDuck::Util::HTML.escape(m[:default]) + "</code></p>"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,33 +1,19 @@
|
|
1
|
-
require "jsduck/
|
1
|
+
require "jsduck/tag/deprecated_tag"
|
2
2
|
|
3
3
|
module JsDuck::Tag
|
4
|
-
|
5
|
-
class Deprecated < JsDuck::MetaTag
|
4
|
+
class Deprecated < DeprecatedTag
|
6
5
|
def initialize
|
7
|
-
@
|
8
|
-
@
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
{:text => text || ""}
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def to_html(depr)
|
23
|
-
v = depr[:version] ? "since " + depr[:version] : ""
|
24
|
-
<<-EOHTML
|
25
|
-
<div class='signature-box deprecated'>
|
26
|
-
<p>This #{@context[:tagname]} has been <strong>deprecated</strong> #{v}</p>
|
27
|
-
#{format(depr[:text])}
|
28
|
-
</div>
|
29
|
-
EOHTML
|
6
|
+
@tagname = :deprecated
|
7
|
+
@css = <<-EOCSS
|
8
|
+
.signature .deprecated {
|
9
|
+
background-color: #aa0000;
|
10
|
+
}
|
11
|
+
.deprecated-box strong {
|
12
|
+
color: white;
|
13
|
+
background-color: #aa0000;
|
14
|
+
}
|
15
|
+
EOCSS
|
16
|
+
super
|
30
17
|
end
|
31
18
|
end
|
32
19
|
end
|
33
|
-
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
|
3
|
+
module JsDuck::Tag
|
4
|
+
# Base class for both @deprecated and @removed. Child classes only
|
5
|
+
# need to define the @tagname attribute and call #super - all the
|
6
|
+
# correct behavior will the fall out automatically.
|
7
|
+
class DeprecatedTag < Tag
|
8
|
+
def initialize
|
9
|
+
if @tagname
|
10
|
+
@pattern = @tagname.to_s
|
11
|
+
@signature = {:long => @tagname.to_s, :short => @tagname.to_s[0..2].upcase}
|
12
|
+
@html_position = POS_DEPRECATED
|
13
|
+
@css += <<-EOCSS
|
14
|
+
.deprecated-tag-box {
|
15
|
+
text-align: center;
|
16
|
+
color: #600;
|
17
|
+
background-color: #fee;
|
18
|
+
}
|
19
|
+
.deprecated-tag-box strong {
|
20
|
+
text-transform: uppercase;
|
21
|
+
border-radius: 2px;
|
22
|
+
padding: 0 3px;
|
23
|
+
}
|
24
|
+
EOCSS
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def parse_doc(p)
|
29
|
+
{
|
30
|
+
:tagname => @tagname,
|
31
|
+
:version => p.match(/[0-9.]+/),
|
32
|
+
:doc => :multiline,
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
def process_doc(h, tags, pos)
|
37
|
+
v = {:text => tags[0][:doc] || ""}
|
38
|
+
v[:version] = tags[0][:version] if tags[0][:version]
|
39
|
+
h[@tagname] = v
|
40
|
+
end
|
41
|
+
|
42
|
+
def format(context, formatter)
|
43
|
+
context[@tagname][:text] = formatter.format(context[@tagname][:text])
|
44
|
+
end
|
45
|
+
|
46
|
+
def to_html(context)
|
47
|
+
depr = context[@tagname]
|
48
|
+
v = depr[:version] ? "since " + depr[:version] : ""
|
49
|
+
<<-EOHTML
|
50
|
+
<div class='rounded-box #{@tagname}-box deprecated-tag-box'>
|
51
|
+
<p>This #{context[:tagname]} has been <strong>#{@tagname}</strong> #{v}</p>
|
52
|
+
#{depr[:text]}
|
53
|
+
</div>
|
54
|
+
EOHTML
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "jsduck/tag/tag"
|
2
|
+
require 'jsduck/format/shortener'
|
3
|
+
|
4
|
+
module JsDuck::Tag
|
5
|
+
# A special class for rendering the documentation field inside
|
6
|
+
# classes and members.
|
7
|
+
class Doc < Tag
|
8
|
+
def initialize
|
9
|
+
@tagname = :doc
|
10
|
+
@html_position = POS_DOC
|
11
|
+
@shortener = JsDuck::Format::Shortener.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def format(m, formatter)
|
15
|
+
m[:doc] = formatter.format(m[:doc])
|
16
|
+
|
17
|
+
if expandable?(m) || @shortener.too_long?(m[:doc])
|
18
|
+
m[:short_doc] = @shortener.shorten(m[:doc])
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_html(m)
|
23
|
+
m[:doc]
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def expandable?(m)
|
29
|
+
m[:params] || (m[:properties] && m[:properties].length > 0) || m[:default] || m[:deprecated] || m[:template]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/jsduck/tag/docauthor.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
require "jsduck/
|
1
|
+
require "jsduck/tag/author"
|
2
2
|
|
3
3
|
module JsDuck::Tag
|
4
|
-
#
|
5
|
-
class Docauthor <
|
4
|
+
# Exactly the same as @author tag - it's simply ignored.
|
5
|
+
class Docauthor < Author
|
6
6
|
def initialize
|
7
|
-
@
|
7
|
+
@pattern = "docauthor"
|
8
8
|
end
|
9
9
|
end
|
10
10
|
end
|
11
|
-
|