yard 0.2.2 → 0.2.3
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 +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
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
|
-
describe YARD::Handlers::ClassHandler do
|
3
|
+
describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}ClassHandler" do
|
4
4
|
before { parse_file :class_handler_001, __FILE__ }
|
5
5
|
|
6
6
|
it "should parse a class block with docstring" do
|
@@ -17,7 +17,7 @@ describe YARD::Handlers::ClassHandler do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should interpret class << self as a class level block" do
|
20
|
-
P("A
|
20
|
+
P("A.classmethod1").should_not == nil
|
21
21
|
end
|
22
22
|
|
23
23
|
it "should interpret class << ClassName as a class level block in ClassName's namespace" do
|
@@ -42,6 +42,10 @@ describe YARD::Handlers::ClassHandler do
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
+
it "should handle class definitions in the form ::ClassName" do
|
46
|
+
Registry.at("MyRootClass").should_not be_nil
|
47
|
+
end
|
48
|
+
|
45
49
|
it "should handle superclass as a constant-style method (camping style < R /path/)" do
|
46
50
|
P('Test1').superclass.should == P(:R)
|
47
51
|
P('Test2').superclass.should == P(:R)
|
@@ -57,12 +61,49 @@ describe YARD::Handlers::ClassHandler do
|
|
57
61
|
P('Test5').superclass.should == P(:Array)
|
58
62
|
end
|
59
63
|
|
64
|
+
it "should handle a superclass of the same name in the form ::ClassName" do
|
65
|
+
P('Q::Logger').superclass.should == P(:Logger)
|
66
|
+
end
|
67
|
+
|
60
68
|
it "should raise an UndocumentableError if the superclass is invalid but it should create the class." do
|
61
|
-
[
|
69
|
+
['@@INVALID', 'hi', '$MYCLASS', 'AnotherClass.new'].each do |klass|
|
62
70
|
Registry.clear
|
63
71
|
undoc_error "class A < #{klass}; end"
|
64
72
|
Registry.at('A').should_not be_nil
|
65
73
|
Registry.at('A').superclass.should == P(:Object)
|
66
74
|
end
|
67
75
|
end
|
76
|
+
|
77
|
+
it "should document 'class << SomeConstant' by using SomeConstant's value as a reference to the real class name" do
|
78
|
+
Registry.at('String.classmethod').should_not be_nil
|
79
|
+
end
|
80
|
+
|
81
|
+
it "should allow class << SomeRubyClass to create the class if it does not exist" do
|
82
|
+
Registry.at('Symbol.toString').should_not be_nil
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should raise an UndocumentableError if the constant class reference 'class << SomeConstant' does not point to a valid class name" do
|
86
|
+
['not.aclass', 'self', 'AnotherClass.new'].each do |klass|
|
87
|
+
Registry.clear
|
88
|
+
undoc_error <<-eof
|
89
|
+
CONST = #{klass}
|
90
|
+
class << CONST; end
|
91
|
+
eof
|
92
|
+
Registry.at(klass).should be_nil
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "should document 'class Exception' without running into superclass issues" do
|
97
|
+
Parser::SourceParser.parse_string <<-eof
|
98
|
+
class Exception
|
99
|
+
end
|
100
|
+
eof
|
101
|
+
Registry.at(:Exception).should_not be_nil
|
102
|
+
end
|
103
|
+
|
104
|
+
it "should document 'class RT < XX::RT' with proper superclass even if XX::RT is a proxy" do
|
105
|
+
Registry.at(:RT).should_not be_nil
|
106
|
+
Registry.at(:RT).superclass.should == P('XX::RT')
|
107
|
+
end
|
108
|
+
|
68
109
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
|
-
describe YARD::Handlers::ClassVariableHandler do
|
3
|
+
describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}ClassVariableHandler" do
|
4
4
|
before { parse_file :class_variable_handler_001, __FILE__ }
|
5
5
|
|
6
6
|
it "should not parse class variables inside methods" do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
|
-
describe YARD::Handlers::ConstantHandler do
|
3
|
+
describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}ConstantHandler" do
|
4
4
|
before { parse_file :constant_handler_001, __FILE__ }
|
5
5
|
|
6
6
|
it "should not parse constants inside methods" do
|
@@ -7,9 +7,11 @@ module A
|
|
7
7
|
alias d? a
|
8
8
|
alias [] a
|
9
9
|
alias []= a
|
10
|
-
alias
|
10
|
+
alias -@ a
|
11
11
|
alias % a
|
12
12
|
alias * a
|
13
|
+
alias for a
|
14
|
+
alias ConstantName a
|
13
15
|
end
|
14
16
|
|
15
17
|
class C
|
@@ -20,5 +22,7 @@ class B < C
|
|
20
22
|
alias_method(:q, :x)
|
21
23
|
alias_method :r?, :x
|
22
24
|
alias_method :s, :to_s
|
23
|
-
alias_method :t, :inspect if 500
|
24
|
-
|
25
|
+
alias_method :t, :inspect if 500 == 3 * CONSTANT
|
26
|
+
alias_method :<<, :a
|
27
|
+
alias_method :for, :a
|
28
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class A
|
2
|
+
if some_condition
|
3
|
+
def a; end
|
4
|
+
elsif 1 == 1
|
5
|
+
def b; end
|
6
|
+
else
|
7
|
+
def c; end
|
8
|
+
end
|
9
|
+
|
10
|
+
def d; end if 50 * 2 == 101
|
11
|
+
|
12
|
+
unless false
|
13
|
+
def e; end
|
14
|
+
else
|
15
|
+
def enot; end
|
16
|
+
end
|
17
|
+
|
18
|
+
def g; end unless 5 * 2 == 101
|
19
|
+
|
20
|
+
def h
|
21
|
+
if 1
|
22
|
+
def hnot; end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
if defined? A
|
27
|
+
def j; end
|
28
|
+
else
|
29
|
+
def jnot; end
|
30
|
+
end
|
31
|
+
|
32
|
+
if defined? RUBY_VERSION
|
33
|
+
def k; end
|
34
|
+
else
|
35
|
+
def knot; end
|
36
|
+
end
|
37
|
+
|
38
|
+
if 0
|
39
|
+
def nnot; end
|
40
|
+
else
|
41
|
+
def n; end
|
42
|
+
end
|
43
|
+
|
44
|
+
if 256
|
45
|
+
def o; end
|
46
|
+
else
|
47
|
+
def onot; end
|
48
|
+
end
|
49
|
+
|
50
|
+
if true
|
51
|
+
def p; end
|
52
|
+
else
|
53
|
+
def pnot; end
|
54
|
+
end
|
55
|
+
|
56
|
+
if false
|
57
|
+
def qnot; end
|
58
|
+
else
|
59
|
+
def q; end
|
60
|
+
end
|
61
|
+
end
|
@@ -20,6 +20,8 @@ module B
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
class RT < XX::RT; end
|
24
|
+
|
23
25
|
class Test1 < R "something"
|
24
26
|
end
|
25
27
|
|
@@ -36,4 +38,35 @@ class Test5 < DelegateClass(Array)
|
|
36
38
|
end
|
37
39
|
|
38
40
|
class Test6 < NotDelegateClass(Array)
|
41
|
+
end
|
42
|
+
|
43
|
+
class ::MyRootClass
|
44
|
+
end
|
45
|
+
|
46
|
+
module Holder
|
47
|
+
module SomeMod
|
48
|
+
class Importer
|
49
|
+
def parse; end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
module Holder
|
55
|
+
class Importer < Holder::SomeMod::Importer
|
56
|
+
def a; end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
class String; end
|
61
|
+
CONST = String
|
62
|
+
class << CONST
|
63
|
+
def classmethod; end
|
64
|
+
end
|
65
|
+
|
66
|
+
module Q
|
67
|
+
class Logger < ::Logger; end
|
68
|
+
end
|
69
|
+
|
70
|
+
class << Symbol
|
71
|
+
alias toString to_s
|
39
72
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class Foo
|
2
2
|
def ==(other)
|
3
|
-
|
3
|
+
'hello'
|
4
4
|
end
|
5
5
|
def /(other) 'hi' end
|
6
6
|
|
@@ -15,14 +15,14 @@ class Foo
|
|
15
15
|
# Docstring
|
16
16
|
def String :: hello; "" end
|
17
17
|
|
18
|
-
def [](key) puts key end
|
18
|
+
def [](key = 'default') puts key end
|
19
19
|
def []=(key, value) end
|
20
20
|
def
|
21
21
|
allowed?
|
22
22
|
end
|
23
23
|
|
24
24
|
def ` param; end
|
25
|
-
def /(x) end
|
25
|
+
def /(x = File.new('x', 'w'), y = 2) end
|
26
26
|
def |; end; def =~ ()
|
27
27
|
def -@; end;
|
28
28
|
end
|
@@ -32,4 +32,16 @@ end
|
|
32
32
|
def &(o) end
|
33
33
|
def %(o) end
|
34
34
|
def ^(o) end
|
35
|
-
|
35
|
+
|
36
|
+
def optsmeth(x, opts = {}) end
|
37
|
+
def blockmeth(x, &block) end
|
38
|
+
|
39
|
+
# @param a [Fixnum]
|
40
|
+
# @overload def bar(a, b = 1)
|
41
|
+
# @param a [String]
|
42
|
+
# @return [String]
|
43
|
+
# @overload def baz(b, c)
|
44
|
+
# @return [Fixnum]
|
45
|
+
# @overload bang(d, e)
|
46
|
+
def foo(*args); end
|
47
|
+
end
|
@@ -1,5 +1,10 @@
|
|
1
1
|
module A; end
|
2
|
-
module B;
|
2
|
+
module B;
|
3
|
+
module C; end
|
4
|
+
module D; end
|
5
|
+
end
|
6
|
+
|
7
|
+
QQQ = B::D
|
3
8
|
|
4
9
|
class X
|
5
10
|
include A
|
@@ -9,4 +14,7 @@ end
|
|
9
14
|
module Y
|
10
15
|
include B::C, B if X == 2
|
11
16
|
include A
|
12
|
-
|
17
|
+
include QQQ
|
18
|
+
|
19
|
+
class << self; include A; end
|
20
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
|
-
describe YARD::Handlers::ExceptionHandler do
|
3
|
+
describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}ExceptionHandler" do
|
4
4
|
before { parse_file :exception_handler_001, __FILE__ }
|
5
5
|
|
6
6
|
it "should not document an exception outside of a method" do
|
@@ -30,6 +30,6 @@ describe YARD::Handlers::ExceptionHandler do
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should handle complex class names" do
|
33
|
-
P('Testing#mymethod5').tag(:raise).types.should == ['YARD::
|
33
|
+
P('Testing#mymethod5').tag(:raise).types.should == ['YARD::Parser::UndocumentableError']
|
34
34
|
end
|
35
35
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
describe "YARD::Handlers::Ruby::#{RUBY18 ? "Legacy::" : ""}ExtendHandler" do
|
4
|
+
before { parse_file :extend_handler_001, __FILE__ }
|
5
|
+
|
6
|
+
it "should include modules at class scope" do
|
7
|
+
Registry.at(:B).class_mixins.should == [P(:A)]
|
8
|
+
Registry.at(:B).instance_mixins.should be_empty
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should handle a module extending itself" do
|
12
|
+
Registry.at(:C).class_mixins.should == [P(:C)]
|
13
|
+
Registry.at(:C).instance_mixins.should be_empty
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
|
3
|
+
include Parser::Ruby::Legacy
|
4
|
+
|
5
|
+
describe YARD::Handlers::Ruby::Legacy::Base, "#tokval" do
|
6
|
+
|
7
|
+
before { @handler = Handlers::Ruby::Legacy::Base.new(nil, nil) }
|
8
|
+
|
9
|
+
def tokval(code, *types)
|
10
|
+
@handler.send(:tokval, TokenList.new(code).first, *types)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should return the String's value without quotes" do
|
14
|
+
tokval('"hello"').should == "hello"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should not allow interpolated strings with TkSTRING" do
|
18
|
+
tokval('"#{c}"', RubyToken::TkSTRING).should be_nil
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should return a Symbol's value as a String (as if it was done via :name.to_sym)" do
|
22
|
+
tokval(':sym').should == :sym
|
23
|
+
end
|
24
|
+
|
25
|
+
it "should return nil for any non accepted type" do
|
26
|
+
tokval('identifier').should be_nil
|
27
|
+
tokval(':sym', RubyToken::TkId).should be_nil
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should accept TkVal tokens by default" do
|
31
|
+
tokval('2.5').should == 2.5
|
32
|
+
tokval(':sym').should == :sym
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should accept any ID type if TkId is set" do
|
36
|
+
tokval('variable', RubyToken::TkId).should == "variable"
|
37
|
+
tokval('CONSTANT', RubyToken::TkId).should == "CONSTANT"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should allow extra token types to be accepted" do
|
41
|
+
tokval('2.5', RubyToken::TkFLOAT).should == 2.5
|
42
|
+
tokval('2', RubyToken::TkFLOAT).should be_nil
|
43
|
+
tokval(':symbol', RubyToken::TkFLOAT).should be_nil
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should allow :string for any string type" do
|
47
|
+
tokval('"hello"', :string).should == "hello"
|
48
|
+
tokval('"#{c}"', :string).should == '#{c}'
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should not include interpolated strings when using :attr" do
|
52
|
+
tokval('"#{c}"', :attr).should be_nil
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should allow any number type with :number" do
|
56
|
+
tokval('2.5', :number).should == 2.5
|
57
|
+
tokval('2', :number).should == 2
|
58
|
+
end
|
59
|
+
|
60
|
+
it "should should allow method names with :identifier" do
|
61
|
+
tokval('methodname?', :identifier).should == "methodname?"
|
62
|
+
end
|
63
|
+
|
64
|
+
#it "should obey documentation expectations" do docspec end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe YARD::Handlers::Base, "#tokval_list" do
|
68
|
+
before { @handler = Handlers::Ruby::Legacy::Base.new(nil, nil) }
|
69
|
+
|
70
|
+
def tokval_list(code, *types)
|
71
|
+
@handler.send(:tokval_list, TokenList.new(code), *types)
|
72
|
+
end
|
73
|
+
|
74
|
+
it "should return the list of tokvalues" do
|
75
|
+
tokval_list(":a, :b, \"\#{c}\", 'd'", :attr).should == [:a, :b, 'd']
|
76
|
+
tokval_list(":a, :b, File.read(\"\#{c}\", ['w']), :d",
|
77
|
+
RubyToken::Token).should == [:a, :b, 'File.read("#{c}", [\'w\'])', :d]
|
78
|
+
end
|
79
|
+
|
80
|
+
it "should try to skip any invalid tokens" do
|
81
|
+
tokval_list(":a, :b, \"\#{c}\", :d", :attr).should == [:a, :b, :d]
|
82
|
+
tokval_list(":a, :b, File.read(\"\#{c}\", 'w', File.open { }), :d", :attr).should == [:a, :b, :d]
|
83
|
+
tokval_list("CONST1, identifier, File.read(\"\#{c}\", 'w', File.open { }), CONST2",
|
84
|
+
RubyToken::TkId).should == ['CONST1', 'identifier', 'CONST2']
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should ignore a token if another invalid token is read before a comma" do
|
88
|
+
tokval_list(":a, :b XYZ, :c", RubyToken::TkSYMBOL).should == [:a, :c]
|
89
|
+
end
|
90
|
+
|
91
|
+
it "should stop on most keywords" do
|
92
|
+
tokval_list(':a rescue :x == 5', RubyToken::Token).should == [:a]
|
93
|
+
end
|
94
|
+
|
95
|
+
it "should handle ignore parentheses that begin the token list" do
|
96
|
+
tokval_list('(:a, :b, :c)', :attr).should == [:a, :b, :c]
|
97
|
+
end
|
98
|
+
|
99
|
+
it "should end when a closing parenthesis was found" do
|
100
|
+
tokval_list(':a, :b, :c), :d', :attr).should == [:a, :b, :c]
|
101
|
+
end
|
102
|
+
|
103
|
+
it "should ignore parentheses around items in a list" do
|
104
|
+
tokval_list(':a, (:b), :c, (:d TEST), :e, [:f], :g', :attr).should == [:a, :b, :c, :e, :g]
|
105
|
+
tokval_list(':a, (((:f)))', :attr).should == [:a, :f]
|
106
|
+
tokval_list(':a, ([:f]), :c)', RubyToken::Token).should == [:a, '[:f]', :c]
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should not stop on a true/false/self keyword (cannot handle nil)" do
|
110
|
+
tokval_list(':a, true, :b, self, false, :c, nil, File, super, if, XYZ',
|
111
|
+
RubyToken::Token).should == [:a, true, :b, 'self', false, :c, 'File', 'super']
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should ignore invalid commas" do
|
115
|
+
tokval_list(":a, :b, , :d").should == [:a, :b, :d]
|
116
|
+
end
|
117
|
+
|
118
|
+
it "should return an empty list if no matches were found" do
|
119
|
+
tokval_list('attr_accessor :x').should == []
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should treat {} as a valid value" do
|
123
|
+
# FIXME: tokval_list destroys extra spaces surrounding the '=' in
|
124
|
+
# this situation. This is technically a design flaw of the
|
125
|
+
# tokval parser, but this is now the expected behaviour.
|
126
|
+
tokval_list("opts = {}", :all).should == ["opts={}"]
|
127
|
+
end
|
128
|
+
end
|