yard 0.8.7.6 → 0.9.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +20 -1
- data/LICENSE +2 -2
- data/README.md +2 -2
- data/Rakefile +1 -1
- data/bin/yard +0 -0
- data/bin/yardoc +0 -0
- data/bin/yri +0 -0
- data/docs/GettingStarted.md +88 -6
- 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/templates/default/fulldoc/html/full_list_tag.erb +6 -4
- data/lib/yard/autoload.rb +3 -0
- data/lib/yard/cli/yardoc.rb +1 -1
- data/lib/yard/code_objects/base.rb +4 -1
- data/lib/yard/code_objects/extra_file_object.rb +3 -1
- data/lib/yard/code_objects/proxy.rb +2 -2
- data/lib/yard/docstring.rb +11 -6
- data/lib/yard/handlers/base.rb +1 -2
- data/lib/yard/handlers/c/base.rb +19 -0
- data/lib/yard/handlers/c/handler_methods.rb +42 -8
- data/lib/yard/handlers/c/init_handler.rb +1 -1
- data/lib/yard/handlers/c/method_handler.rb +3 -3
- data/lib/yard/handlers/ruby/decorator_handler_methods.rb +132 -0
- data/lib/yard/handlers/ruby/legacy/private_class_method_handler.rb +1 -1
- data/lib/yard/handlers/ruby/private_class_method_handler.rb +6 -39
- data/lib/yard/handlers/ruby/private_constant_handler.rb +36 -30
- data/lib/yard/handlers/ruby/public_class_method_handler.rb +13 -0
- data/lib/yard/handlers/ruby/struct_handler_methods.rb +1 -0
- data/lib/yard/handlers/ruby/visibility_handler.rb +5 -8
- data/lib/yard/logging.rb +1 -0
- data/lib/yard/parser/ruby/ruby_parser.rb +2 -2
- data/lib/yard/parser/source_parser.rb +6 -6
- data/lib/yard/rake/yardoc_task.rb +2 -2
- data/lib/yard/serializers/file_system_serializer.rb +33 -1
- data/lib/yard/server/commands/display_file_command.rb +8 -3
- data/lib/yard/server/commands/display_object_command.rb +7 -3
- data/lib/yard/server/doc_server_helper.rb +2 -8
- data/lib/yard/server/doc_server_serializer.rb +2 -4
- data/lib/yard/server/router.rb +1 -1
- data/lib/yard/server/templates/default/fulldoc/html/css/custom.css +57 -8
- data/lib/yard/server/templates/default/layout/html/breadcrumb.erb +2 -10
- data/lib/yard/server/templates/default/layout/html/script_setup.erb +1 -2
- data/lib/yard/server/templates/default/method_details/html/permalink.erb +3 -3
- data/lib/yard/server/templates/doc_server/processing/html/processing.erb +4 -4
- data/lib/yard/tags/directives.rb +1 -0
- data/lib/yard/tags/library.rb +9 -7
- data/lib/yard/tags/overload_tag.rb +4 -1
- data/lib/yard/templates/helpers/html_helper.rb +4 -3
- data/lib/yard/templates/template_options.rb +3 -0
- data/lib/yard/version.rb +1 -1
- data/spec/cli/command_parser_spec.rb +14 -14
- data/spec/cli/command_spec.rb +11 -11
- data/spec/cli/config_spec.rb +32 -32
- data/spec/cli/diff_spec.rb +86 -90
- data/spec/cli/display_spec.rb +6 -6
- data/spec/cli/gems_spec.rb +28 -28
- data/spec/cli/graph_spec.rb +8 -8
- data/spec/cli/help_spec.rb +8 -8
- data/spec/cli/i18n_spec.rb +33 -37
- data/spec/cli/list_spec.rb +2 -2
- data/spec/cli/markup_types_spec.rb +3 -3
- data/spec/cli/server_spec.rb +74 -88
- data/spec/cli/stats_spec.rb +14 -14
- data/spec/cli/yardoc_spec.rb +316 -321
- data/spec/cli/yri_spec.rb +45 -45
- data/spec/code_objects/base_spec.rb +174 -173
- data/spec/code_objects/class_object_spec.rb +65 -65
- data/spec/code_objects/code_object_list_spec.rb +13 -11
- data/spec/code_objects/constants_spec.rb +68 -58
- data/spec/code_objects/extra_file_object_spec.rb +71 -59
- data/spec/code_objects/macro_object_spec.rb +64 -64
- data/spec/code_objects/method_object_spec.rb +80 -72
- data/spec/code_objects/module_object_spec.rb +47 -47
- data/spec/code_objects/namespace_object_spec.rb +51 -51
- data/spec/code_objects/proxy_spec.rb +54 -54
- data/spec/config_spec.rb +104 -104
- data/spec/core_ext/array_spec.rb +5 -5
- data/spec/core_ext/file_spec.rb +33 -33
- data/spec/core_ext/hash_spec.rb +5 -5
- data/spec/core_ext/insertion_spec.rb +18 -18
- data/spec/core_ext/module_spec.rb +6 -6
- data/spec/core_ext/string_spec.rb +17 -17
- data/spec/core_ext/symbol_hash_spec.rb +42 -39
- data/spec/docstring_parser_spec.rb +65 -65
- data/spec/docstring_spec.rb +137 -130
- data/spec/handlers/alias_handler_spec.rb +39 -39
- data/spec/handlers/attribute_handler_spec.rb +35 -35
- data/spec/handlers/base_spec.rb +60 -51
- data/spec/handlers/c/alias_handler_spec.rb +6 -6
- data/spec/handlers/c/attribute_handler_spec.rb +12 -12
- data/spec/handlers/c/class_handler_spec.rb +35 -22
- data/spec/handlers/c/constant_handler_spec.rb +24 -22
- data/spec/handlers/c/init_handler_spec.rb +10 -10
- data/spec/handlers/c/method_handler_spec.rb +150 -65
- data/spec/handlers/c/mixin_handler_spec.rb +5 -5
- data/spec/handlers/c/module_handler_spec.rb +27 -15
- data/spec/handlers/c/override_comment_handler_spec.rb +14 -14
- data/spec/handlers/c/path_handler_spec.rb +8 -8
- data/spec/handlers/c/spec_helper.rb +10 -0
- data/spec/handlers/c/struct_handler_spec.rb +3 -3
- data/spec/handlers/class_condition_handler_spec.rb +18 -18
- data/spec/handlers/class_handler_spec.rb +97 -97
- data/spec/handlers/class_method_handler_shared_examples.rb +132 -0
- data/spec/handlers/class_variable_handler_spec.rb +3 -3
- data/spec/handlers/constant_handler_spec.rb +32 -29
- data/spec/handlers/decorator_handler_methods_spec.rb +405 -0
- data/spec/handlers/dsl_handler_spec.rb +108 -109
- data/spec/handlers/examples/constant_handler_001.rb.txt +4 -1
- data/spec/handlers/examples/visibility_handler_001.rb.txt +4 -0
- data/spec/handlers/exception_handler_spec.rb +23 -23
- data/spec/handlers/extend_handler_spec.rb +9 -9
- data/spec/handlers/legacy_base_spec.rb +60 -60
- data/spec/handlers/method_condition_handler_spec.rb +5 -5
- data/spec/handlers/method_handler_spec.rb +92 -92
- data/spec/handlers/mixin_handler_spec.rb +25 -25
- data/spec/handlers/module_function_handler_spec.rb +24 -24
- data/spec/handlers/module_handler_spec.rb +15 -15
- data/spec/handlers/private_class_method_handler_spec.rb +4 -48
- data/spec/handlers/private_constant_handler_spec.rb +8 -8
- data/spec/handlers/processor_spec.rb +12 -12
- data/spec/handlers/public_class_method_handler_spec.rb +10 -0
- data/spec/handlers/ruby/base_spec.rb +16 -16
- data/spec/handlers/ruby/legacy/base_spec.rb +20 -18
- data/spec/handlers/spec_helper.rb +1 -1
- data/spec/handlers/visibility_handler_spec.rb +25 -21
- data/spec/handlers/yield_handler_spec.rb +28 -28
- data/spec/i18n/locale_spec.rb +16 -16
- data/spec/i18n/message_spec.rb +8 -8
- data/spec/i18n/messages_spec.rb +14 -14
- data/spec/i18n/pot_generator_spec.rb +32 -32
- data/spec/i18n/text_spec.rb +22 -22
- data/spec/logging_spec.rb +12 -12
- data/spec/options_spec.rb +56 -56
- data/spec/parser/base_spec.rb +9 -9
- data/spec/parser/c_parser_spec.rb +50 -50
- data/spec/parser/ruby/ast_node_spec.rb +7 -7
- data/spec/parser/ruby/legacy/statement_list_spec.rb +106 -106
- data/spec/parser/ruby/legacy/token_list_spec.rb +27 -27
- data/spec/parser/ruby/ruby_parser_spec.rb +123 -113
- data/spec/parser/source_parser_spec.rb +224 -224
- data/spec/parser/tag_parsing_spec.rb +6 -7
- data/spec/rake/yardoc_task_spec.rb +38 -48
- data/spec/registry_spec.rb +143 -143
- data/spec/registry_store_spec.rb +165 -165
- data/spec/rubygems/doc_manager_spec.rb +38 -38
- data/spec/serializers/file_system_serializer_spec.rb +53 -33
- data/spec/serializers/yardoc_serializer_spec.rb +15 -15
- data/spec/server/adapter_spec.rb +15 -15
- data/spec/server/commands/base_spec.rb +29 -29
- data/spec/server/commands/library_command_spec.rb +12 -12
- data/spec/server/commands/static_file_command_spec.rb +28 -28
- data/spec/server/doc_server_helper_spec.rb +8 -8
- data/spec/server/doc_server_serializer_spec.rb +23 -18
- data/spec/server/rack_adapter_spec.rb +6 -6
- data/spec/server/router_spec.rb +39 -39
- data/spec/server/static_caching_spec.rb +16 -16
- data/spec/server/webrick_servlet_spec.rb +6 -7
- data/spec/server_spec.rb +3 -3
- data/spec/spec_helper.rb +11 -2
- data/spec/tags/default_factory_spec.rb +64 -64
- data/spec/tags/default_tag_spec.rb +5 -5
- data/spec/tags/directives_spec.rb +121 -121
- data/spec/tags/library_spec.rb +14 -14
- data/spec/tags/overload_tag_spec.rb +24 -24
- data/spec/tags/ref_tag_list_spec.rb +12 -12
- data/spec/templates/class_spec.rb +3 -3
- data/spec/templates/constant_spec.rb +4 -4
- data/spec/templates/engine_spec.rb +47 -48
- data/spec/templates/examples/class001.html +129 -101
- data/spec/templates/examples/class002.html +31 -27
- data/spec/templates/examples/method001.html +54 -47
- data/spec/templates/examples/method002.html +33 -28
- data/spec/templates/examples/method003.html +70 -64
- data/spec/templates/examples/method004.html +13 -9
- data/spec/templates/examples/method005.html +38 -32
- data/spec/templates/examples/module001.html +343 -339
- data/spec/templates/examples/module002.html +147 -124
- data/spec/templates/examples/module003.html +94 -81
- data/spec/templates/examples/module004.html +40 -33
- data/spec/templates/helpers/base_helper_spec.rb +91 -95
- data/spec/templates/helpers/html_helper_spec.rb +276 -279
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +16 -15
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +27 -34
- data/spec/templates/helpers/markup_helper_spec.rb +57 -57
- data/spec/templates/helpers/method_helper_spec.rb +20 -20
- data/spec/templates/helpers/shared_signature_examples.rb +33 -31
- data/spec/templates/helpers/text_helper_spec.rb +6 -6
- data/spec/templates/method_spec.rb +7 -7
- data/spec/templates/module_spec.rb +7 -7
- data/spec/templates/onefile_spec.rb +7 -7
- data/spec/templates/section_spec.rb +66 -69
- data/spec/templates/spec_helper.rb +1 -1
- data/spec/templates/tag_spec.rb +5 -5
- data/spec/templates/template_spec.rb +158 -158
- data/spec/verifier_spec.rb +52 -52
- data/templates/default/fulldoc/html/css/full_list.css +32 -31
- data/templates/default/fulldoc/html/css/style.css +212 -77
- data/templates/default/fulldoc/html/frames.erb +6 -15
- data/templates/default/fulldoc/html/full_list.erb +14 -21
- data/templates/default/fulldoc/html/full_list_class.erb +1 -1
- data/templates/default/fulldoc/html/full_list_file.erb +6 -4
- data/templates/default/fulldoc/html/full_list_method.erb +8 -6
- data/templates/default/fulldoc/html/js/app.js +100 -76
- data/templates/default/fulldoc/html/js/full_list.js +170 -135
- data/templates/default/fulldoc/html/setup.rb +50 -7
- data/templates/default/layout/html/breadcrumb.erb +0 -2
- data/templates/default/layout/html/headers.erb +2 -1
- data/templates/default/layout/html/layout.erb +16 -10
- data/templates/default/layout/html/script_setup.erb +1 -2
- data/templates/default/layout/html/search.erb +7 -2
- data/templates/default/layout/html/setup.rb +16 -0
- data/templates/default/method/html/header.erb +7 -6
- data/templates/default/module/html/attribute_summary.erb +1 -1
- data/templates/default/module/html/box_info.erb +24 -18
- data/templates/default/module/html/constant_summary.erb +9 -11
- data/templates/default/module/html/item_summary.erb +1 -1
- data/templates/default/module/html/method_summary.erb +1 -1
- data/templates/guide/fulldoc/html/setup.rb +1 -1
- data/yard.gemspec +1 -2
- metadata +10 -7
- data/spec/handlers/examples/private_class_method_handler_001.rb.txt +0 -9
- data/spec/handlers/examples/private_class_method_handler_002.rb.txt +0 -18
- data/spec/handlers/examples/private_class_method_handler_003.rb.txt +0 -11
@@ -3,32 +3,32 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}ModuleHandler" do
|
4
4
|
before(:all) { parse_file :module_handler_001, __FILE__ }
|
5
5
|
|
6
|
-
it "
|
7
|
-
Registry.at(:ModName).
|
8
|
-
Registry.at("ModName::OtherModName").
|
6
|
+
it "parses a module block" do
|
7
|
+
expect(Registry.at(:ModName)).not_to eq nil
|
8
|
+
expect(Registry.at("ModName::OtherModName")).not_to eq nil
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
12
|
-
Registry.at("ModName::OtherModName").docstring.
|
11
|
+
it "attaches docstring" do
|
12
|
+
expect(Registry.at("ModName::OtherModName").docstring).to eq "Docstring"
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
16
|
-
Registry.at(:StressTest).
|
15
|
+
it "handles any formatting" do
|
16
|
+
expect(Registry.at(:StressTest)).not_to eq nil
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
20
|
-
Registry.at("A::B").
|
19
|
+
it "handles complex module names" do
|
20
|
+
expect(Registry.at("A::B")).not_to eq nil
|
21
21
|
end
|
22
22
|
|
23
|
-
it "
|
24
|
-
Registry.at("Kernel").
|
23
|
+
it "handles modules in the form ::ModName" do
|
24
|
+
expect(Registry.at("Kernel")).not_to be nil
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
28
|
-
Registry.at('D').mixins.
|
27
|
+
it "lists mixins in proper order" do
|
28
|
+
expect(Registry.at('D').mixins).to eq [P(:C), P(:B), P(:A)]
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
32
|
-
Registry.at('Q::FOO::A').
|
31
|
+
it "creates proper module when constant is in namespace" do
|
32
|
+
expect(Registry.at('Q::FOO::A')).not_to be nil
|
33
33
|
end
|
34
34
|
end
|
@@ -1,54 +1,10 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/class_method_handler_shared_examples'
|
2
3
|
|
3
4
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}PrivateClassMethodHandler" do
|
4
|
-
before
|
5
|
+
before { Registry.clear }
|
5
6
|
|
6
|
-
|
7
|
-
Registry.at('A.c').visibility.should eq :private
|
8
|
-
Registry.at('A.d').visibility.should eq :private
|
9
|
-
Registry.at('A.e').visibility.should eq :private
|
10
|
-
end
|
7
|
+
let(:visibility) { :private }
|
11
8
|
|
12
|
-
|
13
|
-
undoc_error 'class Foo; X = 1; private_class_method X.new("hi"); end'
|
14
|
-
undoc_error 'class Foo; X = 1; private_class_method 123; end'
|
15
|
-
end unless LEGACY_PARSER
|
16
|
-
|
17
|
-
# Issue #760
|
18
|
-
# https://github.com/lsegal/yard/issues/760
|
19
|
-
it "should handle singleton classes" do
|
20
|
-
# Note: It's important to def a method within the singleton class or
|
21
|
-
# the bug may not trigger.
|
22
|
-
code = 'class SingletonClass; private_class_method :new; def self.foo; "foo"end; end'
|
23
|
-
StubbedSourceParser.parse_string(code) # Should be successful.
|
24
|
-
end unless LEGACY_PARSER
|
25
|
-
|
26
|
-
|
27
|
-
describe "should handle reopened class" do
|
28
|
-
|
29
|
-
# Modified #parse_file from '/spec/spec_helper.rb' because the second example
|
30
|
-
# file was overwriting the data from the first example when trying to reopen
|
31
|
-
# the class.
|
32
|
-
def parse_files(files, thisfile = __FILE__, log_level = log.level, ext = '.rb.txt')
|
33
|
-
Registry.clear
|
34
|
-
paths = files.map { |file| File.join(File.dirname(thisfile), 'examples', file.to_s + ext) }
|
35
|
-
YARD::Parser::SourceParser.parse(paths, [], log_level)
|
36
|
-
end
|
37
|
-
|
38
|
-
before {
|
39
|
-
parse_files [
|
40
|
-
:private_class_method_handler_002,
|
41
|
-
:private_class_method_handler_003
|
42
|
-
], __FILE__
|
43
|
-
}
|
44
|
-
|
45
|
-
specify do
|
46
|
-
Registry.at('SingletonClass.foo').visibility.should eq :public
|
47
|
-
Registry.at('SingletonClass.bar').visibility.should eq :private
|
48
|
-
Registry.at('SingletonClass.baz').visibility.should eq :private
|
49
|
-
Registry.at('SingletonClass.bat').visibility.should eq :public
|
50
|
-
end
|
51
|
-
|
52
|
-
end unless LEGACY_PARSER # reopened class
|
53
|
-
|
9
|
+
include_examples "class method visibility decorator"
|
54
10
|
end
|
@@ -3,22 +3,22 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}PrivateConstantHandler" do
|
4
4
|
before(:all) { parse_file :private_constant_handler_001, __FILE__ }
|
5
5
|
|
6
|
-
it "
|
7
|
-
Registry.at('A::Foo').visibility.
|
8
|
-
Registry.at('A::B').visibility.
|
9
|
-
Registry.at('A::C').visibility.
|
6
|
+
it "handles private_constant statement" do
|
7
|
+
expect(Registry.at('A::Foo').visibility).to eq :private
|
8
|
+
expect(Registry.at('A::B').visibility).to eq :private
|
9
|
+
expect(Registry.at('A::C').visibility).to eq :private
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
13
|
-
Registry.at('A::D').visibility.
|
12
|
+
it "makes all other constants public" do
|
13
|
+
expect(Registry.at('A::D').visibility).to eq :public
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
16
|
+
it "fails if parameter is not String, Symbol or Constant" do
|
17
17
|
undoc_error 'class Foo; private_constant x; end'
|
18
18
|
undoc_error 'class Foo; X = 1; private_constant X.new("hi"); end'
|
19
19
|
end unless LEGACY_PARSER
|
20
20
|
|
21
|
-
it "
|
21
|
+
it "fails if constant can't be recognized" do
|
22
22
|
undoc_error 'class Foo2; private_constant :X end'
|
23
23
|
end
|
24
24
|
end
|
@@ -5,30 +5,30 @@ describe YARD::Handlers::Processor do
|
|
5
5
|
@proc = Handlers::Processor.new(OpenStruct.new(:parser_type => :ruby))
|
6
6
|
end
|
7
7
|
|
8
|
-
it "
|
9
|
-
@proc.visibility.
|
8
|
+
it "starts with public visibility" do
|
9
|
+
expect(@proc.visibility).to eq :public
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
13
|
-
@proc.scope.
|
12
|
+
it "starts in instance scope" do
|
13
|
+
expect(@proc.scope).to eq :instance
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
17
|
-
@proc.namespace.
|
16
|
+
it "starts in root namespace" do
|
17
|
+
expect(@proc.namespace).to eq Registry.root
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
21
|
-
@proc.globals.
|
20
|
+
it "has a globals structure" do
|
21
|
+
expect(@proc.globals).to be_a(OpenStruct)
|
22
22
|
end
|
23
23
|
|
24
|
-
it
|
24
|
+
it "ignores HandlerAborted exceptions (but print debug info)" do
|
25
25
|
class AbortHandlerProcessor < YARD::Handlers::Ruby::Base
|
26
26
|
process { abort! }
|
27
27
|
end
|
28
28
|
stmt = OpenStruct.new(:line => 1, :show => 'SOURCE')
|
29
|
-
@proc.
|
30
|
-
log.
|
31
|
-
log.
|
29
|
+
allow(@proc).to receive(:find_handlers).and_return([AbortHandlerProcessor])
|
30
|
+
expect(log).to receive(:debug).with(/AbortHandlerProcessor cancelled from/)
|
31
|
+
expect(log).to receive(:debug).with("\tin file '(stdin)':1:\n\nSOURCE\n")
|
32
32
|
@proc.process([stmt])
|
33
33
|
end
|
34
34
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/spec_helper'
|
2
|
+
require File.dirname(__FILE__) + '/class_method_handler_shared_examples'
|
3
|
+
|
4
|
+
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}PublicClassMethodHandler" do
|
5
|
+
before { Registry.clear }
|
6
|
+
|
7
|
+
let(:visibility) { :public }
|
8
|
+
|
9
|
+
include_examples "class method visibility decorator"
|
10
|
+
end
|
@@ -4,7 +4,7 @@ describe YARD::Handlers::Ruby::Base, '#valid_handler?' do
|
|
4
4
|
include YARD::Parser::Ruby; YARD::Parser::Ruby::AstNode
|
5
5
|
|
6
6
|
before do
|
7
|
-
Handlers::Ruby::Base.
|
7
|
+
allow(Handlers::Ruby::Base).to receive(:inherited)
|
8
8
|
@processor = Handlers::Processor.new(OpenStruct.new(:parser_type => :ruby))
|
9
9
|
end
|
10
10
|
|
@@ -13,67 +13,67 @@ describe YARD::Handlers::Ruby::Base, '#valid_handler?' do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def valid(handler, stmt)
|
16
|
-
@processor.find_handlers(stmt).
|
16
|
+
expect(@processor.find_handlers(stmt)).to include(handler)
|
17
17
|
end
|
18
18
|
|
19
19
|
def invalid(handler, stmt)
|
20
|
-
@processor.find_handlers(stmt).
|
20
|
+
expect(@processor.find_handlers(stmt)).not_to include(handler)
|
21
21
|
end
|
22
22
|
|
23
|
-
it "
|
23
|
+
it "only handles Handlers inherited from Ruby::Base class" do
|
24
24
|
class IgnoredHandler < Handlers::Base
|
25
25
|
handles :list
|
26
26
|
end
|
27
27
|
class NotIgnoredHandler < Handlers::Ruby::Base
|
28
28
|
handles :list
|
29
29
|
end
|
30
|
-
Handlers::Base.
|
31
|
-
@processor.find_handlers(s()).
|
30
|
+
allow(Handlers::Base).to receive(:subclasses).and_return [IgnoredHandler, NotIgnoredHandler]
|
31
|
+
expect(@processor.find_handlers(s())).to eq [NotIgnoredHandler]
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "handles string input (matches AstNode#source)" do
|
35
35
|
class StringHandler < Handlers::Ruby::Base
|
36
36
|
handles "x"
|
37
37
|
end
|
38
|
-
Handlers::Base.
|
38
|
+
allow(Handlers::Base).to receive(:subclasses).and_return [StringHandler]
|
39
39
|
ast = Parser::Ruby::RubyParser.parse("if x == 2 then true end").ast
|
40
40
|
valid StringHandler, ast[0][0][0]
|
41
41
|
invalid StringHandler, ast[0][1]
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
44
|
+
it "handles symbol input (matches AstNode#type)" do
|
45
45
|
class SymbolHandler < Handlers::Ruby::Base
|
46
46
|
handles :myNodeType
|
47
47
|
end
|
48
|
-
Handlers::Base.
|
48
|
+
allow(Handlers::Base).to receive(:subclasses).and_return [SymbolHandler]
|
49
49
|
valid SymbolHandler, s(:myNodeType, s(1, 2, 3))
|
50
50
|
invalid SymbolHandler, s(:NOTmyNodeType, s(1, 2, 3))
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
53
|
+
it "handles regex input (matches AstNode#source)" do
|
54
54
|
class RegexHandler < Handlers::Ruby::Base
|
55
55
|
handles %r{^if x ==}
|
56
56
|
end
|
57
|
-
Handlers::Base.
|
57
|
+
allow(Handlers::Base).to receive(:subclasses).and_return [RegexHandler]
|
58
58
|
ast = Parser::Ruby::RubyParser.parse("if x == 2 then true end").ast
|
59
59
|
valid RegexHandler, ast
|
60
60
|
invalid RegexHandler, ast[0][1]
|
61
61
|
end
|
62
62
|
|
63
|
-
it "
|
63
|
+
it "handles AstNode input (matches AST literally)" do
|
64
64
|
class ASTHandler < Handlers::Ruby::Base
|
65
65
|
handles s(:vcall, s(:ident, "hello_world"))
|
66
66
|
end
|
67
|
-
Handlers::Base.
|
67
|
+
allow(Handlers::Base).to receive(:subclasses).and_return [ASTHandler]
|
68
68
|
valid ASTHandler, s(:vcall, s(:ident, "hello_world"))
|
69
69
|
invalid ASTHandler, s(:vcall, s(:ident, "NOTHELLOWORLD"))
|
70
70
|
end
|
71
71
|
|
72
|
-
it "
|
72
|
+
it "handles #method_call(:methname) on a valid AST" do
|
73
73
|
class MethCallHandler < Handlers::Ruby::Base
|
74
74
|
handles method_call(:meth)
|
75
75
|
end
|
76
|
-
Handlers::Base.
|
76
|
+
allow(Handlers::Base).to receive(:subclasses).and_return [MethCallHandler]
|
77
77
|
ast = Parser::Ruby::RubyParser.parse(<<-"eof").ast
|
78
78
|
meth # 0
|
79
79
|
meth() # 1
|
@@ -4,8 +4,10 @@ include Parser::Ruby::Legacy
|
|
4
4
|
|
5
5
|
describe YARD::Handlers::Ruby::Legacy::Base, "#handles and inheritance" do
|
6
6
|
before do
|
7
|
-
Handlers::Ruby::Legacy::Base.
|
8
|
-
|
7
|
+
allow(Handlers::Ruby::Legacy::Base).to receive(:inherited)
|
8
|
+
if RUBY_VERSION > '1.8.7'
|
9
|
+
allow(Handlers::Ruby::Legacy::MixinHandler).to receive(:inherited) # fixes a Ruby1.9 issue
|
10
|
+
end
|
9
11
|
@processor = Handlers::Processor.new(OpenStruct.new(:parser_type => :ruby18))
|
10
12
|
end
|
11
13
|
|
@@ -17,45 +19,45 @@ describe YARD::Handlers::Ruby::Legacy::Base, "#handles and inheritance" do
|
|
17
19
|
Statement.new(TokenList.new(string))
|
18
20
|
end
|
19
21
|
|
20
|
-
it "
|
22
|
+
it "only handles Handlers inherited from Ruby::Legacy::Base class" do
|
21
23
|
class IgnoredHandler < Handlers::Base
|
22
24
|
handles "hello"
|
23
25
|
end
|
24
26
|
class NotIgnoredHandlerLegacy < Handlers::Ruby::Legacy::Base
|
25
27
|
handles "hello"
|
26
28
|
end
|
27
|
-
Handlers::Base.
|
28
|
-
@processor.find_handlers(stmt("hello world")).
|
29
|
+
allow(Handlers::Base).to receive(:subclasses).and_return [IgnoredHandler, NotIgnoredHandlerLegacy]
|
30
|
+
expect(@processor.find_handlers(stmt("hello world"))).to eq [NotIgnoredHandlerLegacy]
|
29
31
|
end
|
30
32
|
|
31
|
-
it "
|
33
|
+
it "handles a string input" do
|
32
34
|
class TestStringHandler < Handlers::Ruby::Legacy::Base
|
33
35
|
handles "hello"
|
34
36
|
end
|
35
37
|
|
36
|
-
TestStringHandler.handles?(stmt("hello world")).
|
37
|
-
TestStringHandler.handles?(stmt("nothello world")).
|
38
|
+
expect(TestStringHandler.handles?(stmt("hello world"))).to be true
|
39
|
+
expect(TestStringHandler.handles?(stmt("nothello world"))).to be false
|
38
40
|
end
|
39
41
|
|
40
|
-
it "
|
42
|
+
it "handles regex input" do
|
41
43
|
class TestRegexHandler < Handlers::Ruby::Legacy::Base
|
42
44
|
handles /^nothello$/
|
43
45
|
end
|
44
46
|
|
45
|
-
TestRegexHandler.handles?(stmt("nothello")).
|
46
|
-
TestRegexHandler.handles?(stmt("not hello hello")).
|
47
|
+
expect(TestRegexHandler.handles?(stmt("nothello"))).to be true
|
48
|
+
expect(TestRegexHandler.handles?(stmt("not hello hello"))).to be false
|
47
49
|
end
|
48
50
|
|
49
|
-
it "
|
51
|
+
it "handles token input" do
|
50
52
|
class TestTokenHandler < Handlers::Ruby::Legacy::Base
|
51
53
|
handles TkMODULE
|
52
54
|
end
|
53
55
|
|
54
|
-
TestTokenHandler.handles?(stmt("module")).
|
55
|
-
TestTokenHandler.handles?(stmt("if")).
|
56
|
+
expect(TestTokenHandler.handles?(stmt("module"))).to be true
|
57
|
+
expect(TestTokenHandler.handles?(stmt("if"))).to be false
|
56
58
|
end
|
57
59
|
|
58
|
-
it "
|
60
|
+
it "parses a do/end or { } block with #parse_block" do
|
59
61
|
class MyBlockHandler < Handlers::Ruby::Legacy::Base
|
60
62
|
handles /\AmyMethod\b/
|
61
63
|
def process
|
@@ -70,13 +72,13 @@ describe YARD::Handlers::Ruby::Legacy::Base, "#handles and inheritance" do
|
|
70
72
|
def process; @@reached = true end
|
71
73
|
end
|
72
74
|
|
73
|
-
Handlers::Base.
|
75
|
+
allow(Handlers::Base).to receive(:subclasses).and_return [MyBlockHandler, MyBlockInnerHandler]
|
74
76
|
Parser::SourceParser.parser_type = :ruby18
|
75
77
|
Parser::SourceParser.parse_string "myMethod do inner end"
|
76
|
-
MyBlockInnerHandler.
|
78
|
+
expect(MyBlockInnerHandler).to be_reached
|
77
79
|
MyBlockInnerHandler.reset
|
78
80
|
Parser::SourceParser.parse_string "myMethod { inner }"
|
79
|
-
MyBlockInnerHandler.
|
81
|
+
expect(MyBlockInnerHandler).to be_reached
|
80
82
|
Parser::SourceParser.parser_type = :ruby
|
81
83
|
end
|
82
84
|
end
|
@@ -4,7 +4,7 @@ require 'stringio'
|
|
4
4
|
include Handlers
|
5
5
|
|
6
6
|
def undoc_error(code)
|
7
|
-
|
7
|
+
expect { StubbedSourceParser.parse_string(code) }.to raise_error(Parser::UndocumentableError)
|
8
8
|
end
|
9
9
|
|
10
10
|
def with_parser(parser_type, &block)
|
@@ -3,37 +3,41 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}VisibilityHandler" do
|
4
4
|
before(:all) { parse_file :visibility_handler_001, __FILE__ }
|
5
5
|
|
6
|
-
it "
|
7
|
-
Registry.at("Testing#pub").visibility.
|
8
|
-
Registry.at("Testing#pub2").visibility.
|
6
|
+
it "is able to set visibility to public" do
|
7
|
+
expect(Registry.at("Testing#pub").visibility).to eq :public
|
8
|
+
expect(Registry.at("Testing#pub2").visibility).to eq :public
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
12
|
-
Registry.at("Testing#priv").visibility.
|
11
|
+
it "is able to set visibility to private" do
|
12
|
+
expect(Registry.at("Testing#priv").visibility).to eq :private
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
16
|
-
Registry.at("Testing#prot").visibility.
|
15
|
+
it "is able to set visibility to protected" do
|
16
|
+
expect(Registry.at("Testing#prot").visibility).to eq :protected
|
17
17
|
end
|
18
18
|
|
19
|
-
it "
|
20
|
-
Registry
|
21
|
-
Registry
|
22
|
-
Registry
|
19
|
+
it "supports parameters and only set visibility on those methods" do
|
20
|
+
expect(Registry.at('Testing#notpriv').visibility).to eq :protected
|
21
|
+
expect(Registry.at('Testing#notpriv2').visibility).to eq :protected
|
22
|
+
expect(Registry.at('Testing#notpriv?').visibility).to eq :protected
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
26
|
-
Registry.at('Testing#name').
|
27
|
-
Registry.at('Testing#argument').
|
28
|
-
Registry.at('Testing#method_call').
|
25
|
+
it "only accepts strings and symbols" do
|
26
|
+
expect(Registry.at('Testing#name')).to be nil
|
27
|
+
expect(Registry.at('Testing#argument')).to be nil
|
28
|
+
expect(Registry.at('Testing#method_call')).to be nil
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
32
|
-
Registry.at('Testing#Foo').visibility.
|
31
|
+
it "handles constants passed in as symbols" do
|
32
|
+
expect(Registry.at('Testing#Foo').visibility).to eq :private
|
33
33
|
end
|
34
34
|
|
35
|
-
it
|
36
|
-
Registry.at('Testing::Bar').visibility.
|
37
|
-
Registry.at('Testing::Baz').visibility.
|
35
|
+
it "does not register classes with visibility" do
|
36
|
+
expect(Registry.at('Testing::Bar').visibility).to eq :public
|
37
|
+
expect(Registry.at('Testing::Baz').visibility).to eq :public
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
|
+
it "can decorate a method definition" do
|
41
|
+
expect(Registry.at('Testing#decpriv').visibility).to eq :private
|
42
|
+
end unless LEGACY_PARSER
|
43
|
+
end
|
@@ -3,49 +3,49 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe "YARD::Handlers::Ruby::#{LEGACY_PARSER ? "Legacy::" : ""}YieldHandler" do
|
4
4
|
before(:all) { parse_file :yield_handler_001, __FILE__ }
|
5
5
|
|
6
|
-
it "
|
7
|
-
P(:Testing).tag(:yield).
|
8
|
-
P(:Testing).tag(:yieldparam).
|
6
|
+
it "only parses yield blocks in methods" do
|
7
|
+
expect(P(:Testing).tag(:yield)).to be nil
|
8
|
+
expect(P(:Testing).tag(:yieldparam)).to be nil
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
12
|
-
P('Testing#mymethod').tag(:yield).
|
13
|
-
P('Testing#mymethod').tag(:yieldparam).
|
11
|
+
it "handles an empty yield statement" do
|
12
|
+
expect(P('Testing#mymethod').tag(:yield)).to be nil
|
13
|
+
expect(P('Testing#mymethod').tag(:yieldparam)).to be nil
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
17
|
-
P('Testing#mymethod2').tag(:yield).types.
|
18
|
-
P('Testing#mymethod2').tag(:yield).text.
|
19
|
-
P('Testing#mymethod2').tags(:yieldparam).size.
|
16
|
+
it "does not document a yield statement in a method with either @yield or @yieldparam" do
|
17
|
+
expect(P('Testing#mymethod2').tag(:yield).types).to eq ['a', 'b']
|
18
|
+
expect(P('Testing#mymethod2').tag(:yield).text).to eq "Blah"
|
19
|
+
expect(P('Testing#mymethod2').tags(:yieldparam).size).to eq 2
|
20
20
|
|
21
|
-
P('Testing#mymethod3').tag(:yield).types.
|
22
|
-
P('Testing#mymethod3').tags(:yieldparam).size.
|
21
|
+
expect(P('Testing#mymethod3').tag(:yield).types).to eq ['a', 'b']
|
22
|
+
expect(P('Testing#mymethod3').tags(:yieldparam).size).to eq 0
|
23
23
|
|
24
|
-
P('Testing#mymethod4').tag(:yieldparam).name.
|
25
|
-
P('Testing#mymethod4').tag(:yieldparam).text.
|
24
|
+
expect(P('Testing#mymethod4').tag(:yieldparam).name).to eq '_self'
|
25
|
+
expect(P('Testing#mymethod4').tag(:yieldparam).text).to eq 'BLAH'
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
29
|
-
P('Testing#mymethod5').tag(:yield).types.
|
28
|
+
it "handles any arbitrary yield statement" do
|
29
|
+
expect(P('Testing#mymethod5').tag(:yield).types).to eq [':a', 'b', '_self', 'File.read(\'file\', \'w\')', 'CONSTANT']
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
33
|
-
P('Testing#mymethod6').tag(:yield).types.
|
32
|
+
it "handles parentheses" do
|
33
|
+
expect(P('Testing#mymethod6').tag(:yield).types).to eq ['b', 'a']
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
37
|
-
P('Testing#mymethod7').tag(:yield).types.
|
36
|
+
it "only documents the first yield statement in a method (limitation of yield handler)" do
|
37
|
+
expect(P('Testing#mymethod7').tag(:yield).types).to eq ['a']
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
41
|
-
P('Testing#mymethod8').tag(:yield).types.
|
42
|
-
P('Testing#mymethod8').tag(:yieldparam).types.
|
43
|
-
P('Testing#mymethod8').tag(:yieldparam).text.
|
40
|
+
it "handles `self` keyword and list object type as yieldparam for _self" do
|
41
|
+
expect(P('Testing#mymethod8').tag(:yield).types).to eq ['_self']
|
42
|
+
expect(P('Testing#mymethod8').tag(:yieldparam).types).to eq ['Testing']
|
43
|
+
expect(P('Testing#mymethod8').tag(:yieldparam).text).to eq "the object that the method was called on"
|
44
44
|
end
|
45
45
|
|
46
|
-
it "
|
47
|
-
P('Testing#mymethod9').tag(:yield).types.
|
48
|
-
P('Testing#mymethod9').tag(:yieldparam).types.
|
49
|
-
P('Testing#mymethod9').tag(:yieldparam).text.
|
46
|
+
it "handles `super` keyword and document it under _super" do
|
47
|
+
expect(P('Testing#mymethod9').tag(:yield).types).to eq ['_super']
|
48
|
+
expect(P('Testing#mymethod9').tag(:yieldparam).types).to be nil
|
49
|
+
expect(P('Testing#mymethod9').tag(:yieldparam).text).to eq "the result of the method from the superclass"
|
50
50
|
end
|
51
51
|
end
|