yard 0.2.1 → 0.2.2
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/{LICENSE.txt → LICENSE} +1 -1
- data/README +211 -0
- data/Rakefile +31 -0
- data/benchmarks/builtins_vs_eval.rb +23 -0
- data/benchmarks/erb_vs_erubis.rb +53 -0
- data/benchmarks/generation.rb +37 -0
- data/benchmarks/parsing.rb +33 -0
- data/bin/view_generator +17 -0
- data/bin/yard-graph +4 -0
- data/bin/yardoc +1 -93
- data/bin/yri +12 -3
- data/lib/yard.rb +10 -5
- data/lib/yard/autoload.rb +116 -0
- data/lib/yard/cli/yard_graph.rb +86 -0
- data/lib/yard/cli/yardoc.rb +131 -0
- data/lib/yard/code_objects/base.rb +321 -0
- data/lib/yard/code_objects/class_object.rb +89 -0
- data/lib/yard/code_objects/class_variable_object.rb +4 -0
- data/lib/yard/code_objects/constant_object.rb +4 -0
- data/lib/yard/code_objects/method_object.rb +51 -0
- data/lib/yard/code_objects/module_object.rb +4 -0
- data/lib/yard/code_objects/namespace_object.rb +88 -0
- data/lib/yard/code_objects/proxy.rb +183 -0
- data/lib/yard/code_objects/root_object.rb +8 -0
- data/lib/yard/core_ext/file.rb +26 -0
- data/lib/yard/core_ext/logger.rb +5 -0
- data/lib/yard/core_ext/module.rb +9 -0
- data/lib/yard/core_ext/string.rb +13 -0
- data/lib/yard/core_ext/symbol_hash.rb +24 -0
- data/lib/yard/generators/attributes_generator.rb +22 -0
- data/lib/yard/generators/base.rb +285 -0
- data/lib/yard/generators/class_generator.rb +25 -0
- data/lib/yard/generators/constants_generator.rb +73 -0
- data/lib/yard/generators/constructor_generator.rb +25 -0
- data/lib/yard/generators/deprecated_generator.rb +15 -0
- data/lib/yard/generators/docstring_generator.rb +15 -0
- data/lib/yard/generators/full_doc_generator.rb +59 -0
- data/lib/yard/generators/helpers/base_helper.rb +52 -0
- data/lib/yard/generators/helpers/filter_helper.rb +21 -0
- data/lib/yard/generators/helpers/html_helper.rb +137 -0
- data/lib/yard/generators/helpers/method_helper.rb +27 -0
- data/lib/yard/generators/helpers/uml_helper.rb +16 -0
- data/lib/yard/generators/inheritance_generator.rb +16 -0
- data/lib/yard/generators/method_details_generator.rb +18 -0
- data/lib/yard/generators/method_generator.rb +31 -0
- data/lib/yard/generators/method_listing_generator.rb +105 -0
- data/lib/yard/generators/method_missing_generator.rb +25 -0
- data/lib/yard/generators/method_signature_generator.rb +19 -0
- data/lib/yard/generators/method_summary_generator.rb +21 -0
- data/lib/yard/generators/mixins_generator.rb +15 -0
- data/lib/yard/generators/module_generator.rb +22 -0
- data/lib/yard/generators/quick_doc_generator.rb +31 -0
- data/lib/yard/generators/source_generator.rb +26 -0
- data/lib/yard/generators/tags_generator.rb +50 -0
- data/lib/yard/generators/uml_generator.rb +92 -0
- data/lib/yard/generators/visibility_group_generator.rb +26 -0
- data/lib/yard/handlers/alias_handler.rb +32 -0
- data/lib/yard/handlers/attribute_handler.rb +54 -0
- data/lib/yard/handlers/base.rb +509 -0
- data/lib/yard/handlers/class_handler.rb +44 -0
- data/lib/yard/handlers/class_variable_handler.rb +13 -0
- data/lib/yard/handlers/constant_handler.rb +13 -0
- data/lib/yard/handlers/exception_handler.rb +12 -0
- data/lib/yard/handlers/method_handler.rb +27 -0
- data/lib/yard/handlers/mixin_handler.rb +16 -0
- data/lib/yard/handlers/module_handler.rb +9 -0
- data/lib/yard/handlers/visibility_handler.rb +14 -0
- data/lib/yard/handlers/yield_handler.rb +26 -0
- data/lib/yard/logging.rb +27 -0
- data/lib/yard/parser/ruby_lex.rb +1344 -0
- data/lib/yard/parser/source_parser.rb +109 -0
- data/lib/yard/parser/statement.rb +36 -0
- data/lib/yard/parser/statement_list.rb +167 -0
- data/lib/yard/parser/token_list.rb +58 -0
- data/lib/yard/rake/yardoc_task.rb +30 -0
- data/lib/yard/registry.rb +136 -0
- data/lib/yard/serializers/base.rb +16 -0
- data/lib/yard/serializers/file_system_serializer.rb +48 -0
- data/lib/yard/serializers/process_serializer.rb +14 -0
- data/lib/yard/serializers/stdout_serializer.rb +21 -0
- data/lib/yard/tags/default_factory.rb +98 -0
- data/lib/yard/tags/library.rb +109 -0
- data/lib/yard/tags/merbdoc_factory.rb +47 -0
- data/lib/yard/tags/tag.rb +35 -0
- data/spec/code_objects/base_spec.rb +219 -0
- data/spec/code_objects/class_object_spec.rb +176 -0
- data/spec/code_objects/code_object_list_spec.rb +33 -0
- data/spec/code_objects/constants_spec.rb +79 -0
- data/spec/code_objects/method_object_spec.rb +30 -0
- data/spec/code_objects/module_object_spec.rb +73 -0
- data/spec/code_objects/namespace_object_spec.rb +129 -0
- data/spec/code_objects/proxy_spec.rb +80 -0
- data/spec/code_objects/spec_helper.rb +3 -0
- data/spec/core_ext/file_spec.rb +20 -0
- data/spec/core_ext/string_spec.rb +4 -0
- data/spec/core_ext/symbol_hash_spec.rb +80 -0
- data/spec/generators/base_spec.rb +64 -0
- data/spec/generators/helpers/base_helper_spec.rb +15 -0
- data/spec/generators/helpers/html_helper_spec.rb +56 -0
- data/spec/generators/quick_doc_generator_spec.rb +13 -0
- data/spec/handlers/alias_handler_spec.rb +50 -0
- data/spec/handlers/attribute_handler_spec.rb +78 -0
- data/spec/handlers/base_spec.rb +165 -0
- data/spec/handlers/class_handler_spec.rb +68 -0
- data/spec/handlers/class_variable_handler_spec.rb +9 -0
- data/spec/handlers/constant_handler_spec.rb +13 -0
- data/spec/handlers/examples/alias_handler_001.rb.txt +24 -0
- data/spec/handlers/examples/attribute_handler_001.rb.txt +19 -0
- data/spec/handlers/examples/class_handler_001.rb.txt +39 -0
- data/spec/handlers/examples/class_variable_handler_001.rb.txt +9 -0
- data/spec/handlers/examples/constant_handler_001.rb.txt +10 -0
- data/spec/handlers/examples/exception_handler_001.rb.txt +42 -0
- data/spec/handlers/examples/method_handler_001.rb.txt +35 -0
- data/spec/handlers/examples/mixin_handler_001.rb.txt +12 -0
- data/spec/handlers/examples/module_handler_001.rb.txt +16 -0
- data/spec/handlers/examples/visibility_handler_001.rb.txt +20 -0
- data/spec/handlers/examples/yield_handler_001.rb.txt +55 -0
- data/spec/handlers/exception_handler_spec.rb +35 -0
- data/spec/handlers/method_handler_spec.rb +35 -0
- data/spec/handlers/mixin_handler_spec.rb +30 -0
- data/spec/handlers/module_handler_spec.rb +25 -0
- data/spec/handlers/spec_helper.rb +21 -0
- data/spec/handlers/visibility_handler_spec.rb +24 -0
- data/spec/handlers/yield_handler_spec.rb +51 -0
- data/spec/parser/examples/example1.rb.txt +8 -0
- data/spec/parser/examples/tag_handler_001.rb.txt +8 -0
- data/spec/parser/source_parser_spec.rb +43 -0
- data/spec/parser/tag_parsing_spec.rb +18 -0
- data/spec/parser/token_list_spec.rb +35 -0
- data/spec/registry_spec.rb +70 -0
- data/spec/serializers/file_system_serializer_spec.rb +91 -0
- data/spec/serializers/spec_helper.rb +2 -0
- data/spec/spec_helper.rb +77 -0
- data/templates/default/attributes/html/header.erb +35 -0
- data/templates/default/attributes/text/header.erb +10 -0
- data/templates/default/class/html/header.erb +4 -0
- data/templates/default/constants/html/constants.erb +9 -0
- data/templates/default/constants/html/header.erb +3 -0
- data/templates/default/constants/html/included.erb +9 -0
- data/templates/default/constants/html/inherited.erb +9 -0
- data/templates/default/constructor/html/header.erb +10 -0
- data/templates/default/deprecated/html/main.erb +4 -0
- data/templates/default/deprecated/text/main.erb +3 -0
- data/templates/default/docstring/html/main.erb +3 -0
- data/templates/default/docstring/text/main.erb +3 -0
- data/templates/default/fulldoc/html/all_methods.erb +25 -0
- data/templates/default/fulldoc/html/all_namespaces.erb +19 -0
- data/templates/default/fulldoc/html/app.js +18 -0
- data/templates/default/fulldoc/html/header.erb +15 -0
- data/templates/default/fulldoc/html/html_head.erb +3 -0
- data/templates/default/fulldoc/html/index.erb +18 -0
- data/templates/default/fulldoc/html/jquery.js +11 -0
- data/templates/default/fulldoc/html/readme.erb +15 -0
- data/templates/default/fulldoc/html/style.css +65 -0
- data/templates/default/fulldoc/html/syntax_highlight.css +21 -0
- data/templates/default/inheritance/html/header.erb +8 -0
- data/templates/default/inheritance/text/header.erb +3 -0
- data/templates/default/method/html/aliases.erb +6 -0
- data/templates/default/method/html/header.erb +3 -0
- data/templates/default/method/html/title.erb +3 -0
- data/templates/default/methoddetails/html/header.erb +8 -0
- data/templates/default/methoddetails/html/method_header.erb +3 -0
- data/templates/default/methodmissing/html/header.erb +12 -0
- data/templates/default/methodsignature/html/main.erb +8 -0
- data/templates/default/methodsignature/text/main.erb +5 -0
- data/templates/default/methodsummary/html/header.erb +5 -0
- data/templates/default/methodsummary/html/included.erb +9 -0
- data/templates/default/methodsummary/html/inherited.erb +9 -0
- data/templates/default/methodsummary/html/summary.erb +25 -0
- data/templates/default/methodsummary/text/header.erb +5 -0
- data/templates/default/methodsummary/text/included.erb +0 -0
- data/templates/default/methodsummary/text/inherited.erb +0 -0
- data/templates/default/methodsummary/text/summary.erb +3 -0
- data/templates/default/mixins/html/header.erb +4 -0
- data/templates/default/module/html/header.erb +4 -0
- data/templates/default/quickdoc/html/header.erb +15 -0
- data/templates/default/quickdoc/text/header.erb +12 -0
- data/templates/default/source/html/main.erb +15 -0
- data/templates/default/source/text/main.erb +4 -0
- data/templates/default/tags/html/header.erb +4 -0
- data/templates/default/tags/html/see.erb +13 -0
- data/templates/default/tags/html/tags.erb +20 -0
- data/templates/default/tags/text/header.erb +3 -0
- data/templates/default/tags/text/see.erb +5 -0
- data/templates/default/tags/text/tags.erb +7 -0
- data/templates/default/uml/dot/child.erb +1 -0
- data/templates/default/uml/dot/dependencies.erb +10 -0
- data/templates/default/uml/dot/header.erb +6 -0
- data/templates/default/uml/dot/info.erb +14 -0
- data/templates/default/uml/dot/subgraph.erb +6 -0
- data/templates/default/uml/dot/superclasses.erb +9 -0
- data/templates/default/uml/dot/unknown.erb +3 -0
- data/templates/default/uml/dot/unknown_child.erb +1 -0
- data/templates/default/visibilitygroup/html/header.erb +6 -0
- data/templates/javadoc/attributes/html/header.erb +16 -0
- data/templates/javadoc/class/html/header.erb +4 -0
- data/templates/javadoc/constants/html/constants.erb +9 -0
- data/templates/javadoc/constants/html/header.erb +3 -0
- data/templates/javadoc/constants/html/included.erb +12 -0
- data/templates/javadoc/constants/html/inherited.erb +12 -0
- data/templates/javadoc/constructor/html/header.erb +10 -0
- data/templates/javadoc/deprecated/html/main.erb +0 -0
- data/templates/javadoc/docstring/html/main.erb +6 -0
- data/templates/javadoc/fulldoc/html/all_methods.erb +25 -0
- data/templates/javadoc/fulldoc/html/all_namespaces.erb +19 -0
- data/templates/javadoc/fulldoc/html/app.js +18 -0
- data/templates/javadoc/fulldoc/html/header.erb +15 -0
- data/templates/javadoc/fulldoc/html/html_head.erb +3 -0
- data/templates/javadoc/fulldoc/html/index.erb +18 -0
- data/templates/javadoc/fulldoc/html/jquery.js +11 -0
- data/templates/javadoc/fulldoc/html/readme.erb +15 -0
- data/templates/javadoc/fulldoc/html/style.css +22 -0
- data/templates/javadoc/fulldoc/html/syntax_highlight.css +21 -0
- data/templates/javadoc/inheritance/html/header.erb +6 -0
- data/templates/javadoc/method/html/aliases.erb +6 -0
- data/templates/javadoc/method/html/header.erb +4 -0
- data/templates/javadoc/method/html/title.erb +4 -0
- data/templates/javadoc/methoddetails/html/header.erb +8 -0
- data/templates/javadoc/methoddetails/html/method_header.erb +0 -0
- data/templates/javadoc/methodmissing/html/header.erb +12 -0
- data/templates/javadoc/methodsignature/html/main.erb +8 -0
- data/templates/javadoc/methodsummary/html/header.erb +5 -0
- data/templates/javadoc/methodsummary/html/included.erb +12 -0
- data/templates/javadoc/methodsummary/html/inherited.erb +12 -0
- data/templates/javadoc/methodsummary/html/summary.erb +25 -0
- data/templates/javadoc/mixins/html/header.erb +5 -0
- data/templates/javadoc/module/html/header.erb +4 -0
- data/templates/javadoc/source/html/main.erb +15 -0
- data/templates/javadoc/tags/html/header.erb +5 -0
- data/templates/javadoc/tags/html/see.erb +8 -0
- data/templates/javadoc/tags/html/tags.erb +19 -0
- data/templates/javadoc/visibilitygroup/html/header.erb +5 -0
- metadata +352 -50
- data/README.pdf +0 -0
- data/lib/code_object.rb +0 -337
- data/lib/extra.rb +0 -8
- data/lib/formatter.rb +0 -90
- data/lib/handlers/all_handlers.rb +0 -2
- data/lib/handlers/attribute_handler.rb +0 -51
- data/lib/handlers/class_handler.rb +0 -30
- data/lib/handlers/class_variable_handler.rb +0 -9
- data/lib/handlers/code_object_handler.rb +0 -104
- data/lib/handlers/constant_handler.rb +0 -11
- data/lib/handlers/exception_handler.rb +0 -20
- data/lib/handlers/method_handler.rb +0 -28
- data/lib/handlers/mixin_handler.rb +0 -15
- data/lib/handlers/module_handler.rb +0 -9
- data/lib/handlers/visibility_handler.rb +0 -7
- data/lib/handlers/yield_handler.rb +0 -33
- data/lib/logger.rb +0 -19
- data/lib/namespace.rb +0 -98
- data/lib/quick_doc.rb +0 -104
- data/lib/ruby_lex.rb +0 -1321
- data/lib/source_parser.rb +0 -253
- data/lib/tag_library.rb +0 -175
- data/lib/tag_type.rb +0 -155
- data/templates/default/html/_fulldoc.erb +0 -64
- data/templates/default/html/class.erb +0 -226
- data/templates/default/html/method.erb +0 -20
- data/templates/default/html/module.erb +0 -126
- data/test/fixtures/docstring.txt +0 -23
- data/test/fixtures/docstring2.txt +0 -4
- data/test/test_code_object.rb +0 -66
- data/test/test_namespace.rb +0 -10
@@ -0,0 +1,55 @@
|
|
1
|
+
class Testing
|
2
|
+
# Ignore yields outside methods
|
3
|
+
yield x, y, z
|
4
|
+
|
5
|
+
# Should document this
|
6
|
+
def mymethod
|
7
|
+
yield
|
8
|
+
end
|
9
|
+
|
10
|
+
# Has yield and yieldparam documentation
|
11
|
+
# @yield [a, b] Blah
|
12
|
+
# @yieldparam a Blah
|
13
|
+
# @yieldparam b Blah
|
14
|
+
def mymethod2
|
15
|
+
yield(b, a) # Yield something else
|
16
|
+
end
|
17
|
+
|
18
|
+
# Has yield documentation only
|
19
|
+
# @yield [a, b]
|
20
|
+
def mymethod3
|
21
|
+
yield self # Should not be changed
|
22
|
+
end
|
23
|
+
|
24
|
+
# Has yieldparam documentation only
|
25
|
+
# @yieldparam _self BLAH
|
26
|
+
def mymethod4
|
27
|
+
yield self
|
28
|
+
end
|
29
|
+
|
30
|
+
# Some weird possibilities..
|
31
|
+
# Document it all.
|
32
|
+
|
33
|
+
|
34
|
+
def mymethod5
|
35
|
+
yield :a, b, self, File.read('file', 'w'), CONSTANT if x == 2
|
36
|
+
end
|
37
|
+
|
38
|
+
def mymethod6
|
39
|
+
yield(b, a)
|
40
|
+
end
|
41
|
+
|
42
|
+
def mymethod7
|
43
|
+
yield a
|
44
|
+
yield b
|
45
|
+
end
|
46
|
+
|
47
|
+
def mymethod8
|
48
|
+
yield self
|
49
|
+
end
|
50
|
+
|
51
|
+
def mymethod9
|
52
|
+
yield super
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe YARD::Handlers::ExceptionHandler do
|
4
|
+
before { parse_file :exception_handler_001, __FILE__ }
|
5
|
+
|
6
|
+
it "should not document an exception outside of a method" do
|
7
|
+
P('Testing').has_tag?(:raise).should == false
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should document a valid raise" do
|
11
|
+
P('Testing#mymethod').tag(:raise).types.should == ['ArgumentError']
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should only document non-dynamic raises" do
|
15
|
+
P('Testing#mymethod2').tag(:raise).should be_nil
|
16
|
+
P('Testing#mymethod6').tag(:raise).should be_nil
|
17
|
+
P('Testing#mymethod7').tag(:raise).should be_nil
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should treat ConstantName.new as a valid exception class" do
|
21
|
+
P('Testing#mymethod8').tag(:raise).types.should == ['ExceptionClass']
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should not document a method with an existing @raise tag" do
|
25
|
+
P('Testing#mymethod3').tag(:raise).types.should == ['A']
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should only document the first raise message of a method (limitation of exception handler)" do
|
29
|
+
P('Testing#mymethod4').tag(:raise).types.should == ['A']
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should handle complex class names" do
|
33
|
+
P('Testing#mymethod5').tag(:raise).types.should == ['YARD::Handlers::UndocumentableError']
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe YARD::Handlers::MethodHandler do
|
4
|
+
before do
|
5
|
+
log.enter_level(Logger::ERROR) do
|
6
|
+
parse_file :method_handler_001, __FILE__
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should add methods to parent's #meths list" do
|
11
|
+
P(:Foo).meths.should include(P("Foo#method1"))
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should parse/add class methods (self.method2)" do
|
15
|
+
P(:Foo).meths.should include(P("Foo::method2"))
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should parse/add class methods from other namespaces (String::hello)" do
|
19
|
+
P("String::hello").should_not be_nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should allow punctuation in method names ([], ?, =~, <<, etc.)" do
|
23
|
+
[:[], :[]=, :allowed?, :/, :=~, :==, :`, :|, :*, :&, :%, :'^', :-@, :+@, :'~@'].each do |name|
|
24
|
+
Registry.at("Foo##{name}").should_not be_nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should mark dynamic methods as such" do
|
29
|
+
P('Foo#dynamic').dynamic?.should == true
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should show that a method is explicitly defined (if it was originally defined implicitly by attribute)" do
|
33
|
+
P('Foo#method1').is_explicit?.should == true
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe YARD::Handlers::MixinHandler do
|
4
|
+
before { parse_file :mixin_handler_001, __FILE__ }
|
5
|
+
|
6
|
+
it "should handle includes from classes or modules" do
|
7
|
+
Registry.at(:X).mixins.should include(P(:A))
|
8
|
+
Registry.at(:Y).mixins.should include(P(:A))
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should handle includes for complex namespaces" do
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should handle includes for modules that don't yet exist" do
|
15
|
+
Registry.at(:X).mixins.should include(P(nil, :NOTEXIST))
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should set the type of non-existing modules to :module" do
|
19
|
+
P(:NOTEXIST).type.should == :module
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should handle includes with multiple parameters" do
|
23
|
+
Registry.at(:X)
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should handle complex include statements" do
|
27
|
+
P(:Y).mixins.should include(P('B::C'))
|
28
|
+
P(:Y).mixins.should include(P(:B))
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe YARD::Handlers::ModuleHandler do
|
4
|
+
before do
|
5
|
+
Registry.clear
|
6
|
+
parse_file :module_handler_001, __FILE__
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should parse a module block" do
|
10
|
+
Registry.at(:ModName).should_not == nil
|
11
|
+
Registry.at("ModName::OtherModName").should_not == nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should attach docstring" do
|
15
|
+
Registry.at("ModName::OtherModName").docstring.should == "Docstring"
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should handle any formatting" do
|
19
|
+
Registry.at(:StressTest).should_not == nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should handle complex module names" do
|
23
|
+
Registry.at("A::B").should_not == nil
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "..", "spec_helper")
|
2
|
+
|
3
|
+
include Handlers
|
4
|
+
|
5
|
+
def undoc_error(code)
|
6
|
+
mock = mock("parser")
|
7
|
+
mock.stub!(:namespace).and_return(Registry.root)
|
8
|
+
mock.stub!(:namespace=).and_return nil
|
9
|
+
mock.stub!(:owner).and_return(Registry.root)
|
10
|
+
mock.stub!(:owner=).and_return nil
|
11
|
+
mock.stub!(:scope).and_return(:instance)
|
12
|
+
mock.stub!(:scope=).and_return nil
|
13
|
+
mock.stub!(:visibility).and_return(:public)
|
14
|
+
mock.stub!(:visibility=).and_return nil
|
15
|
+
mock.stub!(:file).and_return('<STDIN>')
|
16
|
+
mock.stub!(:parse).and_return nil
|
17
|
+
mock.stub!(:load_order_errors).and_return false
|
18
|
+
|
19
|
+
c = self.class.described_type.new(mock, Parser::StatementList.new(code).first)
|
20
|
+
lambda { c.process }.should raise_error(UndocumentableError)
|
21
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe YARD::Handlers::VisibilityHandler do
|
4
|
+
before { parse_file :visibility_handler_001, __FILE__ }
|
5
|
+
|
6
|
+
it "should be able to set visibility to public" do
|
7
|
+
Registry.at("Testing#pub").visibility.should == :public
|
8
|
+
Registry.at("Testing#pub2").visibility.should == :public
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should be able to set visibility to private" do
|
12
|
+
Registry.at("Testing#priv").visibility.should == :private
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should be able to set visibility to protected" do
|
16
|
+
Registry.at("Testing#prot").visibility.should == :protected
|
17
|
+
end
|
18
|
+
|
19
|
+
it "should support parameters and only set visibility on those methods" do
|
20
|
+
Registry['Testing#notpriv'].visibility.should == :public
|
21
|
+
Registry['Testing#notpriv2'].visibility.should == :public
|
22
|
+
Registry['Testing#notpriv?'].visibility.should == :public
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe YARD::Handlers::YieldHandler do
|
4
|
+
before { parse_file :yield_handler_001, __FILE__ }
|
5
|
+
|
6
|
+
it "should only parse yield blocks in methods" do
|
7
|
+
P(:Testing).tag(:yield).should be_nil
|
8
|
+
P(:Testing).tag(:yieldparam).should be_nil
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should handle an empty yield statement" do
|
12
|
+
P('Testing#mymethod').tag(:yield).should_not be_nil
|
13
|
+
P('Testing#mymethod').tag(:yieldparam).should be_nil
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should not document a yield statement in a method with either @yield or @yieldparam" do
|
17
|
+
P('Testing#mymethod2').tag(:yield).types.should == ['a', 'b']
|
18
|
+
P('Testing#mymethod2').tag(:yield).text.should == "Blah"
|
19
|
+
P('Testing#mymethod2').tags(:yieldparam).size.should == 2
|
20
|
+
|
21
|
+
P('Testing#mymethod3').tag(:yield).types.should == ['a', 'b']
|
22
|
+
P('Testing#mymethod3').tags(:yieldparam).size.should == 0
|
23
|
+
|
24
|
+
P('Testing#mymethod4').tag(:yieldparam).name.should == '_self'
|
25
|
+
P('Testing#mymethod4').tag(:yieldparam).text.should == 'BLAH'
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should handle any arbitrary yield statement" do
|
29
|
+
P('Testing#mymethod5').tag(:yield).types.should == [':a', 'b', '_self', 'File.read(\'file\', \'w\')', 'CONSTANT']
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should handle parentheses" do
|
33
|
+
P('Testing#mymethod6').tag(:yield).types.should == ['b', 'a']
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should only document the first yield statement in a method (limitation of yield handler)" do
|
37
|
+
P('Testing#mymethod7').tag(:yield).types.should == ['a']
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should handle `self` keyword and list object type as yieldparam for _self" do
|
41
|
+
P('Testing#mymethod8').tag(:yield).types.should == ['_self']
|
42
|
+
P('Testing#mymethod8').tag(:yieldparam).types.should == ['Testing']
|
43
|
+
P('Testing#mymethod8').tag(:yieldparam).text.should == "the object that the method was called on"
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should handle `super` keyword and document it under _super" do
|
47
|
+
P('Testing#mymethod9').tag(:yield).types.should == ['_super']
|
48
|
+
P('Testing#mymethod9').tag(:yieldparam).types.should be_nil
|
49
|
+
P('Testing#mymethod9').tag(:yieldparam).text.should == "the result of the method from the superclass"
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe YARD::Parser::SourceParser do
|
4
|
+
before do
|
5
|
+
Registry.clear
|
6
|
+
end
|
7
|
+
|
8
|
+
it "should parse basic Ruby code" do
|
9
|
+
Parser::SourceParser.parse_string(<<-eof)
|
10
|
+
module Hello
|
11
|
+
class Hi
|
12
|
+
# Docstring
|
13
|
+
def me; "VALUE" end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
eof
|
17
|
+
Registry.at(:Hello).should_not == nil
|
18
|
+
Registry.at("Hello::Hi#me").should_not == nil
|
19
|
+
Registry.at("Hello::Hi#me").docstring.should == "Docstring"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should parse a basic Ruby file" do
|
23
|
+
parse_file :example1, __FILE__
|
24
|
+
Registry.at(:Hello).should_not == nil
|
25
|
+
Registry.at("Hello::Hi#me").should_not == nil
|
26
|
+
Registry.at("Hello::Hi#me").docstring.should == "Docstring"
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should start with public visibility" do
|
30
|
+
p = Parser::SourceParser.new
|
31
|
+
p.visibility.should == :public
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should start in instance scope" do
|
35
|
+
p = Parser::SourceParser.new
|
36
|
+
p.scope.should == :instance
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should start in root namespace" do
|
40
|
+
p = Parser::SourceParser.new
|
41
|
+
p.namespace.should == Registry.root
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
describe YARD::Parser, "tag handling" do
|
4
|
+
before { parse_file :tag_handler_001, __FILE__ }
|
5
|
+
|
6
|
+
it "should know the list of all available tags" do
|
7
|
+
P("Foo#foo").tags.should include(P("Foo#foo").tag(:api))
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should know the text of tags on a method" do
|
11
|
+
P("Foo#foo").tag(:api).text.should == "public"
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return true when asked whether a tag exists" do
|
15
|
+
P("Foo#foo").has_tag?(:api).should == true
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
|
+
|
3
|
+
include YARD::Parser
|
4
|
+
include YARD::Parser::RubyToken
|
5
|
+
|
6
|
+
describe YARD::Parser::TokenList, "#initialize / #push" do
|
7
|
+
it "should accept a tokenlist (via constructor or push)" do
|
8
|
+
lambda { TokenList.new(TokenList.new) }.should_not raise_error(ArgumentError)
|
9
|
+
TokenList.new.push(TokenList.new("x = 2")).size.should == 6
|
10
|
+
end
|
11
|
+
|
12
|
+
it "accept a token (via constructor or push)" do
|
13
|
+
lambda { TokenList.new(Token.new(0, 0)) }.should_not raise_error(ArgumentError)
|
14
|
+
TokenList.new.push(Token.new(0, 0), Token.new(1, 1)).size.should == 2
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should accept a string and parse it as code (via constructor or push)" do
|
18
|
+
lambda { TokenList.new("x = 2") }.should_not raise_error(ArgumentError)
|
19
|
+
x = TokenList.new
|
20
|
+
x.push("x", "=", "2")
|
21
|
+
x.size.should == 6
|
22
|
+
x.to_s.should == "x\n=\n2\n"
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should not accept any other input" do
|
26
|
+
lambda { TokenList.new(:notcode) }.should raise_error(ArgumentError)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should not interpolate string data" do
|
30
|
+
x = TokenList.new('x = "hello #{world}"')
|
31
|
+
x.size.should == 6
|
32
|
+
x[4].class.should == TkDSTRING
|
33
|
+
x.to_s.should == 'x = "hello #{world}"' + "\n"
|
34
|
+
end
|
35
|
+
end
|