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
data/spec/cli/config_spec.rb
CHANGED
@@ -6,86 +6,86 @@ describe YARD::CLI::Config do
|
|
6
6
|
before do
|
7
7
|
@config = YARD::CLI::Config.new
|
8
8
|
YARD::Config.options = YARD::Config::DEFAULT_CONFIG_OPTIONS.dup
|
9
|
-
YARD::Config.
|
9
|
+
allow(YARD::Config).to receive(:save)
|
10
10
|
end
|
11
11
|
|
12
12
|
def run(*args)
|
13
13
|
@config.run(*args)
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
17
|
-
it "
|
16
|
+
describe "Listing configuration" do
|
17
|
+
it "accepts --list" do
|
18
18
|
opts = YARD::Config.options
|
19
|
-
YAML.
|
20
|
-
log.
|
19
|
+
expect(YAML).to receive(:dump).twice.and_return("--- foo\nbar\nbaz")
|
20
|
+
expect(log).to receive(:puts).twice.with("bar\nbaz")
|
21
21
|
run
|
22
22
|
run('--list')
|
23
|
-
YARD::Config.options.
|
23
|
+
expect(YARD::Config.options).to eq opts
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
describe
|
28
|
-
it "
|
27
|
+
describe "Viewing an item" do
|
28
|
+
it "views item if no value is given" do
|
29
29
|
YARD::Config.options[:foo] = 'bar'
|
30
|
-
log.
|
30
|
+
expect(log).to receive(:puts).with('"bar"')
|
31
31
|
run 'foo'
|
32
|
-
YARD::Config.options[:foo].
|
32
|
+
expect(YARD::Config.options[:foo]).to eq 'bar'
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe
|
37
|
-
it "
|
36
|
+
describe "Modifying an item" do
|
37
|
+
it "accepts --reset to set value" do
|
38
38
|
YARD::Config.options[:load_plugins] = 'foo'
|
39
39
|
run('--reset', 'load_plugins')
|
40
|
-
YARD::Config.options[:load_plugins].
|
40
|
+
expect(YARD::Config.options[:load_plugins]).to be false
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
43
|
+
it "accepts --as-list to force single item as list" do
|
44
44
|
run('--as-list', 'foo', 'bar')
|
45
|
-
YARD::Config.options[:foo].
|
45
|
+
expect(YARD::Config.options[:foo]).to eq ['bar']
|
46
46
|
end
|
47
47
|
|
48
|
-
it "
|
48
|
+
it "accepts --append to append values to existing key" do
|
49
49
|
YARD::Config.options[:foo] = ['bar']
|
50
50
|
run('--append', 'foo', 'baz', 'quux')
|
51
|
-
YARD::Config.options[:foo].
|
51
|
+
expect(YARD::Config.options[:foo]).to eq ['bar', 'baz', 'quux']
|
52
52
|
run('-a', 'foo', 'last')
|
53
|
-
YARD::Config.options[:foo].
|
53
|
+
expect(YARD::Config.options[:foo]).to eq ['bar', 'baz', 'quux', 'last']
|
54
54
|
end
|
55
55
|
|
56
|
-
it "
|
56
|
+
it "turns key into list if --append is used on single item" do
|
57
57
|
YARD::Config.options[:foo] = 'bar'
|
58
58
|
run('-a', 'foo', 'baz')
|
59
|
-
YARD::Config.options[:foo].
|
59
|
+
expect(YARD::Config.options[:foo]).to eq ['bar', 'baz']
|
60
60
|
end
|
61
61
|
|
62
|
-
it "
|
62
|
+
it "modifies item if value is given" do
|
63
63
|
run('foo', 'xxx')
|
64
|
-
YARD::Config.options[:foo].
|
64
|
+
expect(YARD::Config.options[:foo]).to eq 'xxx'
|
65
65
|
end
|
66
66
|
|
67
|
-
it "
|
67
|
+
it "turns list of values into array of values" do
|
68
68
|
run('foo', 'a', 'b', '1', 'true', 'false')
|
69
|
-
YARD::Config.options[:foo].
|
69
|
+
expect(YARD::Config.options[:foo]).to eq ['a', 'b', 1, true, false]
|
70
70
|
end
|
71
71
|
|
72
|
-
it "
|
72
|
+
it "turns number into numeric Ruby type" do
|
73
73
|
run('foo', '1')
|
74
|
-
YARD::Config.options[:foo].
|
74
|
+
expect(YARD::Config.options[:foo]).to eq 1
|
75
75
|
end
|
76
76
|
|
77
|
-
it "
|
77
|
+
it "turns true into TrueClass" do
|
78
78
|
run('foo', 'true')
|
79
|
-
YARD::Config.options[:foo].
|
79
|
+
expect(YARD::Config.options[:foo]).to be true
|
80
80
|
end
|
81
81
|
|
82
|
-
it "
|
82
|
+
it "turns false into FalseClass" do
|
83
83
|
run('foo', 'false')
|
84
|
-
YARD::Config.options[:foo].
|
84
|
+
expect(YARD::Config.options[:foo]).to be false
|
85
85
|
end
|
86
86
|
|
87
|
-
it "
|
88
|
-
YARD::Config.
|
87
|
+
it "saves on modification" do
|
88
|
+
expect(YARD::Config).to receive(:save)
|
89
89
|
run('foo', 'true')
|
90
90
|
end
|
91
91
|
end
|
data/spec/cli/diff_spec.rb
CHANGED
@@ -4,20 +4,20 @@ require 'open-uri'
|
|
4
4
|
|
5
5
|
describe YARD::CLI::Diff do
|
6
6
|
before do
|
7
|
-
CLI::Yardoc.
|
8
|
-
CLI::Gems.
|
7
|
+
allow(CLI::Yardoc).to receive(:run)
|
8
|
+
allow(CLI::Gems).to receive(:run)
|
9
9
|
@diff = CLI::Diff.new
|
10
10
|
end
|
11
11
|
|
12
|
-
describe
|
13
|
-
it "
|
14
|
-
@diff.
|
15
|
-
log.
|
12
|
+
describe "Argument handling" do
|
13
|
+
it "exits if there is only one gem name" do
|
14
|
+
expect(@diff).to receive(:exit)
|
15
|
+
expect(log).to receive(:puts).with(/Usage/)
|
16
16
|
@diff.run
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
describe
|
20
|
+
describe "Diffing" do
|
21
21
|
before do
|
22
22
|
@objects1 = nil
|
23
23
|
@objects2 = nil
|
@@ -29,7 +29,7 @@ describe YARD::CLI::Diff do
|
|
29
29
|
@objects1 ||= %w( C#fooey C#baz D.bar )
|
30
30
|
@objects2 ||= %w( A A::B A::B::C A.foo A#foo B C.foo C.bar C#baz )
|
31
31
|
@objects = [@objects1, @objects2]
|
32
|
-
@diff.
|
32
|
+
expect(@diff).to receive(:load_gem_data).ordered.with('gem1') do
|
33
33
|
Registry.clear
|
34
34
|
YARD.parse_string <<-eof
|
35
35
|
class C
|
@@ -41,7 +41,7 @@ describe YARD::CLI::Diff do
|
|
41
41
|
end
|
42
42
|
eof
|
43
43
|
end
|
44
|
-
@diff.
|
44
|
+
expect(@diff).to receive(:load_gem_data).ordered.with('gem2') do
|
45
45
|
Registry.clear
|
46
46
|
YARD.parse_string <<-eof
|
47
47
|
module A
|
@@ -58,14 +58,14 @@ describe YARD::CLI::Diff do
|
|
58
58
|
end
|
59
59
|
eof
|
60
60
|
end
|
61
|
-
log.
|
62
|
-
log.
|
61
|
+
allow(log).to receive(:print) {|data| @data << data }
|
62
|
+
allow(log).to receive(:puts) {|*args| @data << args.join("\n"); @data << "\n" }
|
63
63
|
@diff.run(*(args + ['gem1', 'gem2']))
|
64
64
|
end
|
65
65
|
|
66
|
-
it "
|
66
|
+
it "shows differences between objects" do
|
67
67
|
run
|
68
|
-
@data.string.
|
68
|
+
expect(@data.string).to eq <<-eof
|
69
69
|
Added objects:
|
70
70
|
|
71
71
|
A ((stdin):1) (...)
|
@@ -85,9 +85,9 @@ Removed objects:
|
|
85
85
|
eof
|
86
86
|
end
|
87
87
|
|
88
|
-
it "
|
88
|
+
it "accepts --compact" do
|
89
89
|
run('--compact')
|
90
|
-
@data.string.
|
90
|
+
expect(@data.string).to eq <<-eof
|
91
91
|
A A ((stdin):1) (...)
|
92
92
|
A A::B::C ((stdin):3)
|
93
93
|
A C.bar ((stdin):10)
|
@@ -98,10 +98,10 @@ D D ((stdin):5) (...)
|
|
98
98
|
eof
|
99
99
|
end
|
100
100
|
|
101
|
-
it "
|
101
|
+
it "accepts -a/--all" do
|
102
102
|
['-a', '--all'].each do |opt|
|
103
103
|
run(opt)
|
104
|
-
@data.string.
|
104
|
+
expect(@data.string).to eq <<-eof
|
105
105
|
Added objects:
|
106
106
|
|
107
107
|
A ((stdin):1)
|
@@ -126,9 +126,9 @@ eof
|
|
126
126
|
end
|
127
127
|
end
|
128
128
|
|
129
|
-
it "
|
129
|
+
it "accepts --compact and --all" do
|
130
130
|
run('--compact', '--all')
|
131
|
-
@data.string.
|
131
|
+
expect(@data.string).to eq <<-eof
|
132
132
|
A A ((stdin):1)
|
133
133
|
A A#foo ((stdin):6)
|
134
134
|
A A.foo ((stdin):5)
|
@@ -143,9 +143,9 @@ D D.bar ((stdin):6)
|
|
143
143
|
eof
|
144
144
|
end
|
145
145
|
|
146
|
-
it "
|
146
|
+
it "accepts --no-modified" do
|
147
147
|
run('--compact', '--no-modified')
|
148
|
-
@data.string.
|
148
|
+
expect(@data.string).to eq <<-eof
|
149
149
|
A A ((stdin):1) (...)
|
150
150
|
A A::B::C ((stdin):3)
|
151
151
|
A C.bar ((stdin):10)
|
@@ -155,9 +155,9 @@ D D ((stdin):5) (...)
|
|
155
155
|
eof
|
156
156
|
end
|
157
157
|
|
158
|
-
it "
|
158
|
+
it "accepts --query" do
|
159
159
|
run('--compact', '--query', 'o.type == :method')
|
160
|
-
@data.string.
|
160
|
+
expect(@data.string).to eq <<-eof
|
161
161
|
A A#foo ((stdin):6)
|
162
162
|
A A.foo ((stdin):5)
|
163
163
|
A C.bar ((stdin):10)
|
@@ -169,91 +169,87 @@ eof
|
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
172
|
-
describe
|
172
|
+
describe "File searching" do
|
173
173
|
before do
|
174
|
-
@diff.
|
174
|
+
allow(@diff).to receive(:generate_yardoc)
|
175
175
|
end
|
176
176
|
|
177
|
-
it "
|
178
|
-
File.
|
179
|
-
File.
|
180
|
-
Registry.
|
181
|
-
Registry.
|
177
|
+
it "searches for gem/.yardoc" do
|
178
|
+
expect(File).to receive(:directory?).with('gem1/.yardoc').and_return(true)
|
179
|
+
expect(File).to receive(:directory?).with('gem2/.yardoc').and_return(true)
|
180
|
+
expect(Registry).to receive(:load_yardoc).with('gem1/.yardoc')
|
181
|
+
expect(Registry).to receive(:load_yardoc).with('gem2/.yardoc')
|
182
182
|
@diff.run('gem1', 'gem2')
|
183
183
|
end
|
184
184
|
|
185
|
-
it "
|
186
|
-
File.
|
187
|
-
File.
|
188
|
-
File.
|
189
|
-
File.
|
190
|
-
Registry.
|
191
|
-
Registry.
|
185
|
+
it "searches for argument as yardoc" do
|
186
|
+
expect(File).to receive(:directory?).with('gem1/.yardoc').and_return(false)
|
187
|
+
expect(File).to receive(:directory?).with('gem2/.yardoc').and_return(false)
|
188
|
+
expect(File).to receive(:directory?).with('gem1').and_return(true)
|
189
|
+
expect(File).to receive(:directory?).with('gem2').and_return(true)
|
190
|
+
expect(Registry).to receive(:load_yardoc).with('gem1')
|
191
|
+
expect(Registry).to receive(:load_yardoc).with('gem2')
|
192
192
|
@diff.run('gem1', 'gem2')
|
193
193
|
end
|
194
194
|
|
195
|
-
it "
|
196
|
-
File.
|
197
|
-
File.
|
198
|
-
File.
|
199
|
-
File.
|
200
|
-
gemmock =
|
201
|
-
spec1
|
202
|
-
spec2
|
203
|
-
gemmock.
|
204
|
-
Gem.
|
205
|
-
spec1.
|
206
|
-
spec1.
|
207
|
-
spec1.
|
208
|
-
spec2.
|
209
|
-
spec2.
|
210
|
-
spec2.
|
211
|
-
Registry.
|
212
|
-
Registry.
|
213
|
-
Registry.
|
214
|
-
CLI::Gems.
|
215
|
-
Dir.
|
195
|
+
it "searches for installed gem" do
|
196
|
+
expect(File).to receive(:directory?).with('gem1-1.0.0.gem/.yardoc').and_return(false)
|
197
|
+
expect(File).to receive(:directory?).with('gem2-1.0.0/.yardoc').and_return(false)
|
198
|
+
expect(File).to receive(:directory?).with('gem1-1.0.0.gem').and_return(false)
|
199
|
+
expect(File).to receive(:directory?).with('gem2-1.0.0').and_return(false)
|
200
|
+
gemmock = double(:gemmock)
|
201
|
+
spec1 = double(:spec)
|
202
|
+
spec2 = double(:spec)
|
203
|
+
expect(gemmock).to receive(:find_name).at_least(1).times.and_return([spec1, spec2])
|
204
|
+
expect(Gem).to receive(:source_index).at_least(1).times.and_return(gemmock)
|
205
|
+
allow(spec1).to receive(:full_name).and_return('gem1-1.0.0')
|
206
|
+
allow(spec1).to receive(:name).and_return('gem1')
|
207
|
+
allow(spec1).to receive(:version).and_return('1.0.0')
|
208
|
+
allow(spec2).to receive(:full_name).and_return('gem2-1.0.0')
|
209
|
+
allow(spec2).to receive(:name).and_return('gem2')
|
210
|
+
allow(spec2).to receive(:version).and_return('1.0.0')
|
211
|
+
expect(Registry).to receive(:yardoc_file_for_gem).with('gem1', '= 1.0.0').and_return('/path/to/file')
|
212
|
+
expect(Registry).to receive(:yardoc_file_for_gem).with('gem2', '= 1.0.0').and_return(nil)
|
213
|
+
expect(Registry).to receive(:load_yardoc).with('/path/to/file')
|
214
|
+
expect(CLI::Gems).to receive(:run).with('gem2', '1.0.0').and_return(nil)
|
215
|
+
allow(Dir).to receive(:chdir)
|
216
216
|
@diff.run('gem1-1.0.0.gem', 'gem2-1.0.0')
|
217
217
|
end
|
218
218
|
|
219
|
-
it "
|
220
|
-
File.
|
221
|
-
File.
|
222
|
-
File.
|
223
|
-
File.
|
224
|
-
File.
|
225
|
-
File.
|
226
|
-
File.
|
227
|
-
File.
|
228
|
-
|
229
|
-
|
230
|
-
FileUtils.
|
231
|
-
Gem::Package.stub(:open)
|
232
|
-
FileUtils.stub(:rm_rf)
|
219
|
+
it "searches for .gem file" do
|
220
|
+
expect(File).to receive(:directory?).with('gem1/.yardoc').and_return(false)
|
221
|
+
expect(File).to receive(:directory?).with('gem2.gem/.yardoc').and_return(false)
|
222
|
+
expect(File).to receive(:directory?).with('gem1').and_return(false)
|
223
|
+
expect(File).to receive(:directory?).with('gem2.gem').and_return(false)
|
224
|
+
expect(File).to receive(:exist?).with('gem1.gem').and_return(true)
|
225
|
+
expect(File).to receive(:exist?).with('gem2.gem').and_return(true)
|
226
|
+
expect(File).to receive(:open).with('gem1.gem', 'rb')
|
227
|
+
expect(File).to receive(:open).with('gem2.gem', 'rb')
|
228
|
+
allow(FileUtils).to receive(:mkdir_p)
|
229
|
+
allow(Gem::Package).to receive(:open)
|
230
|
+
allow(FileUtils).to receive(:rm_rf)
|
233
231
|
@diff.run('gem1', 'gem2.gem')
|
234
232
|
end
|
235
233
|
|
236
|
-
it "
|
237
|
-
File.
|
238
|
-
File.
|
239
|
-
File.
|
240
|
-
File.
|
241
|
-
File.
|
242
|
-
File.
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
FileUtils.
|
248
|
-
Gem::Package.stub(:open)
|
249
|
-
FileUtils.stub(:rm_rf)
|
234
|
+
it "searches for .gem file on rubygems.org" do
|
235
|
+
expect(File).to receive(:directory?).with('gem1/.yardoc').and_return(false)
|
236
|
+
expect(File).to receive(:directory?).with('gem2.gem/.yardoc').and_return(false)
|
237
|
+
expect(File).to receive(:directory?).with('gem1').and_return(false)
|
238
|
+
expect(File).to receive(:directory?).with('gem2.gem').and_return(false)
|
239
|
+
expect(File).to receive(:exist?).with('gem1.gem').and_return(false)
|
240
|
+
expect(File).to receive(:exist?).with('gem2.gem').and_return(false)
|
241
|
+
expect(@diff).to receive(:open).with('http://rubygems.org/downloads/gem1.gem')
|
242
|
+
expect(@diff).to receive(:open).with('http://rubygems.org/downloads/gem2.gem')
|
243
|
+
allow(FileUtils).to receive(:mkdir_p)
|
244
|
+
allow(Gem::Package).to receive(:open)
|
245
|
+
allow(FileUtils).to receive(:rm_rf)
|
250
246
|
@diff.run('gem1', 'gem2.gem')
|
251
247
|
end
|
252
248
|
|
253
|
-
it "
|
254
|
-
log.
|
255
|
-
log.
|
256
|
-
@diff.
|
249
|
+
it "raises an error if gem is not found" do
|
250
|
+
expect(log).to receive(:error).with("Cannot find gem gem1")
|
251
|
+
expect(log).to receive(:error).with("Cannot find gem gem2.gem")
|
252
|
+
allow(@diff).to receive(:load_gem_data).and_return(false)
|
257
253
|
@diff.run('gem1', 'gem2.gem')
|
258
254
|
end
|
259
255
|
end
|
data/spec/cli/display_spec.rb
CHANGED
@@ -2,29 +2,29 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
2
|
|
3
3
|
describe YARD::CLI::Display do
|
4
4
|
before do
|
5
|
-
Registry.
|
5
|
+
allow(Registry).to receive(:load)
|
6
6
|
@object = CodeObjects::ClassObject.new(:root, :Foo)
|
7
7
|
@object.docstring = 'Foo bar'
|
8
8
|
end
|
9
9
|
|
10
10
|
it "displays an object" do
|
11
11
|
YARD::CLI::Display.run('-f', 'text', 'Foo')
|
12
|
-
log.io.string.strip.
|
12
|
+
expect(log.io.string.strip).to eq(@object.format.strip)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "wraps output with -l (defaulting to layout)" do
|
16
16
|
YARD::CLI::Display.run('-l', '-f', 'html', 'Foo')
|
17
17
|
formatted_output = @object.format(:format => :html).strip
|
18
18
|
actual_output = log.io.string.strip
|
19
|
-
actual_output.
|
20
|
-
actual_output.
|
19
|
+
expect(actual_output).not_to eq(formatted_output)
|
20
|
+
expect(actual_output).to include(formatted_output)
|
21
21
|
end
|
22
22
|
|
23
23
|
it "wraps output with --layout onefile" do
|
24
24
|
YARD::CLI::Display.run('--layout', 'onefile', '-f', 'html', 'Foo')
|
25
25
|
formatted_output = @object.format(:format => :html).strip
|
26
26
|
actual_output = log.io.string.strip
|
27
|
-
actual_output.
|
28
|
-
actual_output.
|
27
|
+
expect(actual_output).not_to eq(formatted_output)
|
28
|
+
expect(actual_output).to include(formatted_output)
|
29
29
|
end
|
30
30
|
end
|
data/spec/cli/gems_spec.rb
CHANGED
@@ -19,62 +19,62 @@ describe YARD::CLI::Gems do
|
|
19
19
|
|
20
20
|
def build_specs(*specs)
|
21
21
|
specs.each do |themock|
|
22
|
-
Registry.
|
23
|
-
File.
|
24
|
-
File.
|
25
|
-
Registry.
|
26
|
-
Dir.
|
22
|
+
expect(Registry).to receive(:yardoc_file_for_gem).with(themock.name, "= #{themock.version}").and_return(themock.yardoc_file)
|
23
|
+
expect(File).to receive(:directory?).with(themock.yardoc_file).and_return(@rebuild)
|
24
|
+
expect(File).to receive(:directory?).with(themock.full_gem_path).and_return(true)
|
25
|
+
expect(Registry).to receive(:yardoc_file_for_gem).with(themock.name, "= #{themock.version}", true).and_return(themock.yardoc_file)
|
26
|
+
expect(Dir).to receive(:chdir).with(themock.full_gem_path)
|
27
27
|
end
|
28
|
-
Registry.
|
29
|
-
CLI::Yardoc.
|
28
|
+
expect(Registry).to receive(:clear).exactly(specs.size).times
|
29
|
+
expect(CLI::Yardoc).to receive(:run).exactly(specs.size).times
|
30
30
|
end
|
31
31
|
|
32
|
-
describe
|
33
|
-
it "
|
32
|
+
describe "#run" do
|
33
|
+
it "builds all gem indexes if no gem is specified" do
|
34
34
|
build_specs(@gem1, @gem2)
|
35
|
-
Gem.source_index.
|
35
|
+
expect(Gem.source_index).to receive(:find_name).with('').and_return([@gem1, @gem2])
|
36
36
|
CLI::Gems.run
|
37
37
|
end
|
38
38
|
|
39
|
-
it "
|
39
|
+
it "allows gem to be specified" do
|
40
40
|
build_specs(@gem1)
|
41
|
-
Gem.source_index.
|
41
|
+
expect(Gem.source_index).to receive(:find_name).with(@gem1.name, '>= 0').and_return([@gem1])
|
42
42
|
CLI::Gems.run(@gem1.name)
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
45
|
+
it "allows multiple gems to be specified for building" do
|
46
46
|
build_specs(@gem1, @gem2)
|
47
|
-
Gem.source_index.
|
48
|
-
Gem.source_index.
|
47
|
+
expect(Gem.source_index).to receive(:find_name).with(@gem1.name, @gem1.version).and_return([@gem1])
|
48
|
+
expect(Gem.source_index).to receive(:find_name).with(@gem2.name, '>= 0').and_return([@gem2])
|
49
49
|
CLI::Gems.run(@gem1.name, @gem1.version, @gem2.name)
|
50
50
|
end
|
51
51
|
|
52
|
-
it "
|
52
|
+
it "allows version to be specified with gem" do
|
53
53
|
build_specs(@gem1)
|
54
|
-
Gem.source_index.
|
54
|
+
expect(Gem.source_index).to receive(:find_name).with(@gem1.name, '>= 1.0').and_return([@gem1])
|
55
55
|
CLI::Gems.run(@gem1.name, '>= 1.0')
|
56
56
|
end
|
57
57
|
|
58
|
-
it "
|
58
|
+
it "warns if one of the gems is not found, but it should process others" do
|
59
59
|
build_specs(@gem2)
|
60
|
-
Gem.source_index.
|
61
|
-
Gem.source_index.
|
62
|
-
log.
|
60
|
+
expect(Gem.source_index).to receive(:find_name).with(@gem1.name, '>= 2.0').and_return([])
|
61
|
+
expect(Gem.source_index).to receive(:find_name).with(@gem2.name, '>= 0').and_return([@gem2])
|
62
|
+
expect(log).to receive(:warn).with(/#{@gem1.name} >= 2.0 could not be found/)
|
63
63
|
CLI::Gems.run(@gem1.name, '>= 2.0', @gem2.name)
|
64
64
|
end
|
65
65
|
|
66
|
-
it "
|
67
|
-
CLI::Yardoc.
|
68
|
-
Gem.source_index.
|
69
|
-
log.
|
70
|
-
log.
|
66
|
+
it "fails if specified gem(s) is/are not found" do
|
67
|
+
expect(CLI::Yardoc).not_to receive(:run)
|
68
|
+
expect(Gem.source_index).to receive(:find_name).with(@gem1.name, '>= 2.0').and_return([])
|
69
|
+
expect(log).to receive(:warn).with(/#{@gem1.name} >= 2.0 could not be found/)
|
70
|
+
expect(log).to receive(:error).with(/No specified gems could be found/)
|
71
71
|
CLI::Gems.run(@gem1.name, '>= 2.0')
|
72
72
|
end
|
73
73
|
|
74
|
-
it "
|
74
|
+
it "accepts --rebuild" do
|
75
75
|
@rebuild = true
|
76
76
|
build_specs(@gem1)
|
77
|
-
Gem.source_index.
|
77
|
+
expect(Gem.source_index).to receive(:find_name).with('').and_return([@gem1])
|
78
78
|
CLI::Gems.run('--rebuild')
|
79
79
|
end
|
80
80
|
end
|