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/graph_spec.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe YARD::CLI::Graph do
|
4
|
-
it "
|
5
|
-
Registry.
|
6
|
-
subject.
|
7
|
-
subject.options.serializer.
|
4
|
+
it "serializes output" do
|
5
|
+
expect(Registry).to receive(:load).at_least(1).times
|
6
|
+
allow(subject).to receive(:yardopts) { [] }
|
7
|
+
expect(subject.options.serializer).to receive(:serialize).once
|
8
8
|
subject.run
|
9
9
|
end
|
10
10
|
|
11
|
-
it
|
12
|
-
subject.
|
13
|
-
subject.options.serializer.
|
11
|
+
it "reads yardoc file from .yardopts" do
|
12
|
+
allow(subject).to receive(:yardopts) { %w(--db /path/to/db) }
|
13
|
+
expect(subject.options.serializer).to receive(:serialize).once
|
14
14
|
subject.run
|
15
|
-
Registry.yardoc_file.
|
15
|
+
expect(Registry.yardoc_file).to eq '/path/to/db'
|
16
16
|
end
|
17
17
|
end
|
data/spec/cli/help_spec.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe YARD::CLI::Help do
|
4
|
-
describe
|
5
|
-
it "
|
6
|
-
CLI::Yardoc.
|
4
|
+
describe "#run" do
|
5
|
+
it "accepts help command" do
|
6
|
+
expect(CLI::Yardoc).to receive(:run).with('--help')
|
7
7
|
CLI::Help.run('doc')
|
8
8
|
end
|
9
9
|
|
10
|
-
it "
|
11
|
-
CLI::CommandParser.
|
10
|
+
it "accepts no arguments (and lists all commands)" do
|
11
|
+
expect(CLI::CommandParser).to receive(:run).with('--help')
|
12
12
|
CLI::Help.run
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
16
|
-
CLI::CommandParser.
|
15
|
+
it "shows all commands if command isn't found" do
|
16
|
+
expect(CLI::CommandParser).to receive(:run).with('--help')
|
17
17
|
help = CLI::Help.new
|
18
|
-
log.
|
18
|
+
expect(log).to receive(:puts).with(/not found/)
|
19
19
|
help.run('unknown')
|
20
20
|
end
|
21
21
|
end
|
data/spec/cli/i18n_spec.rb
CHANGED
@@ -6,105 +6,101 @@ describe YARD::CLI::I18n do
|
|
6
6
|
@i18n.use_document_file = false
|
7
7
|
@i18n.use_yardopts_file = false
|
8
8
|
output_path = File.expand_path(@i18n.options.serializer.basepath)
|
9
|
-
File.
|
10
|
-
YARD.
|
9
|
+
allow(File).to receive(:open!).with(output_path, "wb")
|
10
|
+
allow(YARD).to receive(:parse)
|
11
11
|
end
|
12
12
|
|
13
|
-
describe
|
13
|
+
describe "Defaults" do
|
14
14
|
before do
|
15
15
|
@i18n = YARD::CLI::I18n.new
|
16
|
-
@i18n.
|
17
|
-
@i18n.
|
16
|
+
allow(@i18n).to receive(:yardopts).and_return([])
|
17
|
+
allow(@i18n).to receive(:support_rdoc_document_file!).and_return([])
|
18
18
|
@i18n.parse_arguments
|
19
19
|
end
|
20
20
|
|
21
|
-
it "
|
22
|
-
@i18n.use_yardopts_file.
|
21
|
+
it "reads .yardopts by default" do
|
22
|
+
expect(@i18n.use_yardopts_file).to be true
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
26
|
-
@i18n.
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should only show public visibility by default" do
|
30
|
-
@i18n.visibilities.should == [:public]
|
25
|
+
it "only shows public visibility by default" do
|
26
|
+
expect(@i18n.visibilities).to eq [:public]
|
31
27
|
end
|
32
28
|
end
|
33
29
|
|
34
|
-
describe
|
30
|
+
describe "General options" do
|
35
31
|
def self.should_accept(*args, &block)
|
36
32
|
@counter ||= 0
|
37
33
|
@counter += 1
|
38
34
|
counter = @counter
|
39
35
|
args.each do |arg|
|
40
36
|
define_method("test_options_#{@counter}", &block)
|
41
|
-
it("
|
37
|
+
it("accepts #{arg}") { send("test_options_#{counter}", arg) }
|
42
38
|
end
|
43
39
|
end
|
44
40
|
|
45
41
|
should_accept('--yardopts') do |arg|
|
46
42
|
@i18n = YARD::CLI::I18n.new
|
47
43
|
@i18n.use_document_file = false
|
48
|
-
@i18n.
|
44
|
+
expect(@i18n).to receive(:yardopts).at_least(1).times.and_return([])
|
49
45
|
@i18n.parse_arguments(arg)
|
50
|
-
@i18n.use_yardopts_file.
|
46
|
+
expect(@i18n.use_yardopts_file).to be true
|
51
47
|
@i18n.parse_arguments('--no-yardopts', arg)
|
52
|
-
@i18n.use_yardopts_file.
|
48
|
+
expect(@i18n.use_yardopts_file).to be true
|
53
49
|
end
|
54
50
|
|
55
51
|
should_accept('--yardopts with filename') do |arg|
|
56
52
|
@i18n = YARD::CLI::I18n.new
|
57
|
-
File.
|
53
|
+
expect(File).to receive(:read_binary).with('.yardopts_i18n').and_return('')
|
58
54
|
@i18n.use_document_file = false
|
59
55
|
@i18n.parse_arguments('--yardopts', '.yardopts_i18n')
|
60
|
-
@i18n.use_yardopts_file.
|
61
|
-
@i18n.options_file.
|
56
|
+
expect(@i18n.use_yardopts_file).to be true
|
57
|
+
expect(@i18n.options_file).to eq '.yardopts_i18n'
|
62
58
|
end
|
63
59
|
|
64
60
|
should_accept('--no-yardopts') do |arg|
|
65
61
|
@i18n = YARD::CLI::I18n.new
|
66
62
|
@i18n.use_document_file = false
|
67
|
-
@i18n.
|
63
|
+
expect(@i18n).not_to receive(:yardopts)
|
68
64
|
@i18n.parse_arguments(arg)
|
69
|
-
@i18n.use_yardopts_file.
|
65
|
+
expect(@i18n.use_yardopts_file).to be false
|
70
66
|
@i18n.parse_arguments('--yardopts', arg)
|
71
|
-
@i18n.use_yardopts_file.
|
67
|
+
expect(@i18n.use_yardopts_file).to be false
|
72
68
|
end
|
73
69
|
|
74
70
|
should_accept('--exclude') do |arg|
|
75
|
-
YARD.
|
71
|
+
expect(YARD).to receive(:parse).with(['a'], ['nota', 'b'])
|
76
72
|
@i18n.run(arg, 'nota', arg, 'b', 'a')
|
77
73
|
end
|
78
74
|
end
|
79
75
|
|
80
|
-
describe
|
76
|
+
describe ".yardopts handling" do
|
81
77
|
before do
|
82
78
|
@i18n.use_yardopts_file = true
|
83
79
|
end
|
84
80
|
|
85
|
-
it "
|
86
|
-
File.
|
81
|
+
it "searches for and uses yardopts file specified by #options_file" do
|
82
|
+
expect(File).to receive(:read_binary).with("test").and_return("-o \n\nMYPATH\nFILE1 FILE2")
|
87
83
|
@i18n.use_document_file = false
|
88
84
|
@i18n.options_file = "test"
|
89
|
-
File.
|
85
|
+
expect(File).to receive(:open!).with(File.expand_path("MYPATH"), "wb")
|
90
86
|
@i18n.run
|
91
|
-
@i18n.files.
|
87
|
+
expect(@i18n.files).to eq ["FILE1", "FILE2"]
|
92
88
|
end
|
93
89
|
end
|
94
90
|
|
95
|
-
describe
|
96
|
-
it "
|
97
|
-
@i18n.
|
91
|
+
describe "#run" do
|
92
|
+
it "calls parse_arguments if run() is called" do
|
93
|
+
expect(@i18n).to receive(:parse_arguments)
|
98
94
|
@i18n.run
|
99
95
|
end
|
100
96
|
|
101
|
-
it "
|
102
|
-
@i18n.
|
97
|
+
it "calls parse_arguments if run(arg1, arg2, ...) is called" do
|
98
|
+
expect(@i18n).to receive(:parse_arguments)
|
103
99
|
@i18n.run('--private', '-p', 'foo')
|
104
100
|
end
|
105
101
|
|
106
|
-
it "
|
107
|
-
@i18n.
|
102
|
+
it "doesn't call parse_arguments if run(nil) is called" do
|
103
|
+
expect(@i18n).not_to receive(:parse_arguments)
|
108
104
|
@i18n.run(nil)
|
109
105
|
end
|
110
106
|
end
|
data/spec/cli/list_spec.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe YARD::CLI::List do
|
4
|
-
it "
|
5
|
-
YARD::CLI::Yardoc.
|
4
|
+
it "passes command off to Yardoc with --list" do
|
5
|
+
expect(YARD::CLI::Yardoc).to receive(:run).with('-c', '--list', '--foo')
|
6
6
|
YARD::CLI::List.run('--foo')
|
7
7
|
end
|
8
8
|
end
|
@@ -6,16 +6,16 @@ describe YARD::CLI::MarkupTypes do
|
|
6
6
|
data = log.io.string
|
7
7
|
exts = YARD::Templates::Helpers::MarkupHelper::MARKUP_EXTENSIONS
|
8
8
|
YARD::Templates::Helpers::MarkupHelper::MARKUP_PROVIDERS.each do |name, providers|
|
9
|
-
data.
|
9
|
+
expect(data).to match(/\b#{name}\b/)
|
10
10
|
|
11
11
|
# Match all extensions
|
12
12
|
exts[name].each do |ext|
|
13
|
-
data.
|
13
|
+
expect(data).to include(".#{ext}")
|
14
14
|
end if exts[name]
|
15
15
|
|
16
16
|
# Match all provider libs
|
17
17
|
providers.each do |provider|
|
18
|
-
data.
|
18
|
+
expect(data).to match(/\b#{provider[:lib]}\b/)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
data/spec/cli/server_spec.rb
CHANGED
@@ -4,15 +4,14 @@ class Server::WebrickAdapter; def start; end end
|
|
4
4
|
|
5
5
|
describe YARD::CLI::Server do
|
6
6
|
before do
|
7
|
-
CLI::Yardoc.
|
7
|
+
allow(CLI::Yardoc).to receive(:run)
|
8
8
|
@no_verify_libraries = false
|
9
9
|
@set_libraries = true
|
10
10
|
@no_adapter_mock = false
|
11
11
|
@libraries = {}
|
12
12
|
@options = {:single_library => true, :caching => false}
|
13
13
|
@server_options = {:Port => 8808}
|
14
|
-
@adapter =
|
15
|
-
@adapter.stub!(:setup)
|
14
|
+
@adapter = double(:adapter, :setup => nil)
|
16
15
|
new_cli
|
17
16
|
end
|
18
17
|
|
@@ -46,15 +45,15 @@ describe YARD::CLI::Server do
|
|
46
45
|
@libraries.values.each do |libs|
|
47
46
|
libs.each do |lib|
|
48
47
|
yfile = File.expand_path(lib.yardoc_file)
|
49
|
-
File.
|
48
|
+
allow(File).to receive(:exist?).with(yfile).and_return(true)
|
50
49
|
end
|
51
50
|
end
|
52
51
|
end
|
53
52
|
unless @no_adapter_mock
|
54
|
-
@cli.
|
55
|
-
@adapter.
|
53
|
+
allow(@cli).to receive(:adapter).and_return(@adapter)
|
54
|
+
expect(@adapter).to receive(:new).
|
56
55
|
with(@libraries, @options, @server_options).and_return(@adapter)
|
57
|
-
@adapter.
|
56
|
+
expect(@adapter).to receive(:start)
|
58
57
|
end
|
59
58
|
|
60
59
|
@cli.run(*args.flatten)
|
@@ -62,12 +61,12 @@ describe YARD::CLI::Server do
|
|
62
61
|
end
|
63
62
|
|
64
63
|
def assert_libraries(expected_libs, actual_libs)
|
65
|
-
actual_libs.
|
64
|
+
expect(actual_libs).to eq expected_libs
|
66
65
|
expected_libs.each do |name, libs|
|
67
66
|
libs.each_with_index do |expected,i|
|
68
67
|
actual = actual_libs[name][i]
|
69
68
|
[:source, :source_path, :yardoc_file].each do |m|
|
70
|
-
actual.send(m).
|
69
|
+
expect(actual.send(m)).to eq expected.send(m)
|
71
70
|
end
|
72
71
|
end
|
73
72
|
end
|
@@ -75,34 +74,34 @@ describe YARD::CLI::Server do
|
|
75
74
|
|
76
75
|
# Mocks the existence of a file.
|
77
76
|
def mock_file(filename, content = nil)
|
78
|
-
File.
|
79
|
-
File.
|
77
|
+
allow(File).to receive(:exist?).with(filename).and_return(true)
|
78
|
+
allow(File).to receive(:read_binary).with(filename).and_return(content) if content
|
80
79
|
filename_e = File.expand_path(filename)
|
81
80
|
mock_file(filename_e) unless filename_e == filename
|
82
81
|
end
|
83
82
|
|
84
|
-
|
83
|
+
context 'when .yardopts file exists' do
|
85
84
|
before :each do
|
86
85
|
Registry.yardoc_file = Registry::DEFAULT_YARDOC_FILE
|
87
|
-
Dir.
|
86
|
+
allow(Dir).to receive(:pwd).and_return('/path/to/bar')
|
88
87
|
@name = 'bar'
|
89
88
|
end
|
90
89
|
|
91
|
-
it "
|
90
|
+
it "uses .yardoc as the yardoc db if .yardopts doesn't specify an alternate path" do
|
92
91
|
mock_file '/path/to/bar/.yardopts', '--protected'
|
93
92
|
@libraries[@name] = [Server::LibraryVersion.new(@name, nil, File.expand_path('/path/to/bar/.yardoc'))]
|
94
93
|
@libraries.values[0][0].source_path = File.expand_path('/path/to/bar')
|
95
94
|
run
|
96
95
|
end
|
97
96
|
|
98
|
-
it "
|
97
|
+
it "uses the yardoc db location specified by .yardopts" do
|
99
98
|
mock_file '/path/to/bar/.yardopts', '--db foo'
|
100
99
|
@libraries[@name] = [Server::LibraryVersion.new(@name, nil, File.expand_path('/path/to/bar/foo'))]
|
101
100
|
@libraries.values[0][0].source_path = File.expand_path('/path/to/bar')
|
102
101
|
run
|
103
102
|
end
|
104
103
|
|
105
|
-
it "
|
104
|
+
it "parses .yardopts when the library list is odd" do
|
106
105
|
mock_file '/path/to/bar/.yardopts', '--db foo'
|
107
106
|
@libraries['a'] = [Server::LibraryVersion.new('a', nil, File.expand_path('/path/to/bar/foo'))]
|
108
107
|
@libraries.values[0][0].source_path = File.expand_path('/path/to/bar')
|
@@ -110,203 +109,190 @@ describe YARD::CLI::Server do
|
|
110
109
|
end
|
111
110
|
end
|
112
111
|
|
113
|
-
|
112
|
+
context "when .yardopts file doesn't exist" do
|
114
113
|
before :each do
|
115
|
-
File.
|
114
|
+
allow(File).to receive(:exist?).with(/^(.*[\\\/])?\.yardopts$/).and_return(false)
|
116
115
|
end
|
117
116
|
|
118
|
-
it "
|
119
|
-
Dir.
|
117
|
+
it "defaults to .yardoc if no library is specified" do
|
118
|
+
expect(Dir).to receive(:pwd).at_least(:once).and_return(File.expand_path('/path/to/foo'))
|
120
119
|
@libraries['foo'] = [Server::LibraryVersion.new('foo', nil, File.expand_path('/path/to/foo/.yardoc'))]
|
121
120
|
run
|
122
121
|
end
|
123
122
|
|
124
|
-
it "
|
123
|
+
it "uses .yardoc as yardoc file if library list is odd" do
|
125
124
|
@libraries['a'] = [Server::LibraryVersion.new('a', nil, File.expand_path('.yardoc'))]
|
126
125
|
run 'a'
|
127
126
|
end
|
128
127
|
|
129
|
-
it "
|
130
|
-
File.
|
128
|
+
it "forces multi library if more than one library is listed" do
|
129
|
+
allow(File).to receive(:exist?).with('b').and_return(true)
|
131
130
|
@options[:single_library] = false
|
132
131
|
@libraries['a'] = [Server::LibraryVersion.new('a', nil, File.expand_path('b'))]
|
133
132
|
@libraries['c'] = [Server::LibraryVersion.new('c', nil, File.expand_path('.yardoc'))]
|
134
133
|
run %w(a b c)
|
135
134
|
end
|
136
135
|
|
137
|
-
it "
|
136
|
+
it "fails if specified directory does not exist" do
|
138
137
|
@set_libraries = false
|
139
|
-
File.
|
140
|
-
log.
|
138
|
+
allow(File).to receive(:exist?).with('b').and_return(false)
|
139
|
+
expect(log).to receive(:warn).with(/Cannot find yardoc db for a: "b"/)
|
141
140
|
run %w(a b)
|
142
141
|
end
|
143
142
|
end
|
144
143
|
|
145
|
-
describe
|
144
|
+
describe "General options" do
|
146
145
|
before do
|
147
|
-
File.
|
146
|
+
allow(File).to receive(:exist?).with(/\.yardopts$/).and_return(false)
|
148
147
|
end
|
149
148
|
|
150
|
-
it "
|
149
|
+
it "accepts -m, --multi-library" do
|
151
150
|
@options[:single_library] = false
|
152
151
|
run '-m'
|
153
152
|
run '--multi-library'
|
154
153
|
end
|
155
154
|
|
156
|
-
it "
|
155
|
+
it "accepts -c, --cache" do
|
157
156
|
@options[:caching] = true
|
158
157
|
run '-c'
|
159
158
|
run '--cache'
|
160
159
|
end
|
161
160
|
|
162
|
-
it "
|
161
|
+
it "accepts -r, --reload" do
|
163
162
|
@options[:incremental] = true
|
164
163
|
run '-r'
|
165
164
|
run '--reload'
|
166
165
|
end
|
167
166
|
|
168
|
-
it "
|
167
|
+
it "accepts -d, --daemon" do
|
169
168
|
@server_options[:daemonize] = true
|
170
169
|
run '-d'
|
171
170
|
run '--daemon'
|
172
171
|
end
|
173
172
|
|
174
|
-
it "
|
173
|
+
it "accepts -B, --bind" do
|
175
174
|
@server_options[:Host] = 'example.com'
|
176
175
|
run '-B', 'example.com'
|
177
176
|
run '--bind', 'example.com'
|
178
177
|
end
|
179
178
|
|
180
|
-
it "
|
179
|
+
it "binds address with WebRick adapter" do
|
181
180
|
@server_options[:Host] = 'example.com'
|
182
181
|
run '-B', 'example.com', '-a', 'webrick'
|
183
182
|
run '--bind', 'example.com', '-a', 'webrick'
|
184
183
|
end
|
185
184
|
|
186
|
-
it "
|
185
|
+
it "binds address with Rack adapter" do
|
187
186
|
@server_options[:Host] = 'example.com'
|
188
187
|
run '-B', 'example.com', '-a', 'rack'
|
189
188
|
run '--bind', 'example.com', '-a', 'rack'
|
190
189
|
end
|
191
190
|
|
192
|
-
it "
|
191
|
+
it "accepts -p, --port" do
|
193
192
|
@server_options[:Port] = 10
|
194
193
|
run '-p', '10'
|
195
194
|
run '--port', '10'
|
196
195
|
end
|
197
196
|
|
198
|
-
it "
|
197
|
+
it "accepts --docroot" do
|
199
198
|
@server_options[:DocumentRoot] = Dir.pwd + '/__foo/bar'
|
200
199
|
run '--docroot', '__foo/bar'
|
201
200
|
end
|
202
201
|
|
203
|
-
it "
|
204
|
-
@cli.
|
202
|
+
it "accepts -a webrick to create WEBrick adapter" do
|
203
|
+
expect(@cli).to receive(:adapter=).with(YARD::Server::WebrickAdapter)
|
205
204
|
run '-a', 'webrick'
|
206
205
|
end
|
207
206
|
|
208
|
-
it "
|
207
|
+
it "accepts -a rack to create Rack adapter" do
|
209
208
|
rack_required
|
210
|
-
@cli.
|
209
|
+
expect(@cli).to receive(:adapter=).with(YARD::Server::RackAdapter)
|
211
210
|
run '-a', 'rack'
|
212
211
|
end
|
213
212
|
|
214
|
-
it "
|
213
|
+
it "defaults to Rack adapter if exists on system" do
|
215
214
|
rack_required
|
216
|
-
@cli.
|
217
|
-
@cli.
|
218
|
-
@cli.
|
215
|
+
expect(@cli).to receive(:require).with('rubygems').and_return(false)
|
216
|
+
expect(@cli).to receive(:require).with('rack').and_return(true)
|
217
|
+
expect(@cli).to receive(:adapter=).with(YARD::Server::RackAdapter)
|
219
218
|
@cli.send(:select_adapter)
|
220
219
|
end
|
221
220
|
|
222
|
-
it "
|
223
|
-
@cli.
|
224
|
-
@cli.
|
225
|
-
@cli.
|
221
|
+
it "falls back to WEBrick adapter if Rack is not on system" do
|
222
|
+
expect(@cli).to receive(:require).with('rubygems').and_return(false)
|
223
|
+
expect(@cli).to receive(:require).with('rack').and_raise(LoadError)
|
224
|
+
expect(@cli).to receive(:adapter=).with(YARD::Server::WebrickAdapter)
|
226
225
|
@cli.send(:select_adapter)
|
227
226
|
end
|
228
227
|
|
229
|
-
it "
|
228
|
+
it "accepts -s, --server" do
|
230
229
|
@server_options[:server] = 'thin'
|
231
230
|
run '-s', 'thin'
|
232
231
|
run '--server', 'thin'
|
233
232
|
end
|
234
233
|
|
235
|
-
it "
|
234
|
+
it "accepts -g, --gems" do
|
236
235
|
@no_verify_libraries = true
|
237
236
|
@options[:single_library] = false
|
238
237
|
@libraries['gem1'] = [Server::LibraryVersion.new('gem1', '1.0.0', nil, :gem)]
|
239
238
|
@libraries['gem2'] = [Server::LibraryVersion.new('gem2', '1.0.0', nil, :gem)]
|
240
|
-
gem1 =
|
241
|
-
|
242
|
-
gem1.stub!(:version).and_return('1.0.0')
|
243
|
-
gem1.stub!(:full_gem_path).and_return('/path/to/foo')
|
244
|
-
gem2 = mock(:gem2)
|
245
|
-
gem2.stub!(:name).and_return('gem2')
|
246
|
-
gem2.stub!(:version).and_return('1.0.0')
|
247
|
-
gem2.stub!(:full_gem_path).and_return('/path/to/bar')
|
239
|
+
gem1 = double(:gem1, :name => 'gem1', :version => '1.0.0', :full_gem_path => '/path/to/foo')
|
240
|
+
gem2 = double(:gem2, :name => 'gem2', :version => '1.0.0', :full_gem_path => '/path/to/bar')
|
248
241
|
specs = {'gem1' => gem1, 'gem2' => gem2}
|
249
|
-
source =
|
250
|
-
source.
|
242
|
+
source = double(:source_index)
|
243
|
+
allow(source).to receive(:find_name) do |k, ver|
|
251
244
|
k == '' ? specs.values : specs.grep(k).map {|name| specs[name] }
|
252
245
|
end
|
253
|
-
Gem.
|
246
|
+
allow(Gem).to receive(:source_index).and_return(source)
|
254
247
|
run '-g'
|
255
248
|
run '--gems'
|
256
249
|
end
|
257
250
|
|
258
|
-
it "
|
251
|
+
it "accepts -G, --gemfile" do
|
259
252
|
bundler_required
|
260
253
|
@no_verify_libraries = true
|
261
254
|
@options[:single_library] = false
|
262
255
|
|
263
256
|
@libraries['gem1'] = [Server::LibraryVersion.new('gem1', '1.0.0', nil, :gem)]
|
264
257
|
@libraries['gem2'] = [Server::LibraryVersion.new('gem2', '1.0.0', nil, :gem)]
|
265
|
-
gem1 =
|
266
|
-
|
267
|
-
gem1.stub!(:version).and_return('1.0.0')
|
268
|
-
gem1.stub!(:full_gem_path).and_return('/path/to/foo')
|
269
|
-
gem2 = mock(:gem2)
|
270
|
-
gem2.stub!(:name).and_return('gem2')
|
271
|
-
gem2.stub!(:version).and_return('1.0.0')
|
272
|
-
gem2.stub!(:full_gem_path).and_return('/path/to/bar')
|
258
|
+
gem1 = double(:gem1, :name => 'gem1', :version => '1.0.0', :full_gem_path => '/path/to/foo')
|
259
|
+
gem2 = double(:gem2, :name => 'gem2', :version => '1.0.0', :full_gem_path => '/path/to/bar')
|
273
260
|
specs = {'gem1' => gem1, 'gem2' => gem2}
|
274
|
-
lockfile_parser =
|
275
|
-
|
276
|
-
Bundler::LockfileParser.stub!(:new).and_return(lockfile_parser)
|
261
|
+
lockfile_parser = double(:new, :specs => [gem1, gem2])
|
262
|
+
allow(Bundler::LockfileParser).to receive(:new).and_return(lockfile_parser)
|
277
263
|
|
278
|
-
File.
|
279
|
-
File.
|
264
|
+
expect(File).to receive(:exist?).at_least(2).times.with("Gemfile.lock").and_return(true)
|
265
|
+
allow(File).to receive(:read)
|
280
266
|
|
281
267
|
run '-G'
|
282
268
|
run '--gemfile'
|
283
269
|
|
284
|
-
File.
|
270
|
+
expect(File).to receive(:exist?).with("different_name.lock").and_return(true)
|
285
271
|
run '--gemfile', 'different_name'
|
286
272
|
end
|
287
273
|
|
288
|
-
it "
|
274
|
+
it "warns if lockfile is not found (with -G)" do
|
289
275
|
bundler_required
|
290
|
-
File.
|
291
|
-
File.
|
292
|
-
log.
|
276
|
+
expect(File).to receive(:exist?).with(/\.yardopts$/).at_least(:once).and_return(false)
|
277
|
+
expect(File).to receive(:exist?).with('somefile.lock').and_return(false)
|
278
|
+
expect(log).to receive(:warn).with(/Cannot find somefile.lock/)
|
293
279
|
run '-G', 'somefile'
|
294
280
|
end
|
295
281
|
|
296
|
-
it "
|
297
|
-
@cli.
|
298
|
-
log.
|
282
|
+
it "displays an error if Bundler not available (with -G)" do
|
283
|
+
expect(@cli).to receive(:require).with('bundler').and_raise(LoadError)
|
284
|
+
expect(log).to receive(:error).with(/Bundler not available/)
|
299
285
|
run '-G'
|
300
286
|
end
|
301
287
|
|
302
|
-
it "
|
288
|
+
it "loads template paths after adapter template paths" do
|
303
289
|
unstub_adapter
|
304
290
|
@cli.adapter = Server::WebrickAdapter
|
305
291
|
run '-t', 'foo'
|
306
|
-
Templates::Engine.template_paths.last.
|
292
|
+
expect(Templates::Engine.template_paths.last).to eq 'foo'
|
307
293
|
end
|
308
294
|
|
309
|
-
it "
|
295
|
+
it "loads ruby code (-e) after adapter" do
|
310
296
|
unstub_adapter
|
311
297
|
@cli.adapter = Server::WebrickAdapter
|
312
298
|
path = File.dirname(__FILE__) + '/tmp.adapterscript.rb'
|
@@ -315,7 +301,7 @@ describe YARD::CLI::Server do
|
|
315
301
|
f.puts "YARD::Templates::Engine.register_template_path 'foo'"
|
316
302
|
f.flush
|
317
303
|
run '-e', f.path
|
318
|
-
Templates::Engine.template_paths.last.
|
304
|
+
expect(Templates::Engine.template_paths.last).to eq 'foo'
|
319
305
|
end
|
320
306
|
ensure
|
321
307
|
File.unlink(path)
|