jsduck 3.11.2 → 4.0.beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +45 -0
- data/README.md +0 -3
- data/Rakefile +5 -2
- data/js-classes/String.js +1 -1
- data/jsduck.gemspec +5 -2
- data/lib/jsduck/accessors.rb +1 -0
- data/lib/jsduck/aggregator.rb +3 -0
- data/lib/jsduck/app.rb +3 -6
- data/lib/jsduck/ast.rb +446 -0
- data/lib/jsduck/class_doc_expander.rb +135 -0
- data/lib/jsduck/css_lexer.rb +1 -1
- data/lib/jsduck/css_parser.rb +8 -11
- data/lib/jsduck/doc_ast.rb +305 -0
- data/lib/jsduck/doc_parser.rb +33 -28
- data/lib/jsduck/doc_type.rb +58 -0
- data/lib/jsduck/esprima.rb +32 -0
- data/lib/jsduck/evaluator.rb +69 -0
- data/lib/jsduck/guides.rb +12 -11
- data/lib/jsduck/inherit_doc.rb +80 -14
- data/lib/jsduck/js_parser.rb +162 -373
- data/lib/jsduck/lexer.rb +1 -1
- data/lib/jsduck/logger.rb +0 -2
- data/lib/jsduck/merger.rb +89 -435
- data/lib/jsduck/options.rb +4 -14
- data/lib/jsduck/serializer.rb +262 -0
- data/lib/jsduck/source_file.rb +5 -18
- data/lib/jsduck/source_file_parser.rb +72 -0
- metadata +33 -9
- data/lib/jsduck/js_literal_builder.rb +0 -21
- data/lib/jsduck/js_literal_parser.rb +0 -106
- data/lib/jsduck/tag/chainable.rb +0 -14
@@ -1,21 +0,0 @@
|
|
1
|
-
module JsDuck
|
2
|
-
|
3
|
-
# Takes output of JsLiteralParser and converts it to string
|
4
|
-
class JsLiteralBuilder
|
5
|
-
|
6
|
-
# Converts literal object definition to string
|
7
|
-
def to_s(lit)
|
8
|
-
if lit[:type] == :string
|
9
|
-
'"' + lit[:value] + '"'
|
10
|
-
elsif lit[:type] == :array
|
11
|
-
"[" + lit[:value].map {|v| to_s(v) }.join(", ") + "]"
|
12
|
-
elsif lit[:type] == :object
|
13
|
-
"{" + lit[:value].map {|v| to_s(v[:key]) + ": " + to_s(v[:value]) }.join(", ") + "}"
|
14
|
-
else
|
15
|
-
lit[:value]
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,106 +0,0 @@
|
|
1
|
-
require 'jsduck/lexer'
|
2
|
-
|
3
|
-
module JsDuck
|
4
|
-
|
5
|
-
# Parser for JavaScript literals: numbers, strings, booleans,
|
6
|
-
# regexes, arrays, objects.
|
7
|
-
#
|
8
|
-
# Almost like a JSON parser, but regexes are also valid values and
|
9
|
-
# object keys don't need to be quoted.
|
10
|
-
class JsLiteralParser
|
11
|
-
def initialize(input)
|
12
|
-
@lex = Lexer.new(input)
|
13
|
-
end
|
14
|
-
|
15
|
-
# Parses a literal.
|
16
|
-
#
|
17
|
-
# Returns a Ruby hash representing this literal. For example parsing this:
|
18
|
-
#
|
19
|
-
# [5, "foo"]
|
20
|
-
#
|
21
|
-
# Returns the following structure:
|
22
|
-
#
|
23
|
-
# {:type => :array, :value => [
|
24
|
-
# {:type => :number, :value => "5"},
|
25
|
-
# {:type => :string, :value => "foo"}
|
26
|
-
# ]}
|
27
|
-
#
|
28
|
-
def literal
|
29
|
-
if look(:number)
|
30
|
-
match(:number)
|
31
|
-
elsif look(:string)
|
32
|
-
match(:string)
|
33
|
-
elsif look(:regex)
|
34
|
-
match(:regex)
|
35
|
-
elsif look("[")
|
36
|
-
array_literal
|
37
|
-
elsif look("{")
|
38
|
-
object_literal
|
39
|
-
elsif look(:ident) && (look("true") || look("false") || look("undefined") || look("null"))
|
40
|
-
match(:ident)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
def array_literal
|
45
|
-
match("[")
|
46
|
-
r = []
|
47
|
-
while (lit = literal)
|
48
|
-
r << lit
|
49
|
-
break unless look(",")
|
50
|
-
match(",")
|
51
|
-
end
|
52
|
-
return unless look("]")
|
53
|
-
match("]")
|
54
|
-
return {:type => :array, :value => r}
|
55
|
-
end
|
56
|
-
|
57
|
-
def object_literal
|
58
|
-
match("{")
|
59
|
-
r = []
|
60
|
-
while (look(:ident) || look(:string))
|
61
|
-
lit = object_literal_pair
|
62
|
-
return unless lit
|
63
|
-
r << lit
|
64
|
-
break unless look(",")
|
65
|
-
match(",")
|
66
|
-
end
|
67
|
-
|
68
|
-
return unless look("}")
|
69
|
-
match("}")
|
70
|
-
return {:type => :object, :value => r}
|
71
|
-
end
|
72
|
-
|
73
|
-
def object_literal_pair
|
74
|
-
if look(:ident)
|
75
|
-
key = match(:ident)
|
76
|
-
elsif look(:string)
|
77
|
-
key = match(:string)
|
78
|
-
end
|
79
|
-
|
80
|
-
return unless look(":")
|
81
|
-
match(":")
|
82
|
-
|
83
|
-
value = literal
|
84
|
-
return unless value
|
85
|
-
|
86
|
-
return {:key => key, :value => value}
|
87
|
-
end
|
88
|
-
|
89
|
-
# Matches all arguments, returns the value of last match
|
90
|
-
# When the whole sequence doesn't match, throws exception
|
91
|
-
def match(*args)
|
92
|
-
if look(*args)
|
93
|
-
last = nil
|
94
|
-
args.length.times { last = @lex.next(true) }
|
95
|
-
last
|
96
|
-
else
|
97
|
-
throw "Expected: " + args.join(", ")
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def look(*args)
|
102
|
-
@lex.look(*args)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
data/lib/jsduck/tag/chainable.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require "jsduck/meta_tag"
|
2
|
-
|
3
|
-
module JsDuck::Tag
|
4
|
-
# Implementation of @chainable tag
|
5
|
-
class Chainable < JsDuck::MetaTag
|
6
|
-
def initialize
|
7
|
-
@name = "chainable"
|
8
|
-
@key = :chainable
|
9
|
-
@signature = {:long => "chainable", :short => ">"} # show small right-arrow
|
10
|
-
@boolean = true
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|