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
@@ -5,104 +5,104 @@ require 'fileutils'
|
|
5
5
|
describe Gem::DocManager do
|
6
6
|
before do
|
7
7
|
# Ensure filesystem integrity
|
8
|
-
FileUtils.
|
9
|
-
FileUtils.
|
10
|
-
Dir.
|
8
|
+
allow(FileUtils).to receive(:mkdir_p)
|
9
|
+
allow(FileUtils).to receive(:rm_rf)
|
10
|
+
allow(Dir).to receive(:chdir)
|
11
11
|
|
12
|
-
YARD::CLI::Yardoc.
|
12
|
+
allow(YARD::CLI::Yardoc).to receive(:run)
|
13
13
|
|
14
14
|
@spec_file = File.join(YARD::ROOT, '..', 'yard.gemspec')
|
15
15
|
@spec = Gem::SourceIndex.load_specification(@spec_file)
|
16
16
|
@spec.has_yardoc = false # no yardoc docs for now
|
17
17
|
@yardopts = File.join(@spec.full_gem_path, '.yardopts')
|
18
18
|
@doc = Gem::DocManager.new(@spec)
|
19
|
-
@doc.
|
20
|
-
@doc.
|
19
|
+
allow(@doc).to receive(:install_ri_yard_orig)
|
20
|
+
allow(@doc).to receive(:install_rdoc_yard_orig)
|
21
21
|
end
|
22
22
|
|
23
|
-
def runs; YARD::CLI::Yardoc.
|
23
|
+
def runs; expect(YARD::CLI::Yardoc).to receive(:run) end
|
24
24
|
|
25
|
-
describe
|
26
|
-
it "
|
27
|
-
Gem::DocManager.
|
28
|
-
File.expand_path(path).
|
25
|
+
describe ".load_yardoc" do
|
26
|
+
it "properly loads YARD" do
|
27
|
+
expect(Gem::DocManager).to receive(:require) do |path|
|
28
|
+
expect(File.expand_path(path)).to eq YARD::ROOT + '/yard'
|
29
29
|
end
|
30
30
|
Gem::DocManager.load_yardoc
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
-
describe
|
34
|
+
describe "#install_ri_yard" do
|
35
35
|
def install
|
36
36
|
msg = "Building YARD (yri) index for #{@spec.full_name}..."
|
37
|
-
@doc.
|
37
|
+
expect(@doc).to receive(:say).with(msg)
|
38
38
|
@doc.install_ri_yard
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
41
|
+
it "passes --quiet to all documentation" do
|
42
42
|
runs.with('-c', '-n', '--quiet', 'lib')
|
43
43
|
install
|
44
44
|
end
|
45
45
|
|
46
|
-
it "
|
46
|
+
it "passes extra_rdoc_files to documentation" do
|
47
47
|
@spec.extra_rdoc_files = %w(README LICENSE)
|
48
48
|
runs.with('-c', '-n', '--quiet', 'lib', '-', 'README', 'LICENSE')
|
49
49
|
install
|
50
50
|
end
|
51
51
|
|
52
|
-
it "
|
52
|
+
it "adds --backtrace if Gem.configuration.backtrace" do
|
53
53
|
Gem.configuration.backtrace = true
|
54
54
|
runs.with('-c', '-n', '--quiet', '--backtrace', 'lib')
|
55
55
|
install
|
56
56
|
Gem.configuration.backtrace = false
|
57
57
|
end
|
58
58
|
|
59
|
-
it "
|
60
|
-
File.
|
59
|
+
it "adds require_paths if there is no .yardopts" do
|
60
|
+
expect(File).to receive(:file?).with(@yardopts).and_return(true)
|
61
61
|
runs.with('-c', '-n', '--quiet')
|
62
62
|
install
|
63
63
|
end
|
64
64
|
|
65
|
-
it "
|
65
|
+
it "adds extra_rdoc_files if there is no .yardopts" do
|
66
66
|
@spec.extra_rdoc_files = %w(README LICENSE)
|
67
|
-
File.
|
67
|
+
expect(File).to receive(:file?).with(@yardopts).and_return(true)
|
68
68
|
runs.with('-c', '-n', '--quiet')
|
69
69
|
install
|
70
70
|
end
|
71
71
|
|
72
|
-
it "
|
72
|
+
it "switches to directory before running command" do
|
73
73
|
old = Dir.pwd
|
74
|
-
Dir.
|
75
|
-
Dir.
|
74
|
+
expect(Dir).to receive(:chdir).with(@spec.full_gem_path)
|
75
|
+
expect(Dir).to receive(:chdir).with(old)
|
76
76
|
install
|
77
77
|
end
|
78
78
|
|
79
|
-
it "
|
79
|
+
it "ensures that directory is switched back at end of command in failure" do
|
80
80
|
old = Dir.pwd
|
81
|
-
Dir.
|
82
|
-
Dir.
|
83
|
-
@doc.ui.errs.
|
84
|
-
@doc.ui.errs.
|
85
|
-
@doc.ui.errs.
|
86
|
-
@doc.ui.errs.
|
87
|
-
YARD::CLI::Yardoc.
|
81
|
+
expect(Dir).to receive(:chdir).with(@spec.full_gem_path)
|
82
|
+
expect(Dir).to receive(:chdir).with(old)
|
83
|
+
expect(@doc.ui.errs).to receive(:puts).with(/ERROR:\s*While generating documentation/)
|
84
|
+
expect(@doc.ui.errs).to receive(:puts).with(/MESSAGE:\s*foo/)
|
85
|
+
expect(@doc.ui.errs).to receive(:puts).with(/YARDOC args:\s*-c -n --quiet lib/)
|
86
|
+
expect(@doc.ui.errs).to receive(:puts).with("(continuing with the rest of the installation)")
|
87
|
+
expect(YARD::CLI::Yardoc).to receive(:run).and_raise(RuntimeError.new("foo"))
|
88
88
|
install
|
89
89
|
end
|
90
90
|
|
91
|
-
it "
|
92
|
-
YARD::CLI::Yardoc.
|
93
|
-
|
91
|
+
it "handles permission errors" do
|
92
|
+
expect(YARD::CLI::Yardoc).to receive(:run).and_raise(Errno::EACCES.new("- dir"))
|
93
|
+
expect { install }.to raise_error(Gem::FilePermissionError)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
describe
|
97
|
+
describe "#install_rdoc_yard" do
|
98
98
|
def install
|
99
99
|
msg = "Installing YARD documentation for #{@spec.full_name}..."
|
100
|
-
@doc.
|
100
|
+
expect(@doc).to receive(:say).with(msg)
|
101
101
|
@doc.install_rdoc_yard
|
102
102
|
end
|
103
103
|
|
104
|
-
it "
|
105
|
-
File.
|
104
|
+
it "adds -o outdir when generating docs" do
|
105
|
+
expect(File).to receive(:file?).with(@yardopts).and_return(true)
|
106
106
|
@spec.has_yardoc = true
|
107
107
|
doc_dir = File.join(@doc.instance_variable_get("@doc_dir"), 'rdoc')
|
108
108
|
runs.with('-o', doc_dir, '--quiet')
|
@@ -4,47 +4,46 @@ require 'stringio'
|
|
4
4
|
|
5
5
|
describe YARD::Serializers::FileSystemSerializer do
|
6
6
|
before do
|
7
|
-
FileUtils.
|
8
|
-
File.
|
7
|
+
allow(FileUtils).to receive(:mkdir_p)
|
8
|
+
allow(File).to receive(:open)
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
12
|
-
it "
|
11
|
+
describe "#basepath" do
|
12
|
+
it "defaults the base path to the 'doc/'" do
|
13
13
|
obj = Serializers::FileSystemSerializer.new
|
14
|
-
obj.basepath.
|
14
|
+
expect(obj.basepath).to eq 'doc'
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
-
describe
|
19
|
-
it "
|
18
|
+
describe "#extension" do
|
19
|
+
it "defaults the file extension to .html" do
|
20
20
|
obj = Serializers::FileSystemSerializer.new
|
21
|
-
obj.extension.
|
21
|
+
expect(obj.extension).to eq "html"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
26
|
-
it "
|
25
|
+
describe "#serialized_path" do
|
26
|
+
it "allows no extension to be used" do
|
27
27
|
obj = Serializers::FileSystemSerializer.new :extension => nil
|
28
28
|
yard = CodeObjects::ClassObject.new(nil, :FooBar)
|
29
|
-
obj.serialized_path(yard).
|
29
|
+
expect(obj.serialized_path(yard)).to eq 'FooBar'
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
32
|
+
it "serializes to top-level-namespace for root" do
|
33
33
|
obj = Serializers::FileSystemSerializer.new :extension => nil
|
34
|
-
obj.serialized_path(Registry.root).
|
34
|
+
expect(obj.serialized_path(Registry.root)).to eq "top-level-namespace"
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
37
|
+
it "returns serialized_path for a String" do
|
38
38
|
s = Serializers::FileSystemSerializer.new(:basepath => 'foo', :extension => 'txt')
|
39
|
-
s.serialized_path('test.txt').
|
39
|
+
expect(s.serialized_path('test.txt')).to eq 'test.txt'
|
40
40
|
end
|
41
41
|
|
42
|
-
it "
|
42
|
+
it "removes special chars from path" do
|
43
43
|
m = CodeObjects::MethodObject.new(nil, 'a')
|
44
44
|
s = Serializers::FileSystemSerializer.new
|
45
45
|
|
46
|
-
{
|
47
|
-
:gsub! => 'gsub_21_i.html',
|
46
|
+
{ :gsub! => 'gsub_21_i.html',
|
48
47
|
:ask? => 'ask_3F_i.html',
|
49
48
|
:=== => '_3D_3D_3D_i.html',
|
50
49
|
:+ => '_2B_i.html',
|
@@ -59,25 +58,25 @@ describe YARD::Serializers::FileSystemSerializer do
|
|
59
58
|
:/ => '_2F_i.html',
|
60
59
|
:=~ => '_3D_7E_i.html'
|
61
60
|
}.each do |meth, value|
|
62
|
-
m.
|
63
|
-
s.serialized_path(m).
|
61
|
+
allow(m).to receive(:name).and_return(meth)
|
62
|
+
expect(s.serialized_path(m)).to eq value
|
64
63
|
end
|
65
64
|
end
|
66
65
|
|
67
|
-
it "
|
66
|
+
it "handles ExtraFileObject's" do
|
68
67
|
s = Serializers::FileSystemSerializer.new
|
69
68
|
e = CodeObjects::ExtraFileObject.new('filename.txt', '')
|
70
|
-
s.serialized_path(e).
|
69
|
+
expect(s.serialized_path(e)).to eq 'file.filename.html'
|
71
70
|
end
|
72
71
|
|
73
|
-
it "
|
72
|
+
it "differentiates instance and class methods from serialized path" do
|
74
73
|
s = Serializers::FileSystemSerializer.new
|
75
74
|
m1 = CodeObjects::MethodObject.new(nil, 'meth')
|
76
75
|
m2 = CodeObjects::MethodObject.new(nil, 'meth', :class)
|
77
|
-
s.serialized_path(m1).
|
76
|
+
expect(s.serialized_path(m1)).not_to eq s.serialized_path(m2)
|
78
77
|
end
|
79
78
|
|
80
|
-
it "
|
79
|
+
it "serializes path from overload tag" do
|
81
80
|
YARD.parse_string <<-'eof'
|
82
81
|
class Foo
|
83
82
|
# @overload bar
|
@@ -87,12 +86,33 @@ describe YARD::Serializers::FileSystemSerializer do
|
|
87
86
|
|
88
87
|
serializer = Serializers::FileSystemSerializer.new
|
89
88
|
object = Registry.at('Foo#bar').tag(:overload)
|
90
|
-
serializer.serialized_path(object).
|
89
|
+
expect(serializer.serialized_path(object)).to eq "Foo/bar_i.html"
|
90
|
+
end
|
91
|
+
|
92
|
+
it "maps matching case sensitive object names to different files on disk" do
|
93
|
+
Registry.clear
|
94
|
+
o1 = CodeObjects::ClassObject.new(:root, "AB")
|
95
|
+
o2 = CodeObjects::ClassObject.new(:root, "Ab")
|
96
|
+
s = Serializers::FileSystemSerializer.new
|
97
|
+
expect([["AB_.html", "Ab.html"], ["AB.html", "Ab_.html"]]).to include(
|
98
|
+
[s.serialized_path(o1), s.serialized_path(o2)])
|
99
|
+
end
|
100
|
+
|
101
|
+
it "handles case sensitivity of nested paths for objects with matching names" do
|
102
|
+
Registry.clear
|
103
|
+
YARD.parse_string <<-eof
|
104
|
+
class Abc; class D; end end
|
105
|
+
class ABC; class D; end end
|
106
|
+
eof
|
107
|
+
|
108
|
+
s = Serializers::FileSystemSerializer.new
|
109
|
+
expect(s.serialized_path(Registry.at('ABC::D'))).to eq "ABC/D.html"
|
110
|
+
expect(s.serialized_path(Registry.at('Abc::D'))).to eq "Abc/D.html"
|
91
111
|
end
|
92
112
|
end
|
93
113
|
|
94
|
-
describe
|
95
|
-
it "
|
114
|
+
describe "#serialize" do
|
115
|
+
it "serializes to the correct path" do
|
96
116
|
yard = CodeObjects::ClassObject.new(nil, :FooBar)
|
97
117
|
meth = CodeObjects::MethodObject.new(yard, :baz, :class)
|
98
118
|
meth2 = CodeObjects::MethodObject.new(yard, :baz)
|
@@ -101,24 +121,24 @@ describe YARD::Serializers::FileSystemSerializer do
|
|
101
121
|
'foo/FooBar/baz_i.txt' => meth2,
|
102
122
|
'foo/FooBar.txt' => yard }.each do |path, obj|
|
103
123
|
io = StringIO.new
|
104
|
-
File.
|
105
|
-
io.
|
124
|
+
expect(File).to receive(:open).with(path, 'wb').and_yield(io)
|
125
|
+
expect(io).to receive(:write).with("data")
|
106
126
|
|
107
127
|
s = Serializers::FileSystemSerializer.new(:basepath => 'foo', :extension => 'txt')
|
108
128
|
s.serialize(obj, "data")
|
109
129
|
end
|
110
130
|
end
|
111
131
|
|
112
|
-
it "
|
132
|
+
it "guarantees the directory exists" do
|
113
133
|
o1 = CodeObjects::ClassObject.new(nil, :Really)
|
114
134
|
o2 = CodeObjects::ClassObject.new(o1, :Long)
|
115
135
|
o3 = CodeObjects::ClassObject.new(o2, :PathName)
|
116
136
|
obj = CodeObjects::MethodObject.new(o3, :foo)
|
117
137
|
|
118
|
-
FileUtils.
|
138
|
+
expect(FileUtils).to receive(:mkdir_p).once.with('doc/Really/Long/PathName')
|
119
139
|
|
120
140
|
s = Serializers::FileSystemSerializer.new
|
121
141
|
s.serialize(obj, "data")
|
122
142
|
end
|
123
143
|
end
|
124
|
-
end
|
144
|
+
end
|
@@ -16,30 +16,30 @@ describe YARD::Serializers::YardocSerializer do
|
|
16
16
|
@bar = CodeObjects::MethodObject.new(@foo, :bar)
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
20
|
-
it "
|
19
|
+
describe "#dump" do
|
20
|
+
it "maintains object equality when loading a dumped object" do
|
21
21
|
newfoo = @serializer.internal_dump(@foo)
|
22
|
-
newfoo.
|
23
|
-
newfoo.
|
24
|
-
@foo.
|
25
|
-
@foo.
|
26
|
-
newfoo.hash.
|
22
|
+
expect(newfoo).to equal(@foo)
|
23
|
+
expect(newfoo).to eq @foo
|
24
|
+
expect(@foo).to equal(newfoo)
|
25
|
+
expect(@foo).to eq newfoo
|
26
|
+
expect(newfoo.hash).to eq @foo.hash
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
29
|
+
it "maintains hash key equality when loading a dumped object" do
|
30
30
|
newfoo = @serializer.internal_dump(@foo)
|
31
|
-
{@foo => 1}.
|
32
|
-
{newfoo => 1}.
|
31
|
+
expect({@foo => 1}).to have_key(newfoo)
|
32
|
+
expect({newfoo => 1}).to have_key(@foo)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
|
-
describe
|
37
|
-
it "
|
36
|
+
describe "#serialize" do
|
37
|
+
it "accepts a hash of codeobjects (and write to root)" do
|
38
38
|
data = {:root => Registry.root}
|
39
39
|
marshaldata = Marshal.dump(data)
|
40
|
-
filemock =
|
41
|
-
filemock.
|
42
|
-
File.
|
40
|
+
filemock = double(:file)
|
41
|
+
expect(filemock).to receive(:write).with(marshaldata)
|
42
|
+
expect(File).to receive(:open!).with('.yardoc/objects/root.dat', 'wb').and_yield(filemock)
|
43
43
|
@serializer.serialize(data)
|
44
44
|
end
|
45
45
|
end
|
data/spec/server/adapter_spec.rb
CHANGED
@@ -3,36 +3,36 @@ require File.dirname(__FILE__) + '/spec_helper'
|
|
3
3
|
describe YARD::Server::Adapter do
|
4
4
|
after(:all) { Server::Adapter.shutdown }
|
5
5
|
|
6
|
-
describe
|
7
|
-
it "
|
6
|
+
describe "#add_library" do
|
7
|
+
it "adds a library" do
|
8
8
|
lib = LibraryVersion.new('yard')
|
9
9
|
a = Adapter.new({})
|
10
|
-
a.libraries.
|
10
|
+
expect(a.libraries).to be_empty
|
11
11
|
a.add_library(lib)
|
12
|
-
a.libraries['yard'].
|
12
|
+
expect(a.libraries['yard']).to eq [lib]
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
16
|
-
describe
|
17
|
-
it "
|
18
|
-
|
16
|
+
describe "#start" do
|
17
|
+
it "does not implement #start" do
|
18
|
+
expect { Adapter.new({}).start }.to raise_error(NotImplementedError)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
describe
|
23
|
-
it
|
22
|
+
describe ".setup" do
|
23
|
+
it "adds template paths and helpers" do
|
24
24
|
Adapter.setup
|
25
|
-
Templates::Template.extra_includes.
|
26
|
-
Templates::Engine.template_paths.
|
25
|
+
expect(Templates::Template.extra_includes).to include(DocServerHelper)
|
26
|
+
expect(Templates::Engine.template_paths).to include(YARD::ROOT + '/yard/server/templates')
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
describe
|
31
|
-
it
|
30
|
+
describe ".shutdown" do
|
31
|
+
it "cleans up template paths and helpers" do
|
32
32
|
Adapter.setup
|
33
33
|
Adapter.shutdown
|
34
|
-
Templates::Template.extra_includes.
|
35
|
-
Templates::Engine.template_paths.
|
34
|
+
expect(Templates::Template.extra_includes).not_to include(DocServerHelper)
|
35
|
+
expect(Templates::Engine.template_paths).not_to include(YARD::ROOT + '/yard/server/templates')
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -9,79 +9,79 @@ class MyCacheCommand < Base
|
|
9
9
|
end
|
10
10
|
|
11
11
|
describe YARD::Server::Commands::Base do
|
12
|
-
describe
|
12
|
+
describe "#cache" do
|
13
13
|
before do
|
14
14
|
@command = MyCacheCommand.new(:adapter => mock_adapter, :caching => true)
|
15
15
|
@command.request = OpenStruct.new
|
16
16
|
end
|
17
17
|
|
18
|
-
it "
|
19
|
-
File.
|
18
|
+
it "does not cache if caching == false" do
|
19
|
+
expect(File).not_to receive(:open)
|
20
20
|
@command.caching = false
|
21
21
|
@command.run
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
25
|
-
File.
|
24
|
+
it "requires document root to cache" do
|
25
|
+
expect(File).not_to receive(:open)
|
26
26
|
@command.adapter.document_root = nil
|
27
27
|
@command.run
|
28
28
|
end
|
29
29
|
|
30
|
-
it "
|
31
|
-
FileUtils.
|
32
|
-
File.
|
30
|
+
it "caches to path/to/file.html and create directories" do
|
31
|
+
expect(FileUtils).to receive(:mkdir_p).with('/public/path/to')
|
32
|
+
expect(File).to receive(:open).with('/public/path/to/file.html', anything)
|
33
33
|
@command.request.path = '/path/to/file.html'
|
34
34
|
@command.run
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
describe
|
39
|
-
it "
|
38
|
+
describe "#redirect" do
|
39
|
+
it "returns a valid redirection" do
|
40
40
|
cmd = MyProcCommand.new { redirect '/foo' }
|
41
|
-
cmd.call(mock_request('/foo')).
|
42
|
-
[302, {"Content-Type" => "text/html", "Location" => "/foo"}, [""]]
|
41
|
+
expect(cmd.call(mock_request('/foo'))).to eq(
|
42
|
+
[302, {"Content-Type" => "text/html", "Location" => "/foo"}, [""]])
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
describe
|
47
|
-
it "
|
46
|
+
describe "#call" do
|
47
|
+
it "handles a NotFoundError and use message as body" do
|
48
48
|
cmd = MyProcCommand.new { raise NotFoundError, "hello world" }
|
49
49
|
s, h, b = *cmd.call(mock_request('/foo'))
|
50
|
-
s.
|
51
|
-
b.
|
50
|
+
expect(s).to eq 404
|
51
|
+
expect(b).to eq ["hello world"]
|
52
52
|
end
|
53
53
|
|
54
|
-
it "
|
54
|
+
it "does not use message as body if not provided in NotFoundError" do
|
55
55
|
cmd = MyProcCommand.new { raise NotFoundError }
|
56
56
|
s, h, b = *cmd.call(mock_request('/foo'))
|
57
|
-
s.
|
58
|
-
b.
|
57
|
+
expect(s).to eq 404
|
58
|
+
expect(b).to eq ["Not found: /foo"]
|
59
59
|
end
|
60
60
|
|
61
|
-
it "
|
61
|
+
it "handles 404 status code from #run" do
|
62
62
|
cmd = MyProcCommand.new { self.status = 404 }
|
63
63
|
s, h, b = *cmd.call(mock_request('/foo'))
|
64
|
-
s.
|
65
|
-
b.
|
64
|
+
expect(s).to eq 404
|
65
|
+
expect(b).to eq ["Not found: /foo"]
|
66
66
|
end
|
67
67
|
|
68
|
-
it "
|
68
|
+
it "does not override body if status is 404 and body is defined" do
|
69
69
|
cmd = MyProcCommand.new { self.body = "foo"; self.status = 404 }
|
70
70
|
s, h, b = *cmd.call(mock_request('/bar'))
|
71
|
-
s.
|
72
|
-
b.
|
71
|
+
expect(s).to eq 404
|
72
|
+
expect(b).to eq ['foo']
|
73
73
|
end
|
74
74
|
|
75
|
-
it "
|
75
|
+
it "handles body as Array" do
|
76
76
|
cmd = MyProcCommand.new { self.body = ['a', 'b', 'c'] }
|
77
77
|
s, h, b = *cmd.call(mock_request('/foo'))
|
78
|
-
b.
|
78
|
+
expect(b).to eq %w(a b c)
|
79
79
|
end
|
80
80
|
|
81
|
-
it "
|
81
|
+
it "allows headers to be defined" do
|
82
82
|
cmd = MyProcCommand.new { self.headers['Foo'] = 'BAR' }
|
83
83
|
s, h, b = *cmd.call(mock_request('/foo'))
|
84
|
-
h['Foo'].
|
84
|
+
expect(h['Foo']).to eq 'BAR'
|
85
85
|
end
|
86
86
|
end
|
87
87
|
end
|