yard 0.5.8 → 0.6.0
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/.yardopts +2 -0
- data/ChangeLog +1064 -0
- data/README.md +103 -42
- data/Rakefile +3 -2
- data/benchmarks/parsing.rb +2 -1
- data/bin/yard +4 -0
- data/bin/yard-graph +1 -1
- data/bin/yard-server +4 -0
- data/docs/GettingStarted.md +8 -8
- data/docs/Handlers.md +5 -5
- data/docs/Overview.md +5 -5
- data/docs/Parser.md +1 -1
- data/docs/Tags.md +1 -1
- data/docs/Templates.md +27 -6
- data/docs/WhatsNew.md +222 -2
- data/lib/rubygems_plugin.rb +1 -0
- data/lib/yard.rb +7 -1
- data/lib/yard/autoload.rb +46 -6
- data/lib/yard/cli/{base.rb → command.rb} +20 -6
- data/lib/yard/cli/command_parser.rb +87 -0
- data/lib/yard/cli/diff.rb +176 -0
- data/lib/yard/cli/gems.rb +74 -0
- data/lib/yard/cli/{yard_graph.rb → graph.rb} +9 -8
- data/lib/yard/cli/help.rb +18 -0
- data/lib/yard/cli/server.rb +137 -0
- data/lib/yard/cli/stats.rb +210 -0
- data/lib/yard/cli/yardoc.rb +315 -116
- data/lib/yard/cli/yri.rb +45 -4
- data/lib/yard/code_objects/base.rb +73 -30
- data/lib/yard/code_objects/class_object.rb +9 -1
- data/lib/yard/code_objects/method_object.rb +11 -0
- data/lib/yard/code_objects/namespace_object.rb +8 -2
- data/lib/yard/code_objects/proxy.rb +2 -2
- data/lib/yard/core_ext/array.rb +3 -49
- data/lib/yard/core_ext/file.rb +7 -0
- data/lib/yard/core_ext/insertion.rb +60 -0
- data/lib/yard/docstring.rb +34 -7
- data/lib/yard/globals.rb +2 -2
- data/lib/yard/handlers/base.rb +101 -20
- data/lib/yard/handlers/processor.rb +23 -7
- data/lib/yard/handlers/ruby/alias_handler.rb +1 -0
- data/lib/yard/handlers/ruby/attribute_handler.rb +8 -0
- data/lib/yard/handlers/ruby/base.rb +71 -2
- data/lib/yard/handlers/ruby/class_condition_handler.rb +10 -0
- data/lib/yard/handlers/ruby/class_handler.rb +7 -4
- data/lib/yard/handlers/ruby/class_variable_handler.rb +1 -0
- data/lib/yard/handlers/ruby/constant_handler.rb +1 -0
- data/lib/yard/handlers/ruby/exception_handler.rb +1 -0
- data/lib/yard/handlers/ruby/extend_handler.rb +2 -3
- data/lib/yard/handlers/ruby/legacy/alias_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/attribute_handler.rb +2 -0
- data/lib/yard/handlers/ruby/legacy/base.rb +15 -2
- data/lib/yard/handlers/ruby/legacy/class_condition_handler.rb +5 -0
- data/lib/yard/handlers/ruby/legacy/class_handler.rb +7 -4
- data/lib/yard/handlers/ruby/legacy/class_variable_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/constant_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/exception_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/extend_handler.rb +1 -3
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +7 -3
- data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +2 -1
- data/lib/yard/handlers/ruby/legacy/module_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/process_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/visibility_handler.rb +1 -0
- data/lib/yard/handlers/ruby/legacy/yield_handler.rb +1 -0
- data/lib/yard/handlers/ruby/method_condition_handler.rb +1 -0
- data/lib/yard/handlers/ruby/method_handler.rb +5 -1
- data/lib/yard/handlers/ruby/mixin_handler.rb +2 -1
- data/lib/yard/handlers/ruby/module_handler.rb +1 -0
- data/lib/yard/handlers/ruby/process_handler.rb +7 -1
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +3 -0
- data/lib/yard/handlers/ruby/visibility_handler.rb +8 -2
- data/lib/yard/handlers/ruby/yield_handler.rb +1 -0
- data/lib/yard/logging.rb +7 -1
- data/lib/yard/parser/base.rb +1 -0
- data/lib/yard/parser/c_parser.rb +2 -0
- data/lib/yard/parser/ruby/ast_node.rb +82 -63
- data/lib/yard/parser/ruby/legacy/ruby_lex.rb +36 -10
- data/lib/yard/parser/ruby/legacy/ruby_parser.rb +1 -0
- data/lib/yard/parser/ruby/legacy/statement.rb +9 -5
- data/lib/yard/parser/ruby/legacy/statement_list.rb +20 -11
- data/lib/yard/parser/ruby/ruby_parser.rb +18 -1
- data/lib/yard/parser/source_parser.rb +6 -1
- data/lib/yard/registry.rb +284 -278
- data/lib/yard/registry_store.rb +4 -2
- data/lib/yard/serializers/base.rb +30 -13
- data/lib/yard/serializers/file_system_serializer.rb +10 -1
- data/lib/yard/server/adapter.rb +51 -0
- data/lib/yard/server/commands/base.rb +98 -0
- data/lib/yard/server/commands/display_file_command.rb +20 -0
- data/lib/yard/server/commands/display_object_command.rb +50 -0
- data/lib/yard/server/commands/frames_command.rb +31 -0
- data/lib/yard/server/commands/library_command.rb +83 -0
- data/lib/yard/server/commands/library_index_command.rb +23 -0
- data/lib/yard/server/commands/list_command.rb +44 -0
- data/lib/yard/server/commands/search_command.rb +67 -0
- data/lib/yard/server/commands/static_file_command.rb +45 -0
- data/lib/yard/server/doc_server_helper.rb +22 -0
- data/lib/yard/server/doc_server_serializer.rb +29 -0
- data/lib/yard/server/library_version.rb +86 -0
- data/lib/yard/server/rack_adapter.rb +38 -0
- data/lib/yard/server/router.rb +110 -0
- data/lib/yard/server/static_caching.rb +16 -0
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +78 -0
- data/lib/yard/server/templates/default/fulldoc/html/images/processing.gif +0 -0
- data/lib/yard/server/templates/default/fulldoc/html/js/autocomplete.js +12 -0
- data/lib/yard/server/templates/default/fulldoc/html/js/live.js +32 -0
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +46 -0
- data/lib/yard/server/templates/default/layout/html/headers.erb +11 -0
- data/lib/yard/server/templates/doc_server/frames/html/frames.erb +13 -0
- data/lib/yard/server/templates/doc_server/frames/html/setup.rb +3 -0
- data/lib/yard/server/templates/doc_server/full_list/html/full_list.erb +34 -0
- data/lib/yard/server/templates/doc_server/full_list/html/setup.rb +10 -0
- data/lib/yard/server/templates/doc_server/library_list/html/contents.erb +13 -0
- data/lib/yard/server/templates/doc_server/library_list/html/headers.erb +26 -0
- data/lib/yard/server/templates/doc_server/library_list/html/library_list.erb +12 -0
- data/lib/yard/server/templates/doc_server/library_list/html/setup.rb +3 -0
- data/lib/yard/server/templates/doc_server/library_list/html/title.erb +2 -0
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +51 -0
- data/lib/yard/server/templates/doc_server/processing/html/setup.rb +3 -0
- data/lib/yard/server/templates/doc_server/search/html/search.erb +19 -0
- data/lib/yard/server/templates/doc_server/search/html/setup.rb +8 -0
- data/lib/yard/server/webrick_adapter.rb +38 -0
- data/lib/yard/tags/default_factory.rb +0 -5
- data/lib/yard/tags/library.rb +61 -22
- data/lib/yard/tags/tag.rb +26 -4
- data/lib/yard/templates/engine.rb +12 -1
- data/lib/yard/templates/erb_cache.rb +2 -1
- data/lib/yard/templates/helpers/base_helper.rb +96 -3
- data/lib/yard/templates/helpers/filter_helper.rb +5 -0
- data/lib/yard/templates/helpers/html_helper.rb +204 -94
- data/lib/yard/templates/helpers/html_syntax_highlight_helper.rb +4 -0
- data/lib/yard/templates/helpers/markup_helper.rb +58 -3
- data/lib/yard/templates/helpers/method_helper.rb +7 -0
- data/lib/yard/templates/helpers/module_helper.rb +5 -0
- data/lib/yard/templates/helpers/text_helper.rb +10 -1
- data/lib/yard/templates/helpers/uml_helper.rb +13 -0
- data/lib/yard/templates/section.rb +106 -0
- data/lib/yard/templates/template.rb +20 -19
- data/lib/yard/verifier.rb +21 -2
- data/spec/cli/command_parser_spec.rb +43 -0
- data/spec/cli/diff_spec.rb +170 -0
- data/spec/cli/help_spec.rb +22 -0
- data/spec/cli/server_spec.rb +140 -0
- data/spec/cli/stats_spec.rb +75 -0
- data/spec/cli/yardoc_spec.rb +438 -182
- data/spec/cli/yri_spec.rb +13 -1
- data/spec/code_objects/base_spec.rb +51 -6
- data/spec/code_objects/class_object_spec.rb +15 -1
- data/spec/code_objects/method_object_spec.rb +29 -0
- data/spec/code_objects/namespace_object_spec.rb +150 -129
- data/spec/core_ext/array_spec.rb +4 -23
- data/spec/core_ext/insertion_spec.rb +37 -0
- data/spec/docstring_spec.rb +63 -0
- data/spec/handlers/attribute_handler_spec.rb +4 -0
- data/spec/handlers/base_spec.rb +98 -26
- data/spec/handlers/class_handler_spec.rb +5 -1
- data/spec/handlers/examples/attribute_handler_001.rb.txt +5 -0
- data/spec/handlers/examples/class_handler_001.rb.txt +4 -0
- data/spec/handlers/examples/module_handler_001.rb.txt +6 -1
- data/spec/handlers/examples/visibility_handler_001.rb.txt +4 -0
- data/spec/handlers/method_handler_spec.rb +5 -0
- data/spec/handlers/module_handler_spec.rb +4 -0
- data/spec/handlers/visibility_handler_spec.rb +6 -0
- data/spec/parser/source_parser_spec.rb +24 -0
- data/spec/registry_spec.rb +44 -8
- data/spec/server/adapter_spec.rb +38 -0
- data/spec/server/commands/base_spec.rb +87 -0
- data/spec/server/commands/static_file_command_spec.rb +67 -0
- data/spec/server/doc_server_serializer_spec.rb +58 -0
- data/spec/server/router_spec.rb +115 -0
- data/spec/server/spec_helper.rb +17 -0
- data/spec/server/static_caching_spec.rb +39 -0
- data/spec/server/webrick_servlet_spec.rb +20 -0
- data/spec/templates/constant_spec.rb +40 -0
- data/spec/templates/engine_spec.rb +9 -5
- data/spec/templates/examples/class002.html +1 -3
- data/spec/templates/examples/constant001.txt +25 -0
- data/spec/templates/examples/constant002.txt +7 -0
- data/spec/templates/examples/constant003.txt +11 -0
- data/spec/templates/examples/module001.txt +1 -1
- data/spec/templates/examples/module002.html +319 -0
- data/spec/templates/helpers/base_helper_spec.rb +2 -2
- data/spec/templates/helpers/html_helper_spec.rb +93 -3
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +5 -0
- data/spec/templates/helpers/markup_helper_spec.rb +94 -67
- data/spec/templates/helpers/shared_signature_examples.rb +9 -0
- data/spec/templates/helpers/text_helper_spec.rb +12 -0
- data/spec/templates/module_spec.rb +21 -4
- data/spec/templates/section_spec.rb +146 -0
- data/spec/templates/template_spec.rb +9 -20
- data/templates/default/class/setup.rb +5 -5
- data/templates/default/constant/text/header.erb +11 -0
- data/templates/default/constant/text/setup.rb +3 -0
- data/templates/default/fulldoc/html/css/style.css +29 -3
- data/templates/default/fulldoc/html/js/app.js +67 -1
- data/templates/default/fulldoc/html/js/full_list.js +3 -8
- data/templates/default/fulldoc/html/js/jquery.js +150 -15
- data/templates/default/fulldoc/html/setup.rb +9 -0
- data/templates/default/layout/html/footer.erb +1 -1
- data/templates/default/layout/html/setup.rb +7 -25
- data/templates/default/method_details/html/source.erb +1 -1
- data/templates/default/module/html/attribute_summary.erb +2 -2
- data/templates/default/module/html/method_summary.erb +2 -2
- data/templates/default/module/setup.rb +27 -4
- data/templates/default/onefile/html/files.erb +5 -0
- data/templates/default/onefile/html/layout.erb +22 -0
- data/templates/default/onefile/html/readme.erb +3 -0
- data/templates/default/onefile/html/setup.rb +40 -0
- data/templates/default/root/html/setup.rb +1 -0
- data/templates/default/tags/setup.rb +26 -33
- metadata +80 -10
data/spec/core_ext/array_spec.rb
CHANGED
@@ -5,29 +5,10 @@ describe Array do
|
|
5
5
|
it "should create an Insertion object" do
|
6
6
|
[].place('x').should be_kind_of(Insertion)
|
7
7
|
end
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
describe Insertion do
|
12
|
-
describe '#before' do
|
13
|
-
it "should place an object before another" do
|
14
|
-
[1, 2].place(3).before(2).should == [1, 3, 2]
|
15
|
-
[1, 2].place(3).before(1).should == [3, 1, 2]
|
16
|
-
[1, [4], 2].place(3).before(2).should == [1, [4], 3, 2]
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#after' do
|
21
|
-
it "should place an object after another" do
|
22
|
-
[1, 2].place(3).after(2).should == [1, 2, 3]
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should place an object after another and its subsections" do
|
26
|
-
[1, [2]].place(3).after(1).should == [1, [2], 3]
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should not not ignore subsections if ignore_subections=false" do
|
30
|
-
[1, [2]].place(3).after(1, false).should == [1, 3, [2]]
|
8
|
+
|
9
|
+
it "should allow multiple objects to be placed" do
|
10
|
+
[1, 2].place('x', 'y', 'z').before(2).should == [1, 'x', 'y', 'z', 2]
|
31
11
|
end
|
32
12
|
end
|
33
13
|
end
|
14
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../spec_helper'
|
2
|
+
|
3
|
+
describe Insertion do
|
4
|
+
describe '#before' do
|
5
|
+
it "should place an object before another" do
|
6
|
+
[1, 2].place(3).before(2).should == [1, 3, 2]
|
7
|
+
[1, 2].place(3).before(1).should == [3, 1, 2]
|
8
|
+
[1, [4], 2].place(3).before(2).should == [1, [4], 3, 2]
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#after' do
|
13
|
+
it "should place an object after another" do
|
14
|
+
[1, 2].place(3).after(2).should == [1, 2, 3]
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should no longer place an object after another and its subsections (0.6)" do
|
18
|
+
[1, [2]].place(3).after(1).should == [1, 3, [2]]
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should place an array after an object" do
|
22
|
+
[1, 2, 3].place([4]).after(1).should == [1, [4], 2, 3]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#before_any' do
|
27
|
+
it "should place an object before another anywhere inside list (including sublists)" do
|
28
|
+
[1, 2, [3]].place(4).before_any(3).should == [1, 2, [4, 3]]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#after_any' do
|
33
|
+
it "should place an object after another anywhere inside list (including sublists)" do
|
34
|
+
[1, 2, [3]].place(4).after_any(3).should == [1, 2, [3, 4]]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/docstring_spec.rb
CHANGED
@@ -9,6 +9,26 @@ describe YARD::Docstring do
|
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
|
+
describe '#+' do
|
13
|
+
it "should add another Docstring" do
|
14
|
+
d = Docstring.new("FOO") + Docstring.new("BAR")
|
15
|
+
d.should == "FOO\nBAR"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should copy over tags" do
|
19
|
+
d1 = Docstring.new("FOO\n@api private\n")
|
20
|
+
d2 = Docstring.new("BAR\n@param foo descr")
|
21
|
+
d = (d1 + d2)
|
22
|
+
d.should have_tag(:api)
|
23
|
+
d.should have_tag(:param)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should add a String" do
|
27
|
+
d = Docstring.new("FOO") + "BAR"
|
28
|
+
d.should == "FOOBAR"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
12
32
|
describe '#summary' do
|
13
33
|
it "should handle empty docstrings" do
|
14
34
|
o1 = Docstring.new
|
@@ -134,6 +154,10 @@ describe YARD::Docstring do
|
|
134
154
|
end
|
135
155
|
|
136
156
|
describe '#empty?/#blank?' do
|
157
|
+
before(:all) do
|
158
|
+
Tags::Library.define_tag "Invisible", :invisible_tag
|
159
|
+
end
|
160
|
+
|
137
161
|
it "should be blank and empty if it has no content and no tags" do
|
138
162
|
Docstring.new.should be_blank
|
139
163
|
Docstring.new.should be_empty
|
@@ -158,6 +182,17 @@ describe YARD::Docstring do
|
|
158
182
|
d.should be_empty
|
159
183
|
d.should_not be_blank
|
160
184
|
end
|
185
|
+
|
186
|
+
it "should be blank if it has no visible tags" do
|
187
|
+
d = Docstring.new("@invisible_tag value")
|
188
|
+
d.should be_blank
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should not be blank if it has invisible tags and only_visible_tags = false" do
|
192
|
+
d = Docstring.new("@invisible_tag value")
|
193
|
+
d.add_tag Tags::Tag.new('invisible_tag', nil, nil)
|
194
|
+
d.blank?(false).should == false
|
195
|
+
end
|
161
196
|
end
|
162
197
|
|
163
198
|
describe '#add_tag' do
|
@@ -238,5 +273,33 @@ eof
|
|
238
273
|
eof
|
239
274
|
doc.tag(:param).text.should == "some value\nfoo bar\n baz"
|
240
275
|
end
|
276
|
+
|
277
|
+
it "should allow numbers in tags" do
|
278
|
+
Tags::Library.define_tag(nil, :foo1)
|
279
|
+
Tags::Library.define_tag(nil, :foo2)
|
280
|
+
Tags::Library.define_tag(nil, :foo3)
|
281
|
+
doc = Docstring.new(<<-eof)
|
282
|
+
@foo1 bar1
|
283
|
+
@foo2 bar2
|
284
|
+
@foo3 bar3
|
285
|
+
eof
|
286
|
+
doc.tag(:foo1).text.should == "bar1"
|
287
|
+
doc.tag(:foo2).text.should == "bar2"
|
288
|
+
end
|
289
|
+
|
290
|
+
it "should end tag on newline if next line is not indented" do
|
291
|
+
doc = Docstring.new(<<-eof)
|
292
|
+
@author bar1
|
293
|
+
@api bar2
|
294
|
+
Hello world
|
295
|
+
eof
|
296
|
+
doc.tag(:author).text.should == "bar1"
|
297
|
+
doc.tag(:api).text.should == "bar2"
|
298
|
+
end
|
299
|
+
|
300
|
+
it "should warn about unknown tag" do
|
301
|
+
log.should_receive(:warn).with(/Unknown tag @hello$/)
|
302
|
+
Docstring.new("@hello world")
|
303
|
+
end
|
241
304
|
end
|
242
305
|
end
|
@@ -87,4 +87,8 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}AttributeHandler" do
|
|
87
87
|
it "should add existing writer method as part of attr_reader combo" do
|
88
88
|
Registry.at('C#foo').attr_info[:write].should == Registry.at('C#foo=')
|
89
89
|
end
|
90
|
+
|
91
|
+
it "should maintain visibility for attr_reader" do
|
92
|
+
Registry.at('D#parser').visibility.should == :protected
|
93
|
+
end
|
90
94
|
end
|
data/spec/handlers/base_spec.rb
CHANGED
@@ -2,38 +2,110 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
2
2
|
|
3
3
|
include Parser
|
4
4
|
|
5
|
-
describe YARD::Handlers::Base
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
it "should keep track of subclasses" do
|
11
|
-
Handlers::Base.should_receive(:inherited).once
|
12
|
-
class TestHandler < Handlers::Base; end
|
13
|
-
end
|
5
|
+
describe YARD::Handlers::Base do
|
6
|
+
describe "#handles and inheritance" do
|
7
|
+
before do
|
8
|
+
Handlers::Base.stub!(:inherited)
|
9
|
+
end
|
14
10
|
|
15
|
-
|
16
|
-
|
11
|
+
it "should keep track of subclasses" do
|
12
|
+
Handlers::Base.should_receive(:inherited).once
|
13
|
+
class TestHandler < Handlers::Base; end
|
17
14
|
end
|
15
|
+
|
16
|
+
it "should raise NotImplementedError if process is called on a class with no #process" do
|
17
|
+
class TestNotImplementedHandler < Handlers::Base
|
18
|
+
end
|
18
19
|
|
19
|
-
|
20
|
+
lambda { TestNotImplementedHandler.new(0, 0).process }.should raise_error(NotImplementedError)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should allow multiple handles arguments" do
|
24
|
+
Handlers::Base.should_receive(:inherited).once
|
25
|
+
class TestHandler1 < Handlers::Base
|
26
|
+
handles :a, :b, :c
|
27
|
+
end
|
28
|
+
TestHandler1.handlers.should == [:a, :b, :c]
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should allow multiple handles calls" do
|
32
|
+
Handlers::Base.should_receive(:inherited).once
|
33
|
+
class TestHandler2 < Handlers::Base
|
34
|
+
handles :a
|
35
|
+
handles :b
|
36
|
+
handles :c
|
37
|
+
end
|
38
|
+
TestHandler2.handlers.should == [:a, :b, :c]
|
39
|
+
end
|
20
40
|
end
|
21
41
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
42
|
+
describe 'transitive tags' do
|
43
|
+
it "should add transitive tags to children" do
|
44
|
+
Registry.clear
|
45
|
+
YARD.parse_string <<-eof
|
46
|
+
# @since 1.0
|
47
|
+
# @author Foo
|
48
|
+
class A
|
49
|
+
def foo; end
|
50
|
+
# @since 1.1
|
51
|
+
def bar; end
|
52
|
+
end
|
53
|
+
eof
|
54
|
+
Registry.at('A').tag(:since).text.should == "1.0"
|
55
|
+
Registry.at('A#foo').tag(:since).text.should == "1.0"
|
56
|
+
Registry.at('A#bar').tag(:since).text.should == "1.1"
|
57
|
+
Registry.at('A#bar').tag(:author).should be_nil
|
26
58
|
end
|
27
|
-
TestHandler1.handlers.should == [:a, :b, :c]
|
28
59
|
end
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
60
|
+
|
61
|
+
describe '#push_state' do
|
62
|
+
def process(klass)
|
63
|
+
state = OpenStruct.new(:namespace => "ROOT", :scope => :instance, :owner => "ROOT")
|
64
|
+
klass.new(state, nil).process
|
65
|
+
end
|
66
|
+
|
67
|
+
it "should push and return all old state info after block" do
|
68
|
+
class PushStateHandler1 < Handlers::Base
|
69
|
+
def process
|
70
|
+
push_state(:namespace => "FOO", :scope => :class, :owner => "BAR") do
|
71
|
+
namespace.should == "FOO"
|
72
|
+
scope.should == :class
|
73
|
+
owner.should == "BAR"
|
74
|
+
end
|
75
|
+
namespace.should == "ROOT"
|
76
|
+
owner.should == "ROOT"
|
77
|
+
scope.should == :instance
|
78
|
+
end
|
79
|
+
end
|
80
|
+
process PushStateHandler1
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should allow owner to be pushed individually" do
|
84
|
+
class PushStateHandler2 < Handlers::Base
|
85
|
+
def process
|
86
|
+
push_state(:owner => "BAR") do
|
87
|
+
namespace.should == "ROOT"
|
88
|
+
scope.should == :instance
|
89
|
+
owner.should == "BAR"
|
90
|
+
end
|
91
|
+
owner.should == "ROOT"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
process PushStateHandler2
|
95
|
+
end
|
96
|
+
|
97
|
+
it "should allow scope to be pushed individually" do
|
98
|
+
class PushStateHandler3 < Handlers::Base
|
99
|
+
def process
|
100
|
+
push_state(:scope => :foo) do
|
101
|
+
namespace.should == "ROOT"
|
102
|
+
scope.should == :foo
|
103
|
+
owner.should == "ROOT"
|
104
|
+
end
|
105
|
+
scope.should == :instance
|
106
|
+
end
|
107
|
+
end
|
108
|
+
process PushStateHandler3
|
109
|
+
end
|
38
110
|
end
|
39
111
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/spec_helper'
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}ClassHandler" do
|
4
4
|
before(:all) { parse_file :class_handler_001, __FILE__ }
|
@@ -230,4 +230,8 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}ClassHandler" do
|
|
230
230
|
Registry.at("SemiDoccedStruct#fourth=").docstring.should == "sets the proc that writes stuff"
|
231
231
|
end
|
232
232
|
|
233
|
+
it "should inherit from a regular struct" do
|
234
|
+
Registry.at('RegularStruct').superclass.should == P(:Struct)
|
235
|
+
Registry.at('RegularStruct2').superclass.should == P(:Struct)
|
236
|
+
end
|
233
237
|
end
|
@@ -122,4 +122,9 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}MethodHandler" do
|
|
122
122
|
meth.tag(:param).name.should == "opts"
|
123
123
|
meth.tag(:param).types.should == ["Hash"]
|
124
124
|
end
|
125
|
+
|
126
|
+
it "should raise an undocumentable error when a method is defined on an object instance" do
|
127
|
+
undoc_error "error = Foo; def error.at(foo) end"
|
128
|
+
Registry.at('error').should be_nil
|
129
|
+
end
|
125
130
|
end
|
@@ -23,4 +23,8 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}ModuleHandler" do
|
|
23
23
|
it "should handle modules in the form ::ModName" do
|
24
24
|
Registry.at("Kernel").should_not be_nil
|
25
25
|
end
|
26
|
+
|
27
|
+
it "should list mixins in proper order" do
|
28
|
+
Registry.at('D').mixins.should == [P(:C), P(:B), P(:A)]
|
29
|
+
end
|
26
30
|
end
|
@@ -21,4 +21,10 @@ describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}VisibilityHandler" do
|
|
21
21
|
Registry['Testing#notpriv2'].visibility.should == :protected
|
22
22
|
Registry['Testing#notpriv?'].visibility.should == :protected
|
23
23
|
end
|
24
|
+
|
25
|
+
it "should only accept strings and symbols" do
|
26
|
+
Registry.at('Testing#name').should be_nil
|
27
|
+
Registry.at('Testing#argument').should be_nil
|
28
|
+
Registry.at('Testing#method_call').should be_nil
|
29
|
+
end
|
24
30
|
end
|
@@ -244,5 +244,29 @@ describe YARD::Parser::SourceParser do
|
|
244
244
|
YARD::Parser::SourceParser.parse_string("$$$", :ruby)
|
245
245
|
end
|
246
246
|
end
|
247
|
+
|
248
|
+
it "should handle groups" do
|
249
|
+
Registry.clear
|
250
|
+
YARD.parse_string <<-eof
|
251
|
+
class A
|
252
|
+
# @group Group Name
|
253
|
+
def foo; end
|
254
|
+
def foo2; end
|
255
|
+
|
256
|
+
# @endgroup
|
257
|
+
|
258
|
+
def bar; end
|
259
|
+
|
260
|
+
# @group Group 2
|
261
|
+
def baz; end
|
262
|
+
end
|
263
|
+
eof
|
264
|
+
|
265
|
+
Registry.at('A').groups.should == ['Group Name', 'Group 2']
|
266
|
+
Registry.at('A#bar').group.should be_nil
|
267
|
+
Registry.at('A#foo').group.should == "Group Name"
|
268
|
+
Registry.at('A#foo2').group.should == "Group Name"
|
269
|
+
Registry.at('A#baz').group.should == "Group 2"
|
270
|
+
end
|
247
271
|
end
|
248
272
|
end
|
data/spec/registry_spec.rb
CHANGED
@@ -73,13 +73,13 @@ describe YARD::Registry do
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
describe '
|
76
|
+
describe '.root' do
|
77
77
|
it "should have an empty path for root" do
|
78
78
|
Registry.root.path.should == ""
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
describe '
|
82
|
+
describe '.resolve' do
|
83
83
|
it "should resolve any existing namespace" do
|
84
84
|
o1 = ModuleObject.new(:root, :A)
|
85
85
|
o2 = ModuleObject.new(o1, :B)
|
@@ -139,18 +139,18 @@ describe YARD::Registry do
|
|
139
139
|
end
|
140
140
|
|
141
141
|
it "should only check 'Path' in lookup on root namespace" do
|
142
|
-
Registry.
|
142
|
+
Registry.should_receive(:at).once.with('Test').and_return(true)
|
143
143
|
Registry.resolve(Registry.root, "Test")
|
144
144
|
end
|
145
145
|
|
146
146
|
it "should not perform lookup by joining namespace and name without separator" do
|
147
147
|
yard = ClassObject.new(:root, :YARD)
|
148
|
-
Registry.
|
148
|
+
Registry.should_not_receive(:at).with('YARDB')
|
149
149
|
Registry.resolve(yard, 'B')
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
describe '
|
153
|
+
describe '.all' do
|
154
154
|
it "should return objects of types specified by arguments" do
|
155
155
|
ModuleObject.new(:root, :A)
|
156
156
|
o1 = ClassObject.new(:root, :B)
|
@@ -167,7 +167,7 @@ describe YARD::Registry do
|
|
167
167
|
r.should include(o1, o2)
|
168
168
|
end
|
169
169
|
|
170
|
-
it "should allow
|
170
|
+
it "should allow .all to omit list" do
|
171
171
|
o1 = ModuleObject.new(:root, :A)
|
172
172
|
o2 = ClassObject.new(:root, :B)
|
173
173
|
r = Registry.all
|
@@ -175,7 +175,7 @@ describe YARD::Registry do
|
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
|
-
describe '
|
178
|
+
describe '.paths' do
|
179
179
|
it "should return all object paths" do
|
180
180
|
o1 = ModuleObject.new(:root, :A)
|
181
181
|
o2 = ClassObject.new(:root, :B)
|
@@ -183,7 +183,7 @@ describe YARD::Registry do
|
|
183
183
|
end
|
184
184
|
end
|
185
185
|
|
186
|
-
describe '
|
186
|
+
describe '.load_yardoc' do
|
187
187
|
it "should delegate load to RegistryStore" do
|
188
188
|
store = RegistryStore.new
|
189
189
|
store.should_receive(:load).with('foo')
|
@@ -192,6 +192,10 @@ describe YARD::Registry do
|
|
192
192
|
Registry.load_yardoc
|
193
193
|
end
|
194
194
|
|
195
|
+
it "should return itself" do
|
196
|
+
Registry.load_yardoc.should == Registry
|
197
|
+
end
|
198
|
+
|
195
199
|
it "should maintain hash key equality on loaded objects" do
|
196
200
|
Registry.clear
|
197
201
|
Registry.load!(File.dirname(__FILE__) + '/serializers/data/serialized_yardoc')
|
@@ -200,4 +204,36 @@ describe YARD::Registry do
|
|
200
204
|
Registry.at('Foo').aliases.has_key?(baz).should == true
|
201
205
|
end
|
202
206
|
end
|
207
|
+
|
208
|
+
['load', 'load_all', 'load!'].each do |meth|
|
209
|
+
describe('.' + meth) do
|
210
|
+
it "should return itself" do
|
211
|
+
Registry.send(meth).should == Registry
|
212
|
+
end
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
describe '.each' do
|
217
|
+
before do
|
218
|
+
YARD.parse_string "def a; end; def b; end; def c; end"
|
219
|
+
end
|
220
|
+
|
221
|
+
after { Registry.clear }
|
222
|
+
|
223
|
+
it "should iterate over .all" do
|
224
|
+
items = []
|
225
|
+
Registry.each {|x| items << x.path }
|
226
|
+
items.sort.should == ['#a', '#b', '#c']
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should include Enumerable and allow for find, select" do
|
230
|
+
Registry.find {|x| x.path == "#a" }.should be_a(CodeObjects::MethodObject)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
|
234
|
+
describe '.instance' do
|
235
|
+
it "should return itself" do
|
236
|
+
Registry.instance.should == Registry
|
237
|
+
end
|
238
|
+
end
|
203
239
|
end
|