yard 0.2.3.4 → 0.2.3.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of yard might be problematic. Click here for more details.
- data/lib/yard.rb +1 -1
- data/lib/yard/cli/yardoc.rb +1 -1
- data/lib/yard/generators/helpers/html_syntax_highlight_helper.rb +1 -1
- data/lib/yard/parser/ruby/ruby_parser.rb +15 -7
- data/lib/yard/registry.rb +7 -8
- data/spec/cli/yardoc_spec.rb +8 -1
- data/spec/handlers/examples/extend_handler_001.rb.txt +8 -0
- data/spec/handlers/extend_handler_spec.rb +4 -0
- data/spec/parser/ruby/ruby_parser_spec.rb +23 -0
- data/spec/registry_spec.rb +1 -0
- metadata +2 -2
data/lib/yard.rb
CHANGED
data/lib/yard/cli/yardoc.rb
CHANGED
@@ -150,7 +150,7 @@ module YARD
|
|
150
150
|
options[:title] = title
|
151
151
|
end
|
152
152
|
|
153
|
-
opts.on('-r', '--readme FILE', 'The readme file used as the title page of documentation.') do |readme|
|
153
|
+
opts.on('-r', '--readme FILE', '--main FILE', 'The readme file used as the title page of documentation.') do |readme|
|
154
154
|
raise Errno::ENOENT, readme unless File.file?(readme)
|
155
155
|
options[:readme] = readme
|
156
156
|
end
|
@@ -87,7 +87,7 @@ module YARD
|
|
87
87
|
REV_MAPPINGS = {}
|
88
88
|
|
89
89
|
AST_TOKENS = [:CHAR, :backref, :const, :cvar, :gvar, :heredoc_end, :ident,
|
90
|
-
:int, :float, :ivar, :period, :regexp_end, :tstring_content, :backtick]
|
90
|
+
:int, :float, :ivar, :label, :period, :regexp_end, :tstring_content, :backtick]
|
91
91
|
|
92
92
|
MAPPINGS.each do |k, v|
|
93
93
|
if Array === v
|
@@ -208,20 +208,20 @@ module YARD
|
|
208
208
|
args.first
|
209
209
|
end
|
210
210
|
|
211
|
-
def on_hash(*args)
|
212
|
-
visit_event AstNode.new(:hash, [args.first], listline: lineno..lineno, listchar: charno...charno)
|
213
|
-
end
|
214
|
-
|
215
211
|
def on_assoc_new(*args)
|
216
212
|
AstNode.new(:assoc, args)
|
217
213
|
end
|
214
|
+
|
215
|
+
def on_hash(*args)
|
216
|
+
visit_event AstNode.new(:hash, args.first || [])
|
217
|
+
end
|
218
218
|
|
219
219
|
def on_bare_assoc_hash(*args)
|
220
|
-
args.first
|
220
|
+
AstNode.new(:list, args.first)
|
221
221
|
end
|
222
222
|
|
223
223
|
def on_assoclist_from_args(*args)
|
224
|
-
|
224
|
+
args.first
|
225
225
|
end
|
226
226
|
|
227
227
|
def on_qwords_new
|
@@ -263,6 +263,14 @@ module YARD
|
|
263
263
|
end
|
264
264
|
ParameterNode.new(:params, args, listline: lineno..lineno, listchar: charno..charno)
|
265
265
|
end
|
266
|
+
|
267
|
+
def on_label(data)
|
268
|
+
add_token(:label, data)
|
269
|
+
ch = charno
|
270
|
+
@charno += data.length
|
271
|
+
@ns_charno = charno
|
272
|
+
AstNode.new(:label, [data[0...-1]], line: lineno..lineno, char: ch..charno-1, token: true)
|
273
|
+
end
|
266
274
|
|
267
275
|
def on_comment(comment)
|
268
276
|
visit_ns_token(:comment, comment)
|
data/lib/yard/registry.rb
CHANGED
@@ -11,14 +11,6 @@ module YARD
|
|
11
11
|
|
12
12
|
class << self
|
13
13
|
attr_reader :objects
|
14
|
-
|
15
|
-
def method_missing(meth, *args, &block)
|
16
|
-
if instance.respond_to? meth
|
17
|
-
instance.send(meth, *args, &block)
|
18
|
-
else
|
19
|
-
super
|
20
|
-
end
|
21
|
-
end
|
22
14
|
|
23
15
|
def clear
|
24
16
|
instance.clear
|
@@ -141,6 +133,13 @@ module YARD
|
|
141
133
|
end
|
142
134
|
proxy_fallback ? CodeObjects::Proxy.new(orignamespace, name) : nil
|
143
135
|
end
|
136
|
+
|
137
|
+
# Define all instance methods as singleton methods on instance
|
138
|
+
(public_instance_methods(false) - public_methods(false)).each do |meth|
|
139
|
+
module_eval(<<-eof, __FILE__, __LINE__ + 1)
|
140
|
+
def self.#{meth}(*args, &block) instance.send(:#{meth}, *args, &block) end
|
141
|
+
eof
|
142
|
+
end
|
144
143
|
|
145
144
|
private
|
146
145
|
|
data/spec/cli/yardoc_spec.rb
CHANGED
@@ -13,6 +13,13 @@ describe YARD::CLI::Yardoc do
|
|
13
13
|
@yardoc.optparse('--title', 'hello world')
|
14
14
|
@yardoc.options[:title].should == :'hello world'
|
15
15
|
end
|
16
|
+
|
17
|
+
it "should alias --main to the --readme flag" do
|
18
|
+
readme = File.join(File.dirname(__FILE__),'..','..','README.markdown')
|
19
|
+
|
20
|
+
@yardoc.optparse('--main', readme)
|
21
|
+
@yardoc.options[:readme].should == readme.to_sym
|
22
|
+
end
|
16
23
|
|
17
24
|
it "should select a markup provider when --markup-provider or -mp is set" do
|
18
25
|
@yardoc.optparse("-M", "test")
|
@@ -73,4 +80,4 @@ describe YARD::CLI::Yardoc do
|
|
73
80
|
@yardoc.optparse
|
74
81
|
@yardoc.files.should == %w( lib/**/*.rb )
|
75
82
|
end
|
76
|
-
end
|
83
|
+
end
|
@@ -12,4 +12,8 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}ExtendHandler" do
|
|
12
12
|
Registry.at(:C).class_mixins.should == [P(:C)]
|
13
13
|
Registry.at(:C).instance_mixins.should be_empty
|
14
14
|
end
|
15
|
+
|
16
|
+
it "should extend module with correct namespace" do
|
17
|
+
Registry.at('Q::R::S').class_mixins.first.path.should == 'A'
|
18
|
+
end
|
15
19
|
end
|
@@ -67,6 +67,29 @@ if RUBY19
|
|
67
67
|
it "should throw a ParserSyntaxError on invalid code" do
|
68
68
|
lambda { stmt("Foo, bar.") }.should raise_error(YARD::Parser::ParserSyntaxError)
|
69
69
|
end
|
70
|
+
|
71
|
+
it "should handle bare hashes as method parameters" do
|
72
|
+
src = "command :a => 1, :b => 2, :c => 3"
|
73
|
+
stmt(src).jump(:command)[1].source.should == ":a => 1, :b => 2, :c => 3"
|
74
|
+
|
75
|
+
src = "command a: 1, b: 2, c: 3"
|
76
|
+
stmt(src).jump(:command)[1].source.should == "a: 1, b: 2, c: 3"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should handle source for hash syntax" do
|
80
|
+
src = "{ :a => 1, :b => 2, :c => 3 }"
|
81
|
+
stmt(src).jump(:hash).source.should == "{ :a => 1, :b => 2, :c => 3 }"
|
82
|
+
end
|
83
|
+
|
84
|
+
it "should handle an empty hash" do
|
85
|
+
stmt("{}").jump(:hash).source.should == "{}"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "new hash label syntax should show label without colon" do
|
89
|
+
ast = stmt("{ a: 1 }").jump(:label)
|
90
|
+
ast[0].should == "a"
|
91
|
+
ast.source.should == "a:"
|
92
|
+
end
|
70
93
|
end
|
71
94
|
end
|
72
95
|
end
|
data/spec/registry_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.3.
|
4
|
+
version: 0.2.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loren Segal
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-13 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|