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,16 +3,15 @@ require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
|
3
3
|
describe YARD::Parser, "tag handling" do
|
4
4
|
before { parse_file :tag_handler_001, __FILE__ }
|
5
5
|
|
6
|
-
it "
|
7
|
-
P("Foo#foo").tags.
|
6
|
+
it "knows the list of all available tags" do
|
7
|
+
expect(P("Foo#foo").tags).to include(P("Foo#foo").tag(:api))
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
11
|
-
P("Foo#foo").tag(:api).text.
|
10
|
+
it "knows the text of tags on a method" do
|
11
|
+
expect(P("Foo#foo").tag(:api).text).to eq "public"
|
12
12
|
end
|
13
13
|
|
14
|
-
it "
|
15
|
-
P("Foo#foo").has_tag?(:api).
|
14
|
+
it "returns true when asked whether a tag exists" do
|
15
|
+
expect(P("Foo#foo").has_tag?(:api)).to be true
|
16
16
|
end
|
17
|
-
|
18
17
|
end
|
@@ -7,12 +7,12 @@ describe YARD::Rake::YardocTask do
|
|
7
7
|
@yardoc.use_document_file = false
|
8
8
|
@yardoc.use_yardopts_file = false
|
9
9
|
@yardoc.generate = false
|
10
|
-
Templates::Engine.
|
11
|
-
Templates::Engine.
|
12
|
-
YARD.
|
13
|
-
Registry.
|
14
|
-
Registry.
|
15
|
-
YARD::CLI::Yardoc.
|
10
|
+
allow(Templates::Engine).to receive(:render)
|
11
|
+
allow(Templates::Engine).to receive(:generate)
|
12
|
+
allow(YARD).to receive(:parse)
|
13
|
+
allow(Registry).to receive(:load)
|
14
|
+
allow(Registry).to receive(:save)
|
15
|
+
allow(YARD::CLI::Yardoc).to receive(:new).and_return(@yardoc)
|
16
16
|
::Rake.application.clear
|
17
17
|
end
|
18
18
|
|
@@ -20,103 +20,93 @@ describe YARD::Rake::YardocTask do
|
|
20
20
|
::Rake.application.tasks[0].invoke
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
it "
|
23
|
+
describe "#initialize" do
|
24
|
+
it "allows separate rake task name to be set" do
|
25
25
|
YARD::Rake::YardocTask.new(:notyardoc)
|
26
|
-
::Rake.application.tasks[0].name.
|
26
|
+
expect(::Rake.application.tasks[0].name).to eq "notyardoc"
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
describe
|
31
|
-
it "
|
30
|
+
describe "#files" do
|
31
|
+
it "allows files to be set" do
|
32
32
|
YARD::Rake::YardocTask.new do |t|
|
33
33
|
t.files = ['a', 'b', 'c']
|
34
34
|
end
|
35
35
|
run
|
36
|
-
@yardoc.files.
|
36
|
+
expect(@yardoc.files).to eq %w(a b c)
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
describe
|
41
|
-
it "
|
40
|
+
describe "#options" do
|
41
|
+
it "allows extra options to be set" do
|
42
42
|
YARD::Rake::YardocTask.new do |t|
|
43
43
|
t.options = ['--private', '--protected']
|
44
44
|
end
|
45
45
|
run
|
46
|
-
@yardoc.visibilities.
|
46
|
+
expect(@yardoc.visibilities).to eq [:public, :private, :protected]
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
49
|
+
it "allows --api and --no-api" do
|
50
50
|
YARD::Rake::YardocTask.new do |t|
|
51
51
|
t.options = %w(--api public --no-api)
|
52
52
|
end
|
53
53
|
run
|
54
|
-
@yardoc.options.verifier.expressions.
|
55
|
-
should include('["public"].include?(@api.text) || !@api')
|
54
|
+
expect(@yardoc.options.verifier.expressions).to include('["public"].include?(@api.text) || !@api')
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
59
|
-
describe
|
58
|
+
describe "#stats_options" do
|
60
59
|
before do
|
61
60
|
@yard_stats = Object.new
|
62
|
-
@yard_stats.
|
63
|
-
YARD::CLI::Stats.
|
61
|
+
allow(@yard_stats).to receive(:run)
|
62
|
+
allow(YARD::CLI::Stats).to receive(:new).and_return(@yard_stats)
|
64
63
|
end
|
65
64
|
|
66
|
-
it "
|
67
|
-
@yard_stats.
|
68
|
-
@yardoc.statistics = true
|
69
|
-
YARD::Rake::YardocTask.new do |t|
|
70
|
-
end
|
71
|
-
run
|
72
|
-
@yardoc.statistics.should == true
|
73
|
-
end
|
74
|
-
|
75
|
-
it "should invoke stats" do
|
76
|
-
@yard_stats.should_receive(:run).with('--list-undoc', '--use-cache')
|
65
|
+
it "invokes stats" do
|
66
|
+
expect(@yard_stats).to receive(:run).with('--list-undoc', '--use-cache')
|
77
67
|
@yardoc.statistics = true
|
78
68
|
YARD::Rake::YardocTask.new do |t|
|
79
69
|
t.stats_options = %w(--list-undoc)
|
80
70
|
end
|
81
71
|
run
|
82
|
-
@yardoc.statistics.
|
72
|
+
expect(@yardoc.statistics).to be false
|
83
73
|
end
|
84
74
|
end
|
85
75
|
|
86
|
-
describe
|
87
|
-
it "
|
76
|
+
describe "#before" do
|
77
|
+
it "allows before callback" do
|
88
78
|
proc = lambda { }
|
89
|
-
proc.
|
90
|
-
@yardoc.
|
79
|
+
expect(proc).to receive(:call)
|
80
|
+
expect(@yardoc).to receive(:run)
|
91
81
|
YARD::Rake::YardocTask.new {|t| t.before = proc }
|
92
82
|
run
|
93
83
|
end
|
94
84
|
end
|
95
85
|
|
96
|
-
describe
|
97
|
-
it "
|
86
|
+
describe "#after" do
|
87
|
+
it "allows after callback" do
|
98
88
|
proc = lambda { }
|
99
|
-
proc.
|
100
|
-
@yardoc.
|
89
|
+
expect(proc).to receive(:call)
|
90
|
+
expect(@yardoc).to receive(:run)
|
101
91
|
YARD::Rake::YardocTask.new {|t| t.after = proc }
|
102
92
|
run
|
103
93
|
end
|
104
94
|
end
|
105
95
|
|
106
|
-
describe
|
107
|
-
it "
|
96
|
+
describe "#verifier" do
|
97
|
+
it "allows a verifier proc to be set" do
|
108
98
|
verifier = Verifier.new
|
109
|
-
@yardoc.
|
110
|
-
@yardoc.options[:verifier].
|
99
|
+
expect(@yardoc).to receive(:run) do
|
100
|
+
expect(@yardoc.options[:verifier]).to eq verifier
|
111
101
|
end
|
112
102
|
YARD::Rake::YardocTask.new {|t| t.verifier = verifier }
|
113
103
|
run
|
114
104
|
end
|
115
105
|
|
116
|
-
it "
|
106
|
+
it "overrides --query options" do
|
117
107
|
verifier = Verifier.new
|
118
|
-
@yardoc.
|
119
|
-
@yardoc.options[:verifier].
|
108
|
+
expect(@yardoc).to receive(:run) do
|
109
|
+
expect(@yardoc.options[:verifier]).to eq verifier
|
120
110
|
end
|
121
111
|
YARD::Rake::YardocTask.new do |t|
|
122
112
|
t.options += ['--query', '@return']
|
data/spec/registry_spec.rb
CHANGED
@@ -6,312 +6,312 @@ require "thread"
|
|
6
6
|
describe YARD::Registry do
|
7
7
|
before { Registry.clear }
|
8
8
|
|
9
|
-
describe
|
9
|
+
describe ".yardoc_file_for_gem" do
|
10
10
|
before do
|
11
|
-
@gem =
|
12
|
-
@gem.
|
13
|
-
@gem.
|
14
|
-
@gem.
|
11
|
+
@gem = double('gem')
|
12
|
+
allow(@gem).to receive(:name).and_return('foo')
|
13
|
+
allow(@gem).to receive(:full_name).and_return('foo-1.0')
|
14
|
+
allow(@gem).to receive(:full_gem_path).and_return('/path/to/foo')
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
18
|
-
Gem.source_index.
|
19
|
-
Registry.yardoc_file_for_gem('foo').
|
17
|
+
it "returns nil if gem isn't found" do
|
18
|
+
expect(Gem.source_index).to receive(:find_name).with('foo', '>= 0').and_return([])
|
19
|
+
expect(Registry.yardoc_file_for_gem('foo')).to eq nil
|
20
20
|
end
|
21
21
|
|
22
|
-
it "
|
23
|
-
Gem.source_index.
|
24
|
-
Registry.yardoc_file_for_gem('foo', '= 2').
|
22
|
+
it "allows version to be specified" do
|
23
|
+
expect(Gem.source_index).to receive(:find_name).with('foo', '= 2').and_return([])
|
24
|
+
expect(Registry.yardoc_file_for_gem('foo', '= 2')).to eq nil
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
28
|
-
File.
|
29
|
-
File.
|
30
|
-
Gem.source_index.
|
31
|
-
Registry.yardoc_file_for_gem('foo').
|
27
|
+
it "returns existing .yardoc path for gem when for_writing=false" do
|
28
|
+
expect(File).to receive(:exist?).and_return(false)
|
29
|
+
expect(File).to receive(:exist?).with('/path/to/foo/.yardoc').and_return(true)
|
30
|
+
expect(Gem.source_index).to receive(:find_name).with('foo', '>= 0').and_return([@gem])
|
31
|
+
expect(Registry.yardoc_file_for_gem('foo')).to eq '/path/to/foo/.yardoc'
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
35
|
-
File.
|
36
|
-
File.
|
37
|
-
Gem.source_index.
|
38
|
-
Registry.yardoc_file_for_gem('foo').
|
34
|
+
it "returns nil if no .yardoc path exists in gem when for_writing=false" do
|
35
|
+
expect(File).to receive(:exist?).and_return(false)
|
36
|
+
expect(File).to receive(:exist?).with('/path/to/foo/.yardoc').and_return(false)
|
37
|
+
expect(Gem.source_index).to receive(:find_name).with('foo', '>= 0').and_return([@gem])
|
38
|
+
expect(Registry.yardoc_file_for_gem('foo')).to eq nil
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
42
|
-
File.
|
43
|
-
Gem.source_index.
|
44
|
-
Registry.yardoc_file_for_gem('foo').
|
41
|
+
it "searches local gem path first if for_writing=false" do
|
42
|
+
expect(File).to receive(:exist?).and_return(true)
|
43
|
+
expect(Gem.source_index).to receive(:find_name).with('foo', '>= 0').and_return([@gem])
|
44
|
+
expect(Registry.yardoc_file_for_gem('foo')).to match %r{/.yard/gem_index/foo-1.0.yardoc$}
|
45
45
|
end
|
46
46
|
|
47
|
-
it "
|
48
|
-
File.
|
49
|
-
Gem.source_index.
|
50
|
-
Registry.yardoc_file_for_gem('foo', '>= 0', true).
|
47
|
+
it "returns global .yardoc path for gem if for_writing=true and dir is writable" do
|
48
|
+
expect(File).to receive(:writable?).with(@gem.full_gem_path).and_return(true)
|
49
|
+
expect(Gem.source_index).to receive(:find_name).with('foo', '>= 0').and_return([@gem])
|
50
|
+
expect(Registry.yardoc_file_for_gem('foo', '>= 0', true)).to eq '/path/to/foo/.yardoc'
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
54
|
-
File.
|
55
|
-
Gem.source_index.
|
56
|
-
Registry.yardoc_file_for_gem('foo', '>= 0', true).
|
53
|
+
it "returns local .yardoc path for gem if for_writing=true and dir is not writable" do
|
54
|
+
expect(File).to receive(:writable?).with(@gem.full_gem_path).and_return(false)
|
55
|
+
expect(Gem.source_index).to receive(:find_name).with('foo', '>= 0').and_return([@gem])
|
56
|
+
expect(Registry.yardoc_file_for_gem('foo', '>= 0', true)).to match %r{/.yard/gem_index/foo-1.0.yardoc$}
|
57
57
|
end
|
58
58
|
|
59
|
-
it "
|
60
|
-
@gem.
|
61
|
-
@gem.
|
62
|
-
@gem.
|
63
|
-
Gem.source_index.
|
64
|
-
File.
|
65
|
-
Registry.yardoc_file_for_gem('yard-doc-core').
|
59
|
+
it "returns gem path if gem starts with yard-doc- and for_writing=false" do
|
60
|
+
allow(@gem).to receive(:name).and_return('yard-doc-core')
|
61
|
+
allow(@gem).to receive(:full_name).and_return('yard-doc-core-1.0')
|
62
|
+
allow(@gem).to receive(:full_gem_path).and_return('/path/to/yard-doc-core')
|
63
|
+
expect(Gem.source_index).to receive(:find_name).with('yard-doc-core', '>= 0').and_return([@gem])
|
64
|
+
expect(File).to receive(:exist?).with('/path/to/yard-doc-core/.yardoc').and_return(true)
|
65
|
+
expect(Registry.yardoc_file_for_gem('yard-doc-core')).to eq '/path/to/yard-doc-core/.yardoc'
|
66
66
|
end
|
67
67
|
|
68
|
-
it "
|
69
|
-
@gem.
|
70
|
-
@gem.
|
71
|
-
@gem.
|
72
|
-
Gem.source_index.
|
73
|
-
File.
|
74
|
-
Registry.yardoc_file_for_gem('yard-doc-core', '>= 0', true).
|
68
|
+
it "returns nil if gem starts with yard-doc- and for_writing=true" do
|
69
|
+
allow(@gem).to receive(:name).and_return('yard-doc-core')
|
70
|
+
allow(@gem).to receive(:full_name).and_return('yard-doc-core-1.0')
|
71
|
+
allow(@gem).to receive(:full_gem_path).and_return('/path/to/yard-doc-core')
|
72
|
+
expect(Gem.source_index).to receive(:find_name).with('yard-doc-core', '>= 0').and_return([@gem])
|
73
|
+
expect(File).to receive(:exist?).with('/path/to/yard-doc-core/.yardoc').and_return(true)
|
74
|
+
expect(Registry.yardoc_file_for_gem('yard-doc-core', '>= 0', true)).to eq nil
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
|
-
describe
|
79
|
-
it "
|
80
|
-
Registry.root.path.
|
78
|
+
describe ".root" do
|
79
|
+
it "has an empty path for root" do
|
80
|
+
expect(Registry.root.path).to eq ""
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
describe
|
85
|
-
it "
|
84
|
+
describe ".locale" do
|
85
|
+
it "loads locale object" do
|
86
86
|
fr_locale = I18n::Locale.new("fr")
|
87
87
|
store = Registry.send(:thread_local_store)
|
88
|
-
store.
|
89
|
-
Registry.locale("fr").
|
88
|
+
expect(store).to receive(:locale).with("fr").and_return(fr_locale)
|
89
|
+
expect(Registry.locale("fr")).to eq fr_locale
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
93
|
-
describe
|
94
|
-
it "
|
93
|
+
describe ".resolve" do
|
94
|
+
it "resolves any existing namespace" do
|
95
95
|
o1 = ModuleObject.new(:root, :A)
|
96
96
|
o2 = ModuleObject.new(o1, :B)
|
97
97
|
o3 = ModuleObject.new(o2, :C)
|
98
|
-
Registry.resolve(o1, "B::C").
|
98
|
+
expect(Registry.resolve(o1, "B::C")).to eq o3
|
99
99
|
Registry.resolve(:root, "A::B::C")
|
100
100
|
end
|
101
101
|
|
102
|
-
it "
|
102
|
+
it "resolves an object in the root namespace when prefixed with ::" do
|
103
103
|
o1 = ModuleObject.new(:root, :A)
|
104
104
|
o2 = ModuleObject.new(o1, :B)
|
105
105
|
o3 = ModuleObject.new(o2, :C)
|
106
|
-
Registry.resolve(o3, "::A").
|
106
|
+
expect(Registry.resolve(o3, "::A")).to eq o1
|
107
107
|
|
108
|
-
Registry.resolve(o3, "::String", false, true).
|
108
|
+
expect(Registry.resolve(o3, "::String", false, true)).to eq P(:String)
|
109
109
|
end
|
110
110
|
|
111
|
-
it "
|
111
|
+
it "resolves instance methods with # prefix" do
|
112
112
|
o1 = ModuleObject.new(:root, :A)
|
113
113
|
o2 = ModuleObject.new(o1, :B)
|
114
114
|
o3 = ModuleObject.new(o2, :C)
|
115
115
|
o4 = MethodObject.new(o3, :methname)
|
116
|
-
Registry.resolve(o1, "B::C#methname").
|
117
|
-
Registry.resolve(o2, "C#methname").
|
118
|
-
Registry.resolve(o3, "#methname").
|
116
|
+
expect(Registry.resolve(o1, "B::C#methname")).to eq o4
|
117
|
+
expect(Registry.resolve(o2, "C#methname")).to eq o4
|
118
|
+
expect(Registry.resolve(o3, "#methname")).to eq o4
|
119
119
|
end
|
120
120
|
|
121
|
-
it "
|
121
|
+
it "resolves instance methods in the root without # prefix" do
|
122
122
|
o = MethodObject.new(:root, :methname)
|
123
|
-
Registry.resolve(:root, 'methname').
|
123
|
+
expect(Registry.resolve(:root, 'methname')).to eq o
|
124
124
|
end
|
125
125
|
|
126
|
-
it "
|
126
|
+
it "resolves superclass methods when inheritance = true" do
|
127
127
|
superyard = ClassObject.new(:root, :SuperYard)
|
128
128
|
yard = ClassObject.new(:root, :YARD)
|
129
129
|
yard.superclass = superyard
|
130
130
|
imeth = MethodObject.new(superyard, :hello)
|
131
131
|
cmeth = MethodObject.new(superyard, :class_hello, :class)
|
132
132
|
|
133
|
-
Registry.resolve(yard, "#hello", false).
|
134
|
-
Registry.resolve(yard, "#hello", true).
|
135
|
-
Registry.resolve(yard, "class_hello", false).
|
136
|
-
Registry.resolve(yard, "class_hello", true).
|
133
|
+
expect(Registry.resolve(yard, "#hello", false)).to be nil
|
134
|
+
expect(Registry.resolve(yard, "#hello", true)).to eq imeth
|
135
|
+
expect(Registry.resolve(yard, "class_hello", false)).to be nil
|
136
|
+
expect(Registry.resolve(yard, "class_hello", true)).to eq cmeth
|
137
137
|
end
|
138
138
|
|
139
|
-
it "
|
139
|
+
it "resolves mixin methods when inheritance = true" do
|
140
140
|
yard = ClassObject.new(:root, :YARD)
|
141
141
|
mixin = ModuleObject.new(:root, :Mixin)
|
142
142
|
yard.mixins(:instance) << mixin
|
143
143
|
imeth = MethodObject.new(mixin, :hello)
|
144
144
|
cmeth = MethodObject.new(mixin, :class_hello, :class)
|
145
145
|
|
146
|
-
Registry.resolve(yard, "#hello", false).
|
147
|
-
Registry.resolve(yard, "#hello", true).
|
148
|
-
Registry.resolve(yard, "class_hello", false).
|
149
|
-
Registry.resolve(yard, "class_hello", true).
|
146
|
+
expect(Registry.resolve(yard, "#hello", false)).to be nil
|
147
|
+
expect(Registry.resolve(yard, "#hello", true)).to eq imeth
|
148
|
+
expect(Registry.resolve(yard, "class_hello", false)).to be nil
|
149
|
+
expect(Registry.resolve(yard, "class_hello", true)).to eq cmeth
|
150
150
|
end
|
151
151
|
|
152
|
-
it "
|
152
|
+
it "resolves methods in Object when inheritance = true" do
|
153
153
|
YARD.parse_string <<-eof
|
154
154
|
class Object; def foo; end end
|
155
155
|
class A; end
|
156
156
|
class MyObject < A; end
|
157
157
|
eof
|
158
158
|
|
159
|
-
Registry.resolve(P('MyObject'), '#foo', true).
|
159
|
+
expect(Registry.resolve(P('MyObject'), '#foo', true)).to eq P('Object#foo')
|
160
160
|
end
|
161
161
|
|
162
|
-
it "
|
162
|
+
it "resolves methods in BasicObject when inheritance = true" do
|
163
163
|
YARD.parse_string <<-eof
|
164
164
|
class BasicObject; def foo; end end
|
165
165
|
class A; end
|
166
166
|
class MyObject < A; end
|
167
167
|
eof
|
168
168
|
|
169
|
-
Registry.resolve(P('MyObject'), '#foo', true).
|
169
|
+
expect(Registry.resolve(P('MyObject'), '#foo', true)).to eq P('BasicObject#foo')
|
170
170
|
end
|
171
171
|
|
172
|
-
it "
|
172
|
+
it "does not resolve methods in Object if inheriting BasicObject when inheritance = true" do
|
173
173
|
YARD.parse_string <<-eof
|
174
174
|
class Object; def foo; end end
|
175
175
|
class MyObject < BasicObject; end
|
176
176
|
eof
|
177
177
|
|
178
|
-
Registry.resolve(P('MyObject'), '#foo', true).
|
178
|
+
expect(Registry.resolve(P('MyObject'), '#foo', true)).to be nil
|
179
179
|
end
|
180
180
|
|
181
|
-
it "
|
181
|
+
it "allows type=:typename to ensure resolved object is of a certain type" do
|
182
182
|
YARD.parse_string "class Foo; end"
|
183
|
-
Registry.resolve(Registry.root, 'Foo').
|
184
|
-
Registry.resolve(Registry.root, 'Foo', false, false, :method).
|
183
|
+
expect(Registry.resolve(Registry.root, 'Foo')).to eq Registry.at('Foo')
|
184
|
+
expect(Registry.resolve(Registry.root, 'Foo', false, false, :method)).to be nil
|
185
185
|
end
|
186
186
|
|
187
|
-
it "
|
187
|
+
it "allows keep trying to find obj where type equals object type" do
|
188
188
|
YARD.parse_string <<-eof
|
189
189
|
module Foo
|
190
190
|
class Bar; end
|
191
191
|
def self.Bar; end
|
192
192
|
end
|
193
193
|
eof
|
194
|
-
Registry.resolve(P('Foo'), 'Bar').
|
195
|
-
Registry.resolve(P('Foo'), 'Bar', false, false, :method).
|
196
|
-
Registry.at('Foo.Bar')
|
194
|
+
expect(Registry.resolve(P('Foo'), 'Bar')).to eq Registry.at('Foo::Bar')
|
195
|
+
expect(Registry.resolve(P('Foo'), 'Bar', false, false, :method)).to eq(
|
196
|
+
Registry.at('Foo.Bar'))
|
197
197
|
end
|
198
198
|
|
199
|
-
it "
|
199
|
+
it "returns proxy fallback with given type if supplied" do
|
200
200
|
YARD.parse_string "module Foo; end"
|
201
201
|
proxy = Registry.resolve(P('Foo'), 'Bar', false, true, :method)
|
202
|
-
proxy.type.
|
202
|
+
expect(proxy.type).to eq :method
|
203
203
|
proxy = Registry.resolve(P('Qux'), 'Bar', false, true, :method)
|
204
|
-
proxy.type.
|
204
|
+
expect(proxy.type).to eq :method
|
205
205
|
end
|
206
206
|
|
207
|
-
it "
|
208
|
-
Registry.
|
207
|
+
it "only checks 'Path' in lookup on root namespace" do
|
208
|
+
expect(Registry).to receive(:at).once.with('Test').and_return(true)
|
209
209
|
Registry.resolve(Registry.root, "Test")
|
210
210
|
end
|
211
211
|
|
212
|
-
it "
|
212
|
+
it "does not perform lookup by joining namespace and name without separator" do
|
213
213
|
yard = ClassObject.new(:root, :YARD)
|
214
|
-
Registry.
|
214
|
+
expect(Registry).not_to receive(:at).with('YARDB')
|
215
215
|
Registry.resolve(yard, 'B')
|
216
216
|
end
|
217
217
|
end
|
218
218
|
|
219
|
-
describe
|
220
|
-
it "
|
219
|
+
describe ".all" do
|
220
|
+
it "returns objects of types specified by arguments" do
|
221
221
|
ModuleObject.new(:root, :A)
|
222
222
|
o1 = ClassObject.new(:root, :B)
|
223
223
|
o2 = MethodObject.new(:root, :testing)
|
224
224
|
r = Registry.all(:method, :class)
|
225
|
-
r.
|
225
|
+
expect(r).to include(o1, o2)
|
226
226
|
end
|
227
227
|
|
228
|
-
it "
|
228
|
+
it "returns code objects" do
|
229
229
|
o1 = ModuleObject.new(:root, :A)
|
230
230
|
o2 = ClassObject.new(:root, :B)
|
231
231
|
MethodObject.new(:root, :testing)
|
232
232
|
r = Registry.all.select {|t| NamespaceObject === t }
|
233
|
-
r.
|
233
|
+
expect(r).to include(o1, o2)
|
234
234
|
end
|
235
235
|
|
236
|
-
it "
|
236
|
+
it "allows .all to omit list" do
|
237
237
|
o1 = ModuleObject.new(:root, :A)
|
238
238
|
o2 = ClassObject.new(:root, :B)
|
239
239
|
r = Registry.all
|
240
|
-
r.
|
240
|
+
expect(r).to include(o1, o2)
|
241
241
|
end
|
242
242
|
end
|
243
243
|
|
244
|
-
describe
|
245
|
-
it "
|
244
|
+
describe ".paths" do
|
245
|
+
it "returns all object paths" do
|
246
246
|
o1 = ModuleObject.new(:root, :A)
|
247
247
|
o2 = ClassObject.new(:root, :B)
|
248
|
-
Registry.paths.
|
248
|
+
expect(Registry.paths).to include('A', 'B')
|
249
249
|
end
|
250
250
|
end
|
251
251
|
|
252
|
-
describe
|
253
|
-
it "
|
252
|
+
describe ".load_yardoc" do
|
253
|
+
it "delegates load to RegistryStore" do
|
254
254
|
store = RegistryStore.new
|
255
|
-
store.
|
256
|
-
RegistryStore.
|
255
|
+
expect(store).to receive(:load).with('foo')
|
256
|
+
expect(RegistryStore).to receive(:new).and_return(store)
|
257
257
|
Registry.yardoc_file = 'foo'
|
258
258
|
Registry.load_yardoc
|
259
259
|
end
|
260
260
|
|
261
|
-
it "
|
262
|
-
Registry.load_yardoc.
|
261
|
+
it "returns itself" do
|
262
|
+
expect(Registry.load_yardoc).to eq Registry
|
263
263
|
end
|
264
264
|
|
265
|
-
it "
|
265
|
+
it "maintains hash key equality on loaded objects" do
|
266
266
|
Registry.clear
|
267
267
|
Registry.load!(File.dirname(__FILE__) + '/serializers/data/serialized_yardoc')
|
268
268
|
baz = Registry.at('Foo#baz')
|
269
|
-
Registry.at('Foo').aliases.keys.
|
270
|
-
Registry.at('Foo').aliases.has_key?(baz).
|
269
|
+
expect(Registry.at('Foo').aliases.keys).to include(baz)
|
270
|
+
expect(Registry.at('Foo').aliases.has_key?(baz)).to be true
|
271
271
|
end
|
272
272
|
end
|
273
273
|
|
274
274
|
['load', 'load_all', 'load!'].each do |meth|
|
275
275
|
describe('.' + meth) do
|
276
|
-
it "
|
277
|
-
Registry.send(meth).
|
276
|
+
it "returns itself" do
|
277
|
+
expect(Registry.send(meth)).to eq Registry
|
278
278
|
end
|
279
279
|
end
|
280
280
|
end
|
281
281
|
|
282
|
-
describe
|
282
|
+
describe ".each" do
|
283
283
|
before do
|
284
284
|
YARD.parse_string "def a; end; def b; end; def c; end"
|
285
285
|
end
|
286
286
|
|
287
287
|
after { Registry.clear }
|
288
288
|
|
289
|
-
it "
|
289
|
+
it "iterates over .all" do
|
290
290
|
items = []
|
291
291
|
Registry.each {|x| items << x.path }
|
292
|
-
items.sort.
|
292
|
+
expect(items.sort).to eq ['#a', '#b', '#c']
|
293
293
|
end
|
294
294
|
|
295
|
-
it "
|
296
|
-
Registry.find {|x| x.path == "#a" }.
|
295
|
+
it "includes Enumerable and allow for find, select" do
|
296
|
+
expect(Registry.find {|x| x.path == "#a" }).to be_a(CodeObjects::MethodObject)
|
297
297
|
end
|
298
298
|
end
|
299
299
|
|
300
|
-
describe
|
301
|
-
it "
|
302
|
-
Registry.instance.
|
300
|
+
describe ".instance" do
|
301
|
+
it "returns itself" do
|
302
|
+
expect(Registry.instance).to eq Registry
|
303
303
|
end
|
304
304
|
end
|
305
305
|
|
306
|
-
describe
|
307
|
-
it "
|
308
|
-
Registry.single_object_db.
|
309
|
-
Thread.new { Registry.single_object_db.
|
306
|
+
describe ".single_object_db" do
|
307
|
+
it "defaults to nil" do
|
308
|
+
expect(Registry.single_object_db).to eq nil
|
309
|
+
Thread.new { expect(Registry.single_object_db).to eq nil }.join
|
310
310
|
end
|
311
311
|
end
|
312
312
|
|
313
|
-
describe
|
314
|
-
it "
|
313
|
+
describe "Thread local" do
|
314
|
+
it "maintains two Registries in separate threads" do
|
315
315
|
barrier = 0
|
316
316
|
mutex = Mutex.new
|
317
317
|
threads = []
|
@@ -322,7 +322,7 @@ describe YARD::Registry do
|
|
322
322
|
while barrier < 2 do
|
323
323
|
s = "barrier < 2, spinning"
|
324
324
|
end
|
325
|
-
Registry.at('Foo').docstring.
|
325
|
+
expect(Registry.at('Foo').docstring).to eq "docstring 1"
|
326
326
|
end
|
327
327
|
threads << Thread.new do
|
328
328
|
Registry.clear
|
@@ -331,29 +331,29 @@ describe YARD::Registry do
|
|
331
331
|
while barrier < 2 do
|
332
332
|
s = "barrier < 2, spinning"
|
333
333
|
end
|
334
|
-
Registry.at('Foo').docstring.
|
334
|
+
expect(Registry.at('Foo').docstring).to eq "docstring 2"
|
335
335
|
end
|
336
336
|
threads.each {|t| t.join }
|
337
337
|
end
|
338
338
|
|
339
|
-
it "
|
339
|
+
it "allows setting of yardoc_file in separate threads" do
|
340
340
|
barrier = 0
|
341
341
|
mutex = Mutex.new
|
342
342
|
threads = []
|
343
343
|
threads << Thread.new do
|
344
|
-
Registry.yardoc_file.
|
344
|
+
expect(Registry.yardoc_file).to eq '.yardoc'
|
345
345
|
Registry.yardoc_file = 'foo'
|
346
346
|
mutex.synchronize { barrier += 1 }
|
347
347
|
while barrier == 1 do
|
348
348
|
s = "barrier = 1, spinning"
|
349
349
|
end
|
350
|
-
Registry.yardoc_file.
|
350
|
+
expect(Registry.yardoc_file).to eq 'foo'
|
351
351
|
end
|
352
352
|
threads << Thread.new do
|
353
353
|
while barrier == 0 do
|
354
354
|
s = "barrier = 0, spinning"
|
355
355
|
end
|
356
|
-
Registry.yardoc_file.
|
356
|
+
expect(Registry.yardoc_file).to eq '.yardoc'
|
357
357
|
mutex.synchronize { barrier += 1 }
|
358
358
|
Registry.yardoc_file = 'foo2'
|
359
359
|
end
|
@@ -361,28 +361,28 @@ describe YARD::Registry do
|
|
361
361
|
Registry.yardoc_file = Registry::DEFAULT_YARDOC_FILE
|
362
362
|
end
|
363
363
|
|
364
|
-
it "
|
365
|
-
Thread.new { Registry.all.
|
364
|
+
it "automatically clears in new threads" do
|
365
|
+
Thread.new { expect(Registry.all).to be_empty }.join
|
366
366
|
end
|
367
367
|
|
368
|
-
it "
|
368
|
+
it "allows setting of po_dir in separate threads" do
|
369
369
|
barrier = 0
|
370
370
|
mutex = Mutex.new
|
371
371
|
threads = []
|
372
372
|
threads << Thread.new do
|
373
|
-
Registry.po_dir.
|
373
|
+
expect(Registry.po_dir).to eq 'po'
|
374
374
|
Registry.po_dir = 'locale'
|
375
375
|
mutex.synchronize { barrier += 1 }
|
376
376
|
while barrier == 1 do
|
377
377
|
s = "barrier = 1, spinning"
|
378
378
|
end
|
379
|
-
Registry.po_dir.
|
379
|
+
expect(Registry.po_dir).to eq 'locale'
|
380
380
|
end
|
381
381
|
threads << Thread.new do
|
382
382
|
while barrier == 0 do
|
383
383
|
s = "barrier = 0, spinning"
|
384
384
|
end
|
385
|
-
Registry.po_dir.
|
385
|
+
expect(Registry.po_dir).to eq 'po'
|
386
386
|
mutex.synchronize { barrier += 1 }
|
387
387
|
Registry.po_dir = '.'
|
388
388
|
end
|