yard 0.2.2 → 0.2.3
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.
Potentially problematic release.
This version of yard might be problematic. Click here for more details.
- data/LICENSE +1 -1
- data/README.markdown +200 -0
- data/Rakefile +6 -1
- data/benchmarks/format_args.rb +46 -0
- data/benchmarks/parsing.rb +13 -1
- data/benchmarks/rdoc_vs_yardoc.rb +10 -0
- data/benchmarks/ripper_parser.rb +12 -0
- data/docs/CODE_OBJECTS.markdown +121 -0
- data/docs/FAQ.markdown +34 -0
- data/docs/GENERATORS.markdown +211 -0
- data/docs/GETTING_STARTED.markdown +263 -0
- data/docs/GLOSSARY.markdown +13 -0
- data/docs/HANDLERS.markdown +158 -0
- data/docs/OVERVIEW.markdown +64 -0
- data/docs/PARSER.markdown +180 -0
- data/docs/TAGS.markdown +181 -0
- data/docs/WHATSNEW.markdown +96 -0
- data/docs/images/code-objects-class-diagram.png +0 -0
- data/docs/images/handlers-class-diagram.png +0 -0
- data/docs/images/overview-class-diagram.png +0 -0
- data/docs/images/parser-class-diagram.png +0 -0
- data/docs/images/tags-class-diagram.png +0 -0
- data/lib/yard.rb +4 -1
- data/lib/yard/autoload.rb +79 -31
- data/lib/yard/cli/yard_graph.rb +8 -2
- data/lib/yard/cli/yardoc.rb +61 -8
- data/lib/yard/code_objects/base.rb +78 -135
- data/lib/yard/code_objects/class_object.rb +9 -8
- data/lib/yard/code_objects/constant_object.rb +1 -0
- data/lib/yard/code_objects/extended_method_object.rb +9 -0
- data/lib/yard/code_objects/method_object.rb +18 -5
- data/lib/yard/code_objects/module_object.rb +8 -1
- data/lib/yard/code_objects/namespace_object.rb +25 -16
- data/lib/yard/code_objects/proxy.rb +22 -22
- data/lib/yard/core_ext/file.rb +1 -1
- data/lib/yard/core_ext/string.rb +0 -4
- data/lib/yard/core_ext/symbol_hash.rb +3 -2
- data/lib/yard/docstring.rb +180 -0
- data/lib/yard/generators/base.rb +33 -13
- data/lib/yard/generators/class_generator.rb +4 -2
- data/lib/yard/generators/constants_generator.rb +3 -2
- data/lib/yard/generators/full_doc_generator.rb +76 -9
- data/lib/yard/generators/helpers/base_helper.rb +18 -1
- data/lib/yard/generators/helpers/filter_helper.rb +2 -2
- data/lib/yard/generators/helpers/html_helper.rb +94 -39
- data/lib/yard/generators/helpers/html_syntax_highlight_helper.rb +49 -0
- data/lib/yard/generators/helpers/markup_helper.rb +86 -0
- data/lib/yard/generators/helpers/method_helper.rb +23 -7
- data/lib/yard/generators/method_generator.rb +15 -3
- data/lib/yard/generators/method_listing_generator.rb +3 -3
- data/lib/yard/generators/mixins_generator.rb +8 -2
- data/lib/yard/generators/module_generator.rb +3 -2
- data/lib/yard/generators/overloads_generator.rb +20 -0
- data/lib/yard/generators/quick_doc_generator.rb +3 -9
- data/lib/yard/generators/root_generator.rb +32 -0
- data/lib/yard/generators/source_generator.rb +2 -17
- data/lib/yard/generators/tags_generator.rb +34 -6
- data/lib/yard/generators/uml_generator.rb +16 -6
- data/lib/yard/handlers/base.rb +88 -253
- data/lib/yard/handlers/processor.rb +72 -0
- data/lib/yard/handlers/ruby/alias_handler.rb +38 -0
- data/lib/yard/handlers/ruby/attribute_handler.rb +69 -0
- data/lib/yard/handlers/ruby/base.rb +72 -0
- data/lib/yard/handlers/ruby/class_condition_handler.rb +70 -0
- data/lib/yard/handlers/ruby/class_handler.rb +74 -0
- data/lib/yard/handlers/ruby/class_variable_handler.rb +11 -0
- data/lib/yard/handlers/ruby/constant_handler.rb +12 -0
- data/lib/yard/handlers/ruby/exception_handler.rb +22 -0
- data/lib/yard/handlers/ruby/extend_handler.rb +19 -0
- data/lib/yard/handlers/{alias_handler.rb → ruby/legacy/alias_handler.rb} +3 -4
- data/lib/yard/handlers/{attribute_handler.rb → ruby/legacy/attribute_handler.rb} +2 -2
- data/lib/yard/handlers/ruby/legacy/base.rb +198 -0
- data/lib/yard/handlers/{class_handler.rb → ruby/legacy/class_handler.rb} +18 -6
- data/lib/yard/handlers/{class_variable_handler.rb → ruby/legacy/class_variable_handler.rb} +1 -1
- data/lib/yard/handlers/{constant_handler.rb → ruby/legacy/constant_handler.rb} +2 -2
- data/lib/yard/handlers/{exception_handler.rb → ruby/legacy/exception_handler.rb} +3 -3
- data/lib/yard/handlers/ruby/legacy/extend_handler.rb +18 -0
- data/lib/yard/handlers/ruby/legacy/method_handler.rb +31 -0
- data/lib/yard/handlers/ruby/legacy/mixin_handler.rb +28 -0
- data/lib/yard/handlers/{module_handler.rb → ruby/legacy/module_handler.rb} +1 -1
- data/lib/yard/handlers/{visibility_handler.rb → ruby/legacy/visibility_handler.rb} +1 -1
- data/lib/yard/handlers/{yield_handler.rb → ruby/legacy/yield_handler.rb} +4 -4
- data/lib/yard/handlers/ruby/method_condition_handler.rb +7 -0
- data/lib/yard/handlers/ruby/method_handler.rb +48 -0
- data/lib/yard/handlers/ruby/mixin_handler.rb +25 -0
- data/lib/yard/handlers/ruby/module_handler.rb +9 -0
- data/lib/yard/handlers/ruby/visibility_handler.rb +18 -0
- data/lib/yard/handlers/ruby/yield_handler.rb +28 -0
- data/lib/yard/parser/ruby/ast_node.rb +263 -0
- data/lib/yard/parser/{ruby_lex.rb → ruby/legacy/ruby_lex.rb} +258 -259
- data/lib/yard/parser/{statement.rb → ruby/legacy/statement.rb} +8 -4
- data/lib/yard/parser/ruby/legacy/statement_list.rb +262 -0
- data/lib/yard/parser/{token_list.rb → ruby/legacy/token_list.rb} +1 -1
- data/lib/yard/parser/ruby/ruby_parser.rb +307 -0
- data/lib/yard/parser/source_parser.rb +76 -45
- data/lib/yard/rake/yardoc_task.rb +6 -1
- data/lib/yard/registry.rb +45 -19
- data/lib/yard/serializers/file_system_serializer.rb +8 -3
- data/lib/yard/tags/default_factory.rb +70 -10
- data/lib/yard/tags/default_tag.rb +12 -0
- data/lib/yard/tags/library.rb +65 -26
- data/lib/yard/tags/option_tag.rb +12 -0
- data/lib/yard/tags/overload_tag.rb +62 -0
- data/lib/yard/tags/ref_tag.rb +7 -0
- data/lib/yard/tags/ref_tag_list.rb +27 -0
- data/lib/yard/tags/tag.rb +1 -0
- data/lib/yard/tags/tag_format_error.rb +6 -0
- data/spec/cli/yardoc_spec.rb +43 -0
- data/spec/code_objects/base_spec.rb +56 -68
- data/spec/code_objects/class_object_spec.rb +18 -6
- data/spec/code_objects/constants_spec.rb +2 -0
- data/spec/code_objects/method_object_spec.rb +33 -5
- data/spec/code_objects/module_object_spec.rb +66 -8
- data/spec/code_objects/namespace_object_spec.rb +37 -17
- data/spec/code_objects/proxy_spec.rb +13 -2
- data/spec/core_ext/string_spec.rb +14 -2
- data/spec/core_ext/symbol_hash_spec.rb +9 -3
- data/spec/docstring_spec.rb +139 -0
- data/spec/generators/full_doc_generator_spec.rb +29 -0
- data/spec/generators/helpers/html_helper_spec.rb +74 -0
- data/spec/generators/helpers/markup_helper_spec.rb +95 -0
- data/spec/handlers/alias_handler_spec.rb +16 -3
- data/spec/handlers/attribute_handler_spec.rb +1 -1
- data/spec/handlers/base_spec.rb +15 -141
- data/spec/handlers/class_condition_handler_spec.rb +49 -0
- data/spec/handlers/class_handler_spec.rb +44 -3
- data/spec/handlers/class_variable_handler_spec.rb +1 -1
- data/spec/handlers/constant_handler_spec.rb +1 -1
- data/spec/handlers/examples/alias_handler_001.rb.txt +7 -3
- data/spec/handlers/examples/class_condition_handler_001.rb.txt +61 -0
- data/spec/handlers/examples/class_handler_001.rb.txt +33 -0
- data/spec/handlers/examples/exception_handler_001.rb.txt +1 -1
- data/spec/handlers/examples/extend_handler_001.rb.txt +8 -0
- data/spec/handlers/examples/method_condition_handler_001.rb.txt +10 -0
- data/spec/handlers/examples/method_handler_001.rb.txt +16 -4
- data/spec/handlers/examples/mixin_handler_001.rb.txt +10 -2
- data/spec/handlers/examples/module_handler_001.rb.txt +4 -0
- data/spec/handlers/examples/visibility_handler_001.rb.txt +1 -1
- data/spec/handlers/exception_handler_spec.rb +2 -2
- data/spec/handlers/extend_handler_spec.rb +15 -0
- data/spec/handlers/legacy_base_spec.rb +128 -0
- data/spec/handlers/method_condition_handler_spec.rb +14 -0
- data/spec/handlers/method_handler_spec.rb +38 -5
- data/spec/handlers/mixin_handler_spec.rb +15 -7
- data/spec/handlers/module_handler_spec.rb +5 -1
- data/spec/handlers/processor_spec.rb +19 -0
- data/spec/handlers/ruby/base_spec.rb +90 -0
- data/spec/handlers/ruby/legacy/base_spec.rb +53 -0
- data/spec/handlers/spec_helper.rb +22 -16
- data/spec/handlers/visibility_handler_spec.rb +4 -4
- data/spec/handlers/yield_handler_spec.rb +1 -1
- data/spec/parser/ruby/ast_node_spec.rb +15 -0
- data/spec/parser/ruby/legacy/statement_list_spec.rb +145 -0
- data/spec/parser/{token_list_spec.rb → ruby/legacy/token_list_spec.rb} +4 -4
- data/spec/parser/source_parser_spec.rb +0 -15
- data/spec/rake/yardoc_task_spec.rb +48 -0
- data/spec/registry_spec.rb +28 -2
- data/spec/serializers/file_system_serializer_spec.rb +7 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/tags/default_factory_spec.rb +135 -0
- data/spec/tags/default_tag_spec.rb +11 -0
- data/spec/tags/overload_tag_spec.rb +35 -0
- data/spec/tags/ref_tag_list_spec.rb +53 -0
- data/templates/default/attributes/html/header.erb +17 -5
- data/templates/default/attributes/text/header.erb +1 -1
- data/templates/default/fulldoc/html/all_files.erb +19 -0
- data/templates/default/fulldoc/html/all_methods.erb +8 -7
- data/templates/default/fulldoc/html/all_namespaces.erb +4 -1
- data/templates/default/fulldoc/html/app.js +1 -1
- data/templates/default/fulldoc/html/{readme.erb → file.erb} +2 -2
- data/templates/default/fulldoc/html/header.erb +1 -1
- data/templates/default/fulldoc/html/index.erb +4 -3
- data/templates/default/fulldoc/html/style.css +13 -3
- data/templates/default/fulldoc/html/syntax_highlight.css +8 -5
- data/templates/default/method/text/header.erb +1 -0
- data/templates/default/method/text/title.erb +1 -0
- data/templates/default/methodsignature/html/main.erb +10 -8
- data/templates/default/methodsignature/text/main.erb +4 -1
- data/templates/default/methodsummary/html/summary.erb +8 -4
- data/templates/default/methodsummary/text/summary.erb +4 -1
- data/templates/default/mixins/html/header.erb +3 -3
- data/templates/default/overloads/html/header.erb +8 -0
- data/templates/default/overloads/text/header.erb +8 -0
- data/templates/default/root/html/header.erb +4 -0
- data/templates/default/tags/html/example.erb +20 -0
- data/templates/default/tags/html/option.erb +27 -0
- data/templates/default/tags/html/param.erb +21 -0
- data/templates/default/tags/html/tags.erb +4 -1
- data/templates/default/tags/html/todo.erb +8 -0
- data/templates/default/tags/text/example.erb +14 -0
- data/templates/default/tags/text/header.erb +3 -3
- data/templates/default/tags/text/option.erb +5 -0
- data/templates/default/tags/text/param.erb +9 -0
- data/templates/default/uml/dot/dependencies.erb +1 -1
- data/templates/default/uml/dot/info.erb +1 -1
- data/templates/default/uml/dot/superclasses.erb +2 -2
- data/templates/javadoc/methodsummary/html/summary.erb +2 -2
- data/templates/javadoc/mixins/html/header.erb +3 -3
- metadata +108 -139
- data/README +0 -211
- data/lib/yard/handlers/method_handler.rb +0 -27
- data/lib/yard/handlers/mixin_handler.rb +0 -16
- data/lib/yard/parser/statement_list.rb +0 -167
- data/lib/yard/tags/merbdoc_factory.rb +0 -47
@@ -5,12 +5,16 @@ describe YARD::CodeObjects::ClassObject do
|
|
5
5
|
Registry.clear
|
6
6
|
@mixin = ModuleObject.new(:root, :SomeMixin)
|
7
7
|
@mixin2 = ModuleObject.new(:root, :SomeMixin2)
|
8
|
+
@mixin3 = ModuleObject.new(:root, :SomeMixin3)
|
9
|
+
@mixin4 = ModuleObject.new(:root, :SomeMixin4)
|
10
|
+
@mixin2.instance_mixins << @mixin3
|
8
11
|
@superyard = ClassObject.new(:root, :SuperYard)
|
9
12
|
@superyard.superclass = P("String")
|
10
|
-
@superyard.
|
13
|
+
@superyard.instance_mixins << @mixin2
|
14
|
+
@superyard.class_mixins << @mixin4
|
11
15
|
@yard = ClassObject.new(:root, :YARD)
|
12
16
|
@yard.superclass = @superyard
|
13
|
-
@yard.
|
17
|
+
@yard.instance_mixins << @mixin
|
14
18
|
end
|
15
19
|
|
16
20
|
it "should show the proper inheritance tree" do
|
@@ -18,7 +22,7 @@ describe YARD::CodeObjects::ClassObject do
|
|
18
22
|
end
|
19
23
|
|
20
24
|
it "should show proper inheritance tree when mixins are included" do
|
21
|
-
@yard.inheritance_tree(true).should == [@yard, @mixin, @superyard, P(:String)]
|
25
|
+
@yard.inheritance_tree(true).should == [@yard, @mixin, @superyard, @mixin2, @mixin3, P(:String)]
|
22
26
|
end
|
23
27
|
end
|
24
28
|
|
@@ -53,7 +57,7 @@ describe YARD::CodeObjects::ClassObject, "#meths / #inherited_meths" do
|
|
53
57
|
meths.should include(P("YARD#mymethod"))
|
54
58
|
meths.should include(P("SuperYard#foo"))
|
55
59
|
meths.should include(P("SuperYard#foo2"))
|
56
|
-
meths.should include(P("SuperYard
|
60
|
+
meths.should include(P("SuperYard.bar"))
|
57
61
|
end
|
58
62
|
|
59
63
|
it "should allow :inherited to be set to false" do
|
@@ -61,7 +65,7 @@ describe YARD::CodeObjects::ClassObject, "#meths / #inherited_meths" do
|
|
61
65
|
meths.should include(P("YARD#mymethod"))
|
62
66
|
meths.should_not include(P("SuperYard#foo"))
|
63
67
|
meths.should_not include(P("SuperYard#foo2"))
|
64
|
-
meths.should_not include(P("SuperYard
|
68
|
+
meths.should_not include(P("SuperYard.bar"))
|
65
69
|
end
|
66
70
|
|
67
71
|
it "should not show overridden methods" do
|
@@ -74,7 +78,7 @@ describe YARD::CodeObjects::ClassObject, "#meths / #inherited_meths" do
|
|
74
78
|
meths.should_not include(P("YARD#mymethod"))
|
75
79
|
meths.should include(P("SuperYard#foo"))
|
76
80
|
meths.should include(P("SuperYard#foo2"))
|
77
|
-
meths.should include(P("SuperYard
|
81
|
+
meths.should include(P("SuperYard.bar"))
|
78
82
|
end
|
79
83
|
|
80
84
|
it "should not show inherited methods overridden by other subclasses" do
|
@@ -172,5 +176,13 @@ describe YARD::CodeObjects::ClassObject, "#constants / #inherited_constants" do
|
|
172
176
|
o.superclass = o3
|
173
177
|
o.is_exception?.should == true
|
174
178
|
end
|
179
|
+
|
180
|
+
it "should not raise ArgumentError if superclass is proxy in different namespace" do
|
181
|
+
lambda do
|
182
|
+
o = ClassObject.new(:root, :X) do |o|
|
183
|
+
o.superclass = P('OTHER::X')
|
184
|
+
end
|
185
|
+
end.should_not raise_error(ArgumentError)
|
186
|
+
end
|
175
187
|
end
|
176
188
|
|
@@ -50,6 +50,7 @@ end
|
|
50
50
|
describe YARD::CodeObjects, "BUILTIN_CLASSES" do
|
51
51
|
it "should include all base classes" do
|
52
52
|
YARD::CodeObjects::BUILTIN_CLASSES.each do |name|
|
53
|
+
next if RUBY19 && ["MatchingData"].include?(name)
|
53
54
|
eval(name).should be_instance_of(Class)
|
54
55
|
end
|
55
56
|
end
|
@@ -73,6 +74,7 @@ end
|
|
73
74
|
describe YARD::CodeObjects, "BUILTIN_MODULES" do
|
74
75
|
it "should include all base modules" do
|
75
76
|
YARD::CodeObjects::BUILTIN_MODULES.each do |name|
|
77
|
+
next if RUBY19 && ["Precision"].include?(name)
|
76
78
|
eval(name).should be_instance_of(Module)
|
77
79
|
end
|
78
80
|
end
|
@@ -16,15 +16,43 @@ describe YARD::CodeObjects::MethodObject do
|
|
16
16
|
meth.path.should == "YARD#testing"
|
17
17
|
end
|
18
18
|
|
19
|
-
it "should have a path of YARD
|
19
|
+
it "should have a path of YARD.testing for a class method in YARD" do
|
20
20
|
meth = MethodObject.new(@yard, :testing, :class)
|
21
|
-
meth.path.should == "YARD
|
21
|
+
meth.path.should == "YARD.testing"
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have a path of ::testing (note the ::) for a class method added to root namespace" do
|
25
|
+
meth = MethodObject.new(:root, :testing, :class)
|
26
|
+
meth.path.should == "::testing"
|
22
27
|
end
|
23
28
|
|
24
29
|
it "should exist in the registry after successful creation" do
|
25
30
|
obj = MethodObject.new(@yard, :something, :class)
|
26
|
-
Registry.at("YARD
|
31
|
+
Registry.at("YARD.something").should_not be_nil
|
32
|
+
Registry.at("YARD#something").should be_nil
|
33
|
+
Registry.at("YARD::something").should be_nil
|
27
34
|
obj = MethodObject.new(@yard, :somethingelse)
|
28
|
-
Registry.at("YARD#somethingelse").should_not
|
35
|
+
Registry.at("YARD#somethingelse").should_not be_nil
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should allow #scope to be changed after creation" do
|
39
|
+
obj = MethodObject.new(@yard, :something, :class)
|
40
|
+
Registry.at("YARD.something").should_not be_nil
|
41
|
+
obj.scope = :instance
|
42
|
+
Registry.at("YARD.something").should be_nil
|
43
|
+
Registry.at("YARD#something").should_not be_nil
|
44
|
+
end
|
45
|
+
|
46
|
+
describe '#name' do
|
47
|
+
it "should show a prefix for an instance method when prefix=true" do
|
48
|
+
obj = MethodObject.new(nil, :something)
|
49
|
+
obj.name(true).should == :"#something"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "should never show a prefix for a class method" do
|
53
|
+
obj = MethodObject.new(nil, :something, :class)
|
54
|
+
obj.name.should == :"something"
|
55
|
+
obj.name(true).should == :"something"
|
56
|
+
end
|
29
57
|
end
|
30
|
-
end
|
58
|
+
end
|
@@ -10,7 +10,7 @@ describe YARD::CodeObjects::ModuleObject, "#meths" do
|
|
10
10
|
# YARD#foo:method
|
11
11
|
# YARD#foo2:method
|
12
12
|
# YARD#xyz:method
|
13
|
-
# YARD
|
13
|
+
# YARD.bar:method
|
14
14
|
# SomeMod#mixmethod
|
15
15
|
# SomeMod#xyz:method
|
16
16
|
#
|
@@ -26,48 +26,106 @@ describe YARD::CodeObjects::ModuleObject, "#meths" do
|
|
26
26
|
@other = ModuleObject.new(:root, :SomeMod)
|
27
27
|
MethodObject.new(@other, :mixmethod)
|
28
28
|
MethodObject.new(@other, :xyz)
|
29
|
+
MethodObject.new(@other, :baz, :class)
|
30
|
+
@another = ModuleObject.new(:root, :AnotherMod)
|
31
|
+
MethodObject.new(@another, :fizz)
|
32
|
+
MethodObject.new(@another, :bar)
|
33
|
+
MethodObject.new(@another, :fazz, :class)
|
29
34
|
|
30
|
-
@yard.
|
35
|
+
@yard.instance_mixins << @other
|
36
|
+
@yard.class_mixins << @another
|
31
37
|
end
|
32
38
|
|
33
39
|
it "should list all methods (including mixin methods) via #meths" do
|
34
40
|
meths = @yard.meths
|
35
41
|
meths.should include(P("YARD#foo"))
|
36
42
|
meths.should include(P("YARD#foo2"))
|
37
|
-
meths.should include(P("YARD
|
43
|
+
meths.should include(P("YARD.bar"))
|
38
44
|
meths.should include(P("SomeMod#mixmethod"))
|
45
|
+
meths.should include(P("AnotherMod#fizz"))
|
39
46
|
end
|
40
47
|
|
41
48
|
it "should allow :visibility to be set" do
|
42
49
|
meths = @yard.meths(:visibility => :public)
|
43
|
-
meths.should_not include(P("YARD
|
50
|
+
meths.should_not include(P("YARD.bar"))
|
44
51
|
meths = @yard.meths(:visibility => [:public, :private])
|
45
52
|
meths.should include(P("YARD#foo"))
|
46
|
-
meths.should include(P("YARD
|
53
|
+
meths.should include(P("YARD.bar"))
|
47
54
|
meths.should_not include(P("YARD#foo2"))
|
48
55
|
end
|
49
56
|
|
50
|
-
it "should
|
57
|
+
it "should only display class methods for :scope => :class" do
|
51
58
|
meths = @yard.meths(:scope => :class)
|
52
59
|
meths.should_not include(P("YARD#foo"))
|
53
60
|
meths.should_not include(P("YARD#foo2"))
|
54
61
|
meths.should_not include(P("SomeMod#mixmethod"))
|
62
|
+
meths.should_not include(P("SomeMod.baz"))
|
63
|
+
meths.should_not include(P("AnotherMod#fazz"))
|
64
|
+
meths.should include(P("YARD.bar"))
|
65
|
+
meths.should include(P("AnotherMod#fizz"))
|
66
|
+
end
|
67
|
+
|
68
|
+
it "should only display instance methods for :scope => :class" do
|
69
|
+
meths = @yard.meths(:scope => :instance)
|
70
|
+
meths.should include(P("YARD#foo"))
|
71
|
+
meths.should include(P("YARD#foo2"))
|
72
|
+
meths.should include(P("SomeMod#mixmethod"))
|
73
|
+
meths.should_not include(P("YARD.bar"))
|
74
|
+
meths.should_not include(P("AnotherMod#fizz"))
|
55
75
|
end
|
56
76
|
|
57
77
|
it "should allow :included to be set" do
|
58
78
|
meths = @yard.meths(:included => false)
|
59
79
|
meths.should_not include(P("SomeMod#mixmethod"))
|
80
|
+
meths.should_not include(P("AnotherMod#fizz"))
|
60
81
|
meths.should include(P("YARD#foo"))
|
61
82
|
meths.should include(P("YARD#foo2"))
|
62
|
-
meths.should include(P("YARD
|
83
|
+
meths.should include(P("YARD.bar"))
|
63
84
|
end
|
64
85
|
|
65
86
|
it "should choose the method defined in the class over an included module" do
|
66
87
|
meths = @yard.meths
|
67
88
|
meths.should_not include(P("SomeMod#xyz"))
|
68
89
|
meths.should include(P("YARD#xyz"))
|
90
|
+
meths.should_not include(P("AnotherMod#bar"))
|
91
|
+
meths.should include(P("YARD.bar"))
|
69
92
|
|
70
93
|
meths = @other.meths
|
71
94
|
meths.should include(P("SomeMod#xyz"))
|
95
|
+
|
96
|
+
meths = @another.meths
|
97
|
+
meths.should include(P("AnotherMod#bar"))
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
describe YARD::CodeObjects::ModuleObject, "#inheritance_tree" do
|
102
|
+
before do
|
103
|
+
Registry.clear
|
104
|
+
|
105
|
+
@mod1 = ModuleObject.new(:root, :Mod1)
|
106
|
+
@mod2 = ModuleObject.new(:root, :Mod2)
|
107
|
+
@mod3 = ModuleObject.new(:root, :Mod3)
|
108
|
+
@mod4 = ModuleObject.new(:root, :Mod4)
|
109
|
+
@mod5 = ModuleObject.new(:root, :Mod5)
|
110
|
+
|
111
|
+
@mod1.instance_mixins << @mod2
|
112
|
+
@mod2.instance_mixins << @mod3
|
113
|
+
@mod1.instance_mixins << @mod4
|
114
|
+
|
115
|
+
@proxy = P(:SomeProxyClass)
|
116
|
+
@mod5.instance_mixins << @proxy
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should show only itself for an inheritance tree without included modules" do
|
120
|
+
@mod1.inheritance_tree.should == [@mod1]
|
121
|
+
end
|
122
|
+
|
123
|
+
it "should show proper inheritance three when modules are included" do
|
124
|
+
@mod1.inheritance_tree(true).should == [@mod1, @mod2, @mod3, @mod4]
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should not list inheritance tree of proxy objects in inheritance tree" do
|
128
|
+
@proxy.should_not_receive(:inheritance_tree)
|
129
|
+
@mod5.instance_mixins.should == [@proxy]
|
72
130
|
end
|
73
|
-
end
|
131
|
+
end
|
@@ -24,25 +24,39 @@ describe YARD::CodeObjects::NamespaceObject do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should not list included methods that are already defined in the namespace using #meths" do
|
27
|
-
a = ModuleObject.new(nil, :
|
27
|
+
a = ModuleObject.new(nil, :Mod1)
|
28
28
|
ameth = MethodObject.new(a, :testing)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
29
|
+
b = ModuleObject.new(nil, :Mod2)
|
30
|
+
bmeth = MethodObject.new(b, :foo)
|
31
|
+
c = NamespaceObject.new(nil, :YARD)
|
32
|
+
cmeth = MethodObject.new(c, :testing)
|
33
|
+
cmeth2 = MethodObject.new(c, :foo)
|
34
|
+
c.instance_mixins << a
|
35
|
+
c.class_mixins << b
|
34
36
|
|
35
|
-
meths =
|
37
|
+
meths = c.meths
|
36
38
|
meths.should include(bmeth)
|
37
|
-
meths.should include(
|
38
|
-
meths.should include(
|
39
|
+
meths.should include(cmeth)
|
40
|
+
meths.should include(cmeth2)
|
39
41
|
meths.should_not include(ameth)
|
40
42
|
|
41
|
-
meths =
|
42
|
-
meths.should include(
|
43
|
+
meths = c.included_meths
|
44
|
+
meths.should include(bmeth)
|
43
45
|
meths.should_not include(ameth)
|
44
|
-
meths.should_not include(
|
45
|
-
meths.should_not include(
|
46
|
+
meths.should_not include(cmeth)
|
47
|
+
meths.should_not include(cmeth2)
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should list included_meths mixed into the class scope as class methods" do
|
51
|
+
b = ModuleObject.new(nil, :Mod2)
|
52
|
+
bmeth = MethodObject.new(b, :foo)
|
53
|
+
bmeth2 = MethodObject.new(b, :foo2)
|
54
|
+
c = NamespaceObject.new(nil, :YARD)
|
55
|
+
c.class_mixins << b
|
56
|
+
|
57
|
+
[bmeth, bmeth2].each {|o| o.scope.should == :instance }
|
58
|
+
meths = c.included_meths(:scope => :class)
|
59
|
+
meths.each {|o| o.scope.should == :class }
|
46
60
|
end
|
47
61
|
|
48
62
|
it "should not list methods overridden by another included module" do
|
@@ -51,12 +65,18 @@ describe YARD::CodeObjects::NamespaceObject do
|
|
51
65
|
b = ModuleObject.new(nil, :Mod2)
|
52
66
|
bmeth = MethodObject.new(b, :testing)
|
53
67
|
c = NamespaceObject.new(nil, :YARD)
|
54
|
-
c.
|
55
|
-
c.
|
68
|
+
c.instance_mixins << a
|
69
|
+
c.instance_mixins << b
|
70
|
+
c.class_mixins << b
|
71
|
+
c.class_mixins << a
|
56
72
|
|
57
|
-
meths = c.included_meths
|
73
|
+
meths = c.included_meths(:scope => :instance)
|
58
74
|
meths.should_not include(ameth)
|
59
75
|
meths.should include(bmeth)
|
76
|
+
|
77
|
+
meths = c.included_meths(:scope => :class)
|
78
|
+
meths.should include(ameth)
|
79
|
+
meths.should_not include(bmeth)
|
60
80
|
end
|
61
81
|
|
62
82
|
it "should list class attributes using #class_attributes" do
|
@@ -126,4 +146,4 @@ describe YARD::CodeObjects::NamespaceObject, '#constants/#included_constants' do
|
|
126
146
|
consts.should include(P('B::CONST2'))
|
127
147
|
consts.should_not include(P('A::CONST2'))
|
128
148
|
end
|
129
|
-
end
|
149
|
+
end
|
@@ -28,7 +28,7 @@ describe YARD::CodeObjects::Proxy do
|
|
28
28
|
it "should return the object if it's an included Module" do
|
29
29
|
yardobj = ModuleObject.new(:root, :YARD)
|
30
30
|
pathobj = ClassObject.new(:root, :TestClass)
|
31
|
-
pathobj.
|
31
|
+
pathobj.instance_mixins << yardobj
|
32
32
|
P(P(nil, :TestClass), :YARD).should be_instance_of(ModuleObject)
|
33
33
|
end
|
34
34
|
|
@@ -37,6 +37,12 @@ describe YARD::CodeObjects::Proxy do
|
|
37
37
|
yardobj = ModuleObject.new(:root, :YARD)
|
38
38
|
P(:YARD).respond_to?(:children).should == true
|
39
39
|
P(:NOTYARD).respond_to?(:children).should == false
|
40
|
+
|
41
|
+
private_method = P(:instantiated).private_methods.first
|
42
|
+
P(:YARD).respond_to?(private_method).should == false
|
43
|
+
P(:YARD).respond_to?(private_method, true).should == true
|
44
|
+
P(:NOTYARD).respond_to?(private_method).should == false
|
45
|
+
P(:NOTYARD).respond_to?(private_method, true).should == true
|
40
46
|
end
|
41
47
|
|
42
48
|
it "should make itself obvious that it's a proxy" do
|
@@ -77,4 +83,9 @@ describe YARD::CodeObjects::Proxy do
|
|
77
83
|
P("InvalidClass").type = :class
|
78
84
|
P("InvalidClass").type.should == :class
|
79
85
|
end
|
80
|
-
|
86
|
+
|
87
|
+
it "should never equal Registry.root" do
|
88
|
+
P("MYPROXY").should_not == Registry.root
|
89
|
+
P("X::A").should_not == Registry.root
|
90
|
+
end
|
91
|
+
end
|
@@ -1,4 +1,16 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
|
-
described_in_docs String, '#camelcase'
|
4
|
-
described_in_docs String, '#underscore'
|
3
|
+
#described_in_docs String, '#camelcase'
|
4
|
+
#described_in_docs String, '#underscore'
|
5
|
+
|
6
|
+
describe String, '#camelcase' do
|
7
|
+
it 'should turn HelloWorld into hello_world' do
|
8
|
+
"HelloWorld".underscore.should == "hello_world"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe String, '#underscore' do
|
13
|
+
it 'should turn hello_world into HelloWorld' do
|
14
|
+
"hello_world".camelcase.should == "HelloWorld"
|
15
|
+
end
|
16
|
+
end
|
@@ -55,13 +55,19 @@ describe SymbolHash do
|
|
55
55
|
h['test'].should == [1,2,3]
|
56
56
|
end
|
57
57
|
|
58
|
-
it "should support symbolization using #update or #merge" do
|
58
|
+
it "should support symbolization using #update or #merge!" do
|
59
59
|
h = SymbolHash.new
|
60
60
|
h.update('test' => 'value')
|
61
61
|
h[:test].should == :value
|
62
|
-
h.merge('test' => 'value2')
|
62
|
+
h.merge!('test' => 'value2')
|
63
63
|
h[:test].should == :value2
|
64
64
|
end
|
65
|
+
|
66
|
+
it "should support symbolization non-destructively using #merge" do
|
67
|
+
h = SymbolHash.new
|
68
|
+
h.merge('test' => 'value')[:test].should == :value
|
69
|
+
h.should == SymbolHash.new
|
70
|
+
end
|
65
71
|
|
66
72
|
it "should support #initializing of a hash" do
|
67
73
|
h = SymbolHash[:test => 1]
|
@@ -77,4 +83,4 @@ describe SymbolHash do
|
|
77
83
|
opts.keys.should == [:default]
|
78
84
|
opts[:default].should == 1
|
79
85
|
end
|
80
|
-
end
|
86
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe YARD::Docstring do
|
4
|
+
before { YARD::Registry.clear }
|
5
|
+
|
6
|
+
it "should parse comments into tags" do
|
7
|
+
doc = Docstring.new(<<-eof)
|
8
|
+
@param name Hello world
|
9
|
+
how are you?
|
10
|
+
@param name2
|
11
|
+
this is a new line
|
12
|
+
@param name3 and this
|
13
|
+
is a new paragraph:
|
14
|
+
|
15
|
+
right here.
|
16
|
+
eof
|
17
|
+
doc.tags("param").each do |tag|
|
18
|
+
if tag.name == "name"
|
19
|
+
tag.text.should == "Hello world how are you?"
|
20
|
+
elsif tag.name == "name2"
|
21
|
+
tag.text.should == "this is a new line"
|
22
|
+
elsif tag.name == "name3"
|
23
|
+
tag.text.should == "and this is a new paragraph:\n\nright here."
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should handle empty docstrings with #summary" do
|
29
|
+
o1 = Docstring.new
|
30
|
+
o1.summary.should == ""
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should return the first sentence with #summary" do
|
34
|
+
o = Docstring.new("DOCSTRING. Another sentence")
|
35
|
+
o.summary.should == "DOCSTRING."
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should return the first paragraph with #summary" do
|
39
|
+
o = Docstring.new("DOCSTRING, and other stuff\n\nAnother sentence.")
|
40
|
+
o.summary.should == "DOCSTRING, and other stuff."
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should return proper summary when docstring is changed" do
|
44
|
+
o = Docstring.new "DOCSTRING, and other stuff\n\nAnother sentence."
|
45
|
+
o.summary.should == "DOCSTRING, and other stuff."
|
46
|
+
o = Docstring.new "DOCSTRING."
|
47
|
+
o.summary.should == "DOCSTRING."
|
48
|
+
end
|
49
|
+
|
50
|
+
it "should not double the ending period in docstring.summary" do
|
51
|
+
o = Docstring.new("Returns a list of tags specified by +name+ or all tags if +name+ is not specified.\n\nTest")
|
52
|
+
o.summary.should == "Returns a list of tags specified by +name+ or all tags if +name+ is not specified."
|
53
|
+
|
54
|
+
doc = Docstring.new(<<-eof)
|
55
|
+
|
56
|
+
Returns a list of tags specified by +name+ or all tags if +name+ is not specified.
|
57
|
+
|
58
|
+
@param name the tag name to return data for, or nil for all tags
|
59
|
+
@return [Array<Tags::Tag>] the list of tags by the specified tag name
|
60
|
+
eof
|
61
|
+
doc.summary.should == "Returns a list of tags specified by +name+ or all tags if +name+ is not specified."
|
62
|
+
end
|
63
|
+
|
64
|
+
it "should parse reference tag into ref_tags" do
|
65
|
+
doc = Docstring.new("@return (see Foo#bar)")
|
66
|
+
doc.ref_tags.size.should == 1
|
67
|
+
doc.ref_tags.first.owner.should == P("Foo#bar")
|
68
|
+
doc.ref_tags.first.tag_name.should == "return"
|
69
|
+
doc.ref_tags.first.name.should be_nil
|
70
|
+
end
|
71
|
+
|
72
|
+
it "should parse named reference tag into ref_tags" do
|
73
|
+
doc = Docstring.new("@param blah \n (see Foo#bar )")
|
74
|
+
doc.ref_tags.size.should == 1
|
75
|
+
doc.ref_tags.first.owner.should == P("Foo#bar")
|
76
|
+
doc.ref_tags.first.tag_name.should == "param"
|
77
|
+
doc.ref_tags.first.name.should == "blah"
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should fail to parse named reference tag into ref_tags" do
|
81
|
+
doc = Docstring.new("@param blah THIS_BREAKS_REFTAG (see Foo#bar)")
|
82
|
+
doc.ref_tags.size.should == 0
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should return all valid reference tags along with #tags" do
|
86
|
+
o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
|
87
|
+
o.docstring.add_tag Tags::Tag.new('return', 'testing')
|
88
|
+
doc = Docstring.new("@return (see Foo#bar)")
|
89
|
+
tags = doc.tags
|
90
|
+
tags.size.should == 1
|
91
|
+
tags.first.text.should == 'testing'
|
92
|
+
tags.first.should be_kind_of(Tags::RefTag)
|
93
|
+
tags.first.owner.should == o
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should return all valid named reference tags along with #tags(name)" do
|
97
|
+
o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
|
98
|
+
o.docstring.add_tag Tags::Tag.new('param', 'testing', nil, '*args')
|
99
|
+
o.docstring.add_tag Tags::Tag.new('param', 'NOTtesting', nil, 'notargs')
|
100
|
+
doc = Docstring.new("@param *args (see Foo#bar)")
|
101
|
+
tags = doc.tags('param')
|
102
|
+
tags.size.should == 1
|
103
|
+
tags.first.text.should == 'testing'
|
104
|
+
tags.first.should be_kind_of(Tags::RefTag)
|
105
|
+
tags.first.owner.should == o
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should ignore invalid reference tags" do
|
109
|
+
doc = Docstring.new("@param *args (see INVALID::TAG#tag)")
|
110
|
+
tags = doc.tags('param')
|
111
|
+
tags.size.should == 0
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should be blank and empty if it has no content and no tags" do
|
115
|
+
Docstring.new.should be_blank
|
116
|
+
Docstring.new.should be_empty
|
117
|
+
end
|
118
|
+
|
119
|
+
it "shouldn't be empty or blank if it has content" do
|
120
|
+
d = Docstring.new("foo bar")
|
121
|
+
d.should_not be_empty
|
122
|
+
d.should_not be_blank
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should be empty but not blank if it has tags" do
|
126
|
+
d = Docstring.new("@param foo")
|
127
|
+
d.should be_empty
|
128
|
+
d.should_not be_blank
|
129
|
+
end
|
130
|
+
|
131
|
+
it "should be empty but not blank if it has ref tags" do
|
132
|
+
o = CodeObjects::MethodObject.new(:root, 'Foo#bar')
|
133
|
+
o.docstring.add_tag Tags::Tag.new('return', 'testing')
|
134
|
+
d = Docstring.new("@return (see Foo#bar)")
|
135
|
+
d.should be_empty
|
136
|
+
d.should_not be_blank
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|