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/stats_spec.rb
CHANGED
@@ -26,14 +26,14 @@ describe YARD::CLI::Stats do
|
|
26
26
|
|
27
27
|
@output = StringIO.new
|
28
28
|
@stats = CLI::Stats.new(false)
|
29
|
-
@stats.
|
30
|
-
@stats.
|
31
|
-
log.
|
29
|
+
allow(@stats).to receive(:support_rdoc_document_file!).and_return([])
|
30
|
+
allow(@stats).to receive(:yardopts).and_return([])
|
31
|
+
allow(log).to receive(:puts) {|*args| @output << args.join("\n") << "\n" }
|
32
32
|
end
|
33
33
|
|
34
|
-
it "
|
34
|
+
it "lists undocumented objects with --list-undoc when there are undocumented objects" do
|
35
35
|
@stats.run('--list-undoc')
|
36
|
-
@output.string.
|
36
|
+
expect(@output.string).to eq <<-eof
|
37
37
|
#{@main_stats}
|
38
38
|
Undocumented Objects:
|
39
39
|
|
@@ -45,14 +45,14 @@ A#foo
|
|
45
45
|
eof
|
46
46
|
end
|
47
47
|
|
48
|
-
it "
|
48
|
+
it "lists no undocumented objects with --list-undoc when there is nothing undocumented" do
|
49
49
|
Registry.clear
|
50
50
|
YARD.parse_string <<-eof
|
51
51
|
# documentation
|
52
52
|
def foo; end
|
53
53
|
eof
|
54
54
|
@stats.run('--list-undoc')
|
55
|
-
@output.string.
|
55
|
+
expect(@output.string).to eq "Files: 1\n" +
|
56
56
|
"Modules: 0 ( 0 undocumented)\n" +
|
57
57
|
"Classes: 0 ( 0 undocumented)\n" +
|
58
58
|
"Constants: 0 ( 0 undocumented)\n" +
|
@@ -60,9 +60,9 @@ eof
|
|
60
60
|
" 100.00% documented\n"
|
61
61
|
end
|
62
62
|
|
63
|
-
it "
|
63
|
+
it "lists undocumented objects in compact mode with --list-undoc --compact" do
|
64
64
|
@stats.run('--list-undoc', '--compact')
|
65
|
-
@output.string.
|
65
|
+
expect(@output.string).to eq <<-eof
|
66
66
|
#{@main_stats}
|
67
67
|
Undocumented Objects:
|
68
68
|
B ((stdin):9)
|
@@ -72,19 +72,19 @@ A#foo ((stdin):4)
|
|
72
72
|
eof
|
73
73
|
end
|
74
74
|
|
75
|
-
it "
|
75
|
+
it "still lists stats with --quiet" do
|
76
76
|
@stats.run('--quiet')
|
77
|
-
@output.string.
|
77
|
+
expect(@output.string).to eq @main_stats
|
78
78
|
end
|
79
79
|
|
80
|
-
it "
|
80
|
+
it "ignores everything with --no-public" do
|
81
81
|
@stats.run('--no-public')
|
82
|
-
@output.string.
|
82
|
+
expect(@output.string).to eq(
|
83
83
|
"Files: 0\n" +
|
84
84
|
"Modules: 0 ( 0 undocumented)\n" +
|
85
85
|
"Classes: 0 ( 0 undocumented)\n" +
|
86
86
|
"Constants: 0 ( 0 undocumented)\n" +
|
87
87
|
"Methods: 0 ( 0 undocumented)\n" +
|
88
|
-
" 100.00% documented\n"
|
88
|
+
" 100.00% documented\n")
|
89
89
|
end
|
90
90
|
end
|
data/spec/cli/yardoc_spec.rb
CHANGED
@@ -7,290 +7,290 @@ describe YARD::CLI::Yardoc do
|
|
7
7
|
@yardoc.use_document_file = false
|
8
8
|
@yardoc.use_yardopts_file = false
|
9
9
|
@yardoc.generate = false
|
10
|
-
Templates::Engine.
|
11
|
-
Templates::Engine.
|
12
|
-
YARD.
|
13
|
-
Registry.
|
14
|
-
Registry.
|
10
|
+
allow(Templates::Engine).to receive(:render)
|
11
|
+
allow(Templates::Engine).to receive(:generate)
|
12
|
+
allow(YARD).to receive(:parse)
|
13
|
+
allow(Registry).to receive(:load)
|
14
|
+
allow(Registry).to receive(:save)
|
15
15
|
end
|
16
16
|
|
17
|
-
describe
|
17
|
+
describe "Defaults" do
|
18
18
|
before do
|
19
19
|
@yardoc = CLI::Yardoc.new
|
20
|
-
@yardoc.
|
21
|
-
@yardoc.
|
20
|
+
allow(@yardoc).to receive(:yardopts).and_return([])
|
21
|
+
allow(@yardoc).to receive(:support_rdoc_document_file!).and_return([])
|
22
22
|
@yardoc.parse_arguments
|
23
23
|
end
|
24
24
|
|
25
|
-
it "
|
26
|
-
@yardoc.use_cache.
|
25
|
+
it "does not use cache by default" do
|
26
|
+
expect(@yardoc.use_cache).to be false
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
30
|
-
@yardoc.statistics.
|
29
|
+
it "prints statistics by default" do
|
30
|
+
expect(@yardoc.statistics).to be true
|
31
31
|
end
|
32
32
|
|
33
|
-
it "
|
34
|
-
@yardoc.generate.
|
33
|
+
it "generates output by default" do
|
34
|
+
expect(@yardoc.generate).to be true
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
38
|
-
@yardoc.use_yardopts_file.
|
37
|
+
it "reads .yardopts by default" do
|
38
|
+
expect(@yardoc.use_yardopts_file).to be true
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
42
|
-
@yardoc.use_document_file.
|
41
|
+
it "reads .document by default" do
|
42
|
+
expect(@yardoc.use_document_file).to be true
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
46
|
-
@yardoc.files.
|
45
|
+
it "uses lib, app, and ext as default file glob paths" do
|
46
|
+
expect(@yardoc.files).to eq Parser::SourceParser::DEFAULT_PATH_GLOB
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
50
|
-
@yardoc.options.markup.
|
49
|
+
it "uses rdoc as default markup type (but falls back on none)" do
|
50
|
+
expect(@yardoc.options.markup).to eq :rdoc
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
54
|
-
@yardoc.options.template.
|
53
|
+
it "uses default as default template" do
|
54
|
+
expect(@yardoc.options.template).to eq :default
|
55
55
|
end
|
56
56
|
|
57
|
-
it "
|
58
|
-
@yardoc.options.format.
|
57
|
+
it "uses HTML as default format" do
|
58
|
+
expect(@yardoc.options.format).to eq :html
|
59
59
|
end
|
60
60
|
|
61
|
-
it "
|
62
|
-
@yardoc.options.default_return.
|
61
|
+
it "uses 'Object' as default return type" do
|
62
|
+
expect(@yardoc.options.default_return).to eq 'Object'
|
63
63
|
end
|
64
64
|
|
65
|
-
it "
|
66
|
-
@yardoc.options.hide_void_return.
|
65
|
+
it "does not hide void return types by default" do
|
66
|
+
expect(@yardoc.options.hide_void_return).to be false
|
67
67
|
end
|
68
68
|
|
69
|
-
it "
|
70
|
-
@yardoc.visibilities.
|
69
|
+
it "only shows public visibility by default" do
|
70
|
+
expect(@yardoc.visibilities).to eq [:public]
|
71
71
|
end
|
72
72
|
|
73
|
-
it "
|
74
|
-
@yardoc.list.
|
73
|
+
it "does not list objects by default" do
|
74
|
+
expect(@yardoc.list).to be false
|
75
75
|
end
|
76
76
|
|
77
|
-
it "
|
78
|
-
@yardoc.options.embed_mixins.
|
77
|
+
it "does not embed mixins by default" do
|
78
|
+
expect(@yardoc.options.embed_mixins).to be_empty
|
79
79
|
end
|
80
80
|
|
81
|
-
it "
|
82
|
-
@yardoc.options.locale.
|
81
|
+
it "does not set any locale by default" do
|
82
|
+
expect(@yardoc.options.locale).to be nil
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
describe
|
86
|
+
describe "General options" do
|
87
87
|
def self.should_accept(*args, &block)
|
88
88
|
@counter ||= 0
|
89
89
|
@counter += 1
|
90
90
|
counter = @counter
|
91
91
|
args.each do |arg|
|
92
92
|
define_method("test_options_#{@counter}", &block)
|
93
|
-
it("
|
93
|
+
it("accepts #{arg}") { send("test_options_#{counter}", arg) }
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
97
|
should_accept('--single-db') do |arg|
|
98
98
|
@yardoc.parse_arguments(arg)
|
99
|
-
Registry.single_object_db.
|
99
|
+
expect(Registry.single_object_db).to be true
|
100
100
|
Registry.single_object_db = nil
|
101
101
|
end
|
102
102
|
|
103
103
|
should_accept('--no-single-db') do |arg|
|
104
104
|
@yardoc.parse_arguments(arg)
|
105
|
-
Registry.single_object_db.
|
105
|
+
expect(Registry.single_object_db).to be false
|
106
106
|
Registry.single_object_db = nil
|
107
107
|
end
|
108
108
|
|
109
109
|
should_accept('-c', '--use-cache') do |arg|
|
110
110
|
@yardoc.parse_arguments(arg)
|
111
|
-
@yardoc.use_cache.
|
111
|
+
expect(@yardoc.use_cache).to be true
|
112
112
|
end
|
113
113
|
|
114
114
|
should_accept('--no-cache') do |arg|
|
115
115
|
@yardoc.parse_arguments(arg)
|
116
|
-
@yardoc.use_cache.
|
116
|
+
expect(@yardoc.use_cache).to be false
|
117
117
|
end
|
118
118
|
|
119
119
|
should_accept('--yardopts') do |arg|
|
120
120
|
@yardoc = CLI::Yardoc.new
|
121
121
|
@yardoc.use_document_file = false
|
122
|
-
@yardoc.
|
122
|
+
expect(@yardoc).to receive(:yardopts).at_least(1).times.and_return([])
|
123
123
|
@yardoc.parse_arguments(arg)
|
124
|
-
@yardoc.use_yardopts_file.
|
124
|
+
expect(@yardoc.use_yardopts_file).to be true
|
125
125
|
@yardoc.parse_arguments('--no-yardopts', arg)
|
126
|
-
@yardoc.use_yardopts_file.
|
126
|
+
expect(@yardoc.use_yardopts_file).to be true
|
127
127
|
end
|
128
128
|
|
129
129
|
should_accept('--yardopts with filename') do |arg|
|
130
130
|
@yardoc = CLI::Yardoc.new
|
131
|
-
File.
|
131
|
+
expect(File).to receive(:read_binary).with('.foobar').and_return('')
|
132
132
|
@yardoc.use_document_file = false
|
133
133
|
@yardoc.parse_arguments('--yardopts', '.foobar')
|
134
|
-
@yardoc.use_yardopts_file.
|
135
|
-
@yardoc.options_file.
|
134
|
+
expect(@yardoc.use_yardopts_file).to be true
|
135
|
+
expect(@yardoc.options_file).to eq '.foobar'
|
136
136
|
end
|
137
137
|
|
138
138
|
should_accept('--no-yardopts') do |arg|
|
139
139
|
@yardoc = CLI::Yardoc.new
|
140
140
|
@yardoc.use_document_file = false
|
141
|
-
@yardoc.
|
141
|
+
expect(@yardoc).not_to receive(:yardopts)
|
142
142
|
@yardoc.parse_arguments(arg)
|
143
|
-
@yardoc.use_yardopts_file.
|
143
|
+
expect(@yardoc.use_yardopts_file).to be false
|
144
144
|
@yardoc.parse_arguments('--yardopts', arg)
|
145
|
-
@yardoc.use_yardopts_file.
|
145
|
+
expect(@yardoc.use_yardopts_file).to be false
|
146
146
|
end
|
147
147
|
|
148
148
|
should_accept('--document') do |arg|
|
149
149
|
@yardoc = CLI::Yardoc.new
|
150
150
|
@yardoc.use_yardopts_file = false
|
151
|
-
@yardoc.
|
151
|
+
expect(@yardoc).to receive(:support_rdoc_document_file!).and_return([])
|
152
152
|
@yardoc.parse_arguments('--no-document', arg)
|
153
|
-
@yardoc.use_document_file.
|
153
|
+
expect(@yardoc.use_document_file).to be true
|
154
154
|
end
|
155
155
|
|
156
156
|
should_accept('--no-document') do |arg|
|
157
157
|
@yardoc = CLI::Yardoc.new
|
158
158
|
@yardoc.use_yardopts_file = false
|
159
|
-
@yardoc.
|
159
|
+
expect(@yardoc).not_to receive(:support_rdoc_document_file!)
|
160
160
|
@yardoc.parse_arguments('--document', arg)
|
161
|
-
@yardoc.use_document_file.
|
161
|
+
expect(@yardoc.use_document_file).to be false
|
162
162
|
end
|
163
163
|
|
164
164
|
should_accept('-b', '--db') do |arg|
|
165
165
|
@yardoc.parse_arguments(arg, 'test')
|
166
|
-
Registry.yardoc_file.
|
166
|
+
expect(Registry.yardoc_file).to eq 'test'
|
167
167
|
Registry.yardoc_file = '.yardoc'
|
168
168
|
end
|
169
169
|
|
170
170
|
should_accept('-n', '--no-output') do |arg|
|
171
|
-
Templates::Engine.
|
171
|
+
expect(Templates::Engine).not_to receive(:generate)
|
172
172
|
@yardoc.run(arg)
|
173
173
|
end
|
174
174
|
|
175
175
|
should_accept('--exclude') do |arg|
|
176
|
-
YARD.
|
176
|
+
expect(YARD).to receive(:parse).with(['a'], ['nota', 'b'])
|
177
177
|
@yardoc.run(arg, 'nota', arg, 'b', 'a')
|
178
178
|
end
|
179
179
|
|
180
180
|
should_accept('--no-save') do |arg|
|
181
|
-
YARD.
|
182
|
-
Registry.
|
181
|
+
expect(YARD).to receive(:parse)
|
182
|
+
expect(Registry).not_to receive(:save)
|
183
183
|
@yardoc.run(arg)
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
187
|
-
describe
|
188
|
-
it "
|
187
|
+
describe "Output options" do
|
188
|
+
it "accepts --title" do
|
189
189
|
@yardoc.parse_arguments('--title', 'hello world')
|
190
|
-
@yardoc.options.title.
|
190
|
+
expect(@yardoc.options.title).to eq 'hello world'
|
191
191
|
end
|
192
192
|
|
193
|
-
it "
|
194
|
-
File.
|
193
|
+
it "allows --title to have multiple spaces in .yardopts" do
|
194
|
+
expect(File).to receive(:read_binary).with("test").and_return("--title \"Foo Bar\"")
|
195
195
|
@yardoc.options_file = "test"
|
196
196
|
@yardoc.use_yardopts_file = true
|
197
197
|
@yardoc.run
|
198
|
-
@yardoc.options.title.
|
198
|
+
expect(@yardoc.options.title).to eq "Foo Bar"
|
199
199
|
end
|
200
200
|
|
201
|
-
it "
|
201
|
+
it "aliases --main to the --readme flag" do
|
202
202
|
readme = File.join(File.dirname(__FILE__),'..','..','README.md')
|
203
203
|
|
204
204
|
@yardoc.parse_arguments('--main', readme)
|
205
|
-
@yardoc.options.readme.
|
205
|
+
expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new(readme, '')
|
206
206
|
end
|
207
207
|
|
208
|
-
it "
|
208
|
+
it "selects a markup provider when --markup-provider or -mp is set" do
|
209
209
|
@yardoc.parse_arguments("-M", "test")
|
210
|
-
@yardoc.options.markup_provider.
|
210
|
+
expect(@yardoc.options.markup_provider).to eq :test
|
211
211
|
@yardoc.parse_arguments("--markup-provider", "test2")
|
212
|
-
@yardoc.options.markup_provider.
|
212
|
+
expect(@yardoc.options.markup_provider).to eq :test2
|
213
213
|
end
|
214
214
|
|
215
|
-
it "
|
216
|
-
@yardoc.
|
215
|
+
it "selects a markup format when -m is set" do
|
216
|
+
expect(@yardoc).to receive(:verify_markup_options).and_return(true)
|
217
217
|
@yardoc.generate = true
|
218
218
|
@yardoc.parse_arguments('-m', 'markdown')
|
219
|
-
@yardoc.options.markup.
|
219
|
+
expect(@yardoc.options.markup).to eq :markdown
|
220
220
|
end
|
221
221
|
|
222
|
-
it "
|
222
|
+
it "accepts --default-return" do
|
223
223
|
@yardoc.parse_arguments *%w( --default-return XYZ )
|
224
|
-
@yardoc.options.default_return.
|
224
|
+
expect(@yardoc.options.default_return).to eq "XYZ"
|
225
225
|
end
|
226
226
|
|
227
|
-
it "
|
227
|
+
it "allows --hide-void-return to be set" do
|
228
228
|
@yardoc.parse_arguments *%w( --hide-void-return )
|
229
|
-
@yardoc.options.hide_void_return.
|
229
|
+
expect(@yardoc.options.hide_void_return).to be true
|
230
230
|
end
|
231
231
|
|
232
|
-
it "
|
232
|
+
it "accepts --embed-mixins" do
|
233
233
|
@yardoc.parse_arguments *%w( --embed-mixins )
|
234
|
-
@yardoc.options.embed_mixins.
|
234
|
+
expect(@yardoc.options.embed_mixins).to eq ['*']
|
235
235
|
end
|
236
236
|
|
237
|
-
it "
|
237
|
+
it "accepts --embed-mixin MODULE" do
|
238
238
|
@yardoc.parse_arguments *%w( --embed-mixin MyModule )
|
239
|
-
@yardoc.options.embed_mixins.
|
239
|
+
expect(@yardoc.options.embed_mixins).to eq ['MyModule']
|
240
240
|
end
|
241
241
|
|
242
|
-
it "
|
243
|
-
YARD.
|
244
|
-
Registry.
|
245
|
-
Registry.
|
246
|
-
@yardoc.
|
242
|
+
it "generates all objects with --use-cache" do
|
243
|
+
expect(YARD).to receive(:parse)
|
244
|
+
expect(Registry).to receive(:load)
|
245
|
+
expect(Registry).to receive(:load_all)
|
246
|
+
allow(@yardoc).to receive(:generate).and_return(true)
|
247
247
|
@yardoc.run *%w( --use-cache )
|
248
248
|
end
|
249
249
|
|
250
|
-
it "
|
251
|
-
@yardoc.
|
252
|
-
CLI::Stats.
|
250
|
+
it "does not print statistics with --no-stats" do
|
251
|
+
allow(@yardoc).to receive(:statistics).and_return(false)
|
252
|
+
expect(CLI::Stats).not_to receive(:new)
|
253
253
|
@yardoc.run *%w( --no-stats )
|
254
254
|
end
|
255
255
|
|
256
|
-
describe
|
256
|
+
describe "--asset" do
|
257
257
|
before do
|
258
258
|
@yardoc.generate = true
|
259
|
-
@yardoc.
|
259
|
+
allow(@yardoc).to receive(:run_generate)
|
260
260
|
end
|
261
261
|
|
262
|
-
it "
|
263
|
-
FileUtils.
|
262
|
+
it "copies assets to output directory" do
|
263
|
+
expect(FileUtils).to receive(:cp_r).with('a', 'doc/a')
|
264
264
|
@yardoc.run *%w( --asset a )
|
265
|
-
@yardoc.assets.
|
265
|
+
expect(@yardoc.assets).to eq({'a' => 'a'})
|
266
266
|
end
|
267
267
|
|
268
|
-
it "
|
269
|
-
FileUtils.
|
270
|
-
FileUtils.
|
268
|
+
it "allows multiple --asset options" do
|
269
|
+
expect(FileUtils).to receive(:cp_r).with('a', 'doc/a')
|
270
|
+
expect(FileUtils).to receive(:cp_r).with('b', 'doc/b')
|
271
271
|
@yardoc.run *%w( --asset a --asset b )
|
272
|
-
@yardoc.assets.
|
272
|
+
expect(@yardoc.assets).to eq({'a' => 'a', 'b' => 'b'})
|
273
273
|
end
|
274
274
|
|
275
|
-
it "
|
276
|
-
log.
|
275
|
+
it "does not allow from or to to refer to a path above current path" do
|
276
|
+
expect(log).to receive(:warn).exactly(4).times.with(/invalid/i)
|
277
277
|
@yardoc.run *%w( --asset ../../../etc/passwd )
|
278
|
-
@yardoc.assets.
|
278
|
+
expect(@yardoc.assets).to be_empty
|
279
279
|
@yardoc.run *%w( --asset a/b/c/d/../../../../../../etc/passwd )
|
280
|
-
@yardoc.assets.
|
280
|
+
expect(@yardoc.assets).to be_empty
|
281
281
|
@yardoc.run *%w( --asset /etc/passwd )
|
282
|
-
@yardoc.assets.
|
282
|
+
expect(@yardoc.assets).to be_empty
|
283
283
|
@yardoc.run *%w( --asset normal:/etc/passwd )
|
284
|
-
@yardoc.assets.
|
284
|
+
expect(@yardoc.assets).to be_empty
|
285
285
|
end
|
286
286
|
|
287
|
-
it "
|
288
|
-
FileUtils.
|
287
|
+
it "allows from:to syntax" do
|
288
|
+
expect(FileUtils).to receive(:cp_r).with('foo', 'doc/bar')
|
289
289
|
@yardoc.run *%w( --asset foo:bar )
|
290
|
-
@yardoc.assets.
|
290
|
+
expect(@yardoc.assets).to eq({'foo' => 'bar'})
|
291
291
|
end
|
292
292
|
|
293
|
-
it "
|
293
|
+
it "does not put from inside of to/ if from is a directory" do
|
294
294
|
begin
|
295
295
|
from = 'tmp_foo'
|
296
296
|
to = 'tmp_bar'
|
@@ -299,8 +299,8 @@ describe YARD::CLI::Yardoc do
|
|
299
299
|
@yardoc.options.serializer.basepath = File.dirname(__FILE__)
|
300
300
|
@yardoc.run("--asset", "#{from}:#{to}")
|
301
301
|
@yardoc.run("--asset", "#{from}:#{to}")
|
302
|
-
File.directory?(full_to).
|
303
|
-
File.directory?(File.join(full_to, 'tmp_foo')).
|
302
|
+
expect(File.directory?(full_to)).to be true
|
303
|
+
expect(File.directory?(File.join(full_to, 'tmp_foo'))).to be false
|
304
304
|
ensure
|
305
305
|
FileUtils.rm_rf(from)
|
306
306
|
FileUtils.rm_rf(full_to)
|
@@ -308,37 +308,37 @@ describe YARD::CLI::Yardoc do
|
|
308
308
|
end
|
309
309
|
end
|
310
310
|
|
311
|
-
describe
|
312
|
-
it
|
313
|
-
File.
|
314
|
-
File.
|
311
|
+
describe "--locale" do
|
312
|
+
it "applies specified locale to all extra file objects" do
|
313
|
+
allow(File).to receive(:read).with('extra_file1').and_return('')
|
314
|
+
allow(File).to receive(:read).with('extra_file2').and_return('')
|
315
315
|
|
316
316
|
extra_file_object1 = CodeObjects::ExtraFileObject.new('extra_file1')
|
317
317
|
extra_file_object2 = CodeObjects::ExtraFileObject.new('extra_file2')
|
318
|
-
extra_file_object1.
|
319
|
-
extra_file_object2.
|
320
|
-
|
321
|
-
CodeObjects::ExtraFileObject.
|
322
|
-
CodeObjects::ExtraFileObject.
|
323
|
-
Dir.
|
324
|
-
File.
|
325
|
-
File.
|
318
|
+
expect(extra_file_object1).to receive(:locale=).with('fr')
|
319
|
+
expect(extra_file_object2).to receive(:locale=).with('fr')
|
320
|
+
|
321
|
+
allow(CodeObjects::ExtraFileObject).to receive(:new).with('extra_file1').and_return(extra_file_object1)
|
322
|
+
allow(CodeObjects::ExtraFileObject).to receive(:new).with('extra_file2').and_return(extra_file_object2)
|
323
|
+
allow(Dir).to receive(:glob).with('README{,*[^~]}').and_return([])
|
324
|
+
allow(File).to receive(:file?).with('extra_file1').and_return(true)
|
325
|
+
allow(File).to receive(:file?).with('extra_file2').and_return(true)
|
326
326
|
@yardoc.run('--locale=fr', '-', 'extra_file1', 'extra_file2')
|
327
327
|
end
|
328
328
|
end
|
329
329
|
|
330
|
-
describe
|
331
|
-
it
|
332
|
-
Registry.
|
330
|
+
describe "--po-dir" do
|
331
|
+
it "sets Registry.po_dir" do
|
332
|
+
expect(Registry).to receive(:po_dir=).with("locale")
|
333
333
|
@yardoc.run('--po-dir=locale')
|
334
334
|
end
|
335
335
|
end
|
336
336
|
end
|
337
337
|
|
338
|
-
describe
|
338
|
+
describe "--[no-]api" do
|
339
339
|
before { Registry.clear }
|
340
340
|
|
341
|
-
it "
|
341
|
+
it "allows --api name" do
|
342
342
|
YARD.parse_string <<-eof
|
343
343
|
# @api private
|
344
344
|
class Foo; end
|
@@ -347,10 +347,10 @@ describe YARD::CLI::Yardoc do
|
|
347
347
|
class Baz; end
|
348
348
|
eof
|
349
349
|
@yardoc.run('--api', 'private')
|
350
|
-
@yardoc.options.verifier.run(Registry.all).
|
350
|
+
expect(@yardoc.options.verifier.run(Registry.all)).to eq [P('Foo')]
|
351
351
|
end
|
352
352
|
|
353
|
-
it "
|
353
|
+
it "allows multiple --api's to all be shown" do
|
354
354
|
YARD.parse_string <<-eof
|
355
355
|
# @api private
|
356
356
|
class Foo; end
|
@@ -359,11 +359,11 @@ describe YARD::CLI::Yardoc do
|
|
359
359
|
class Baz; end
|
360
360
|
eof
|
361
361
|
@yardoc.run('--api', 'private', '--api', 'public')
|
362
|
-
@yardoc.options.verifier.run(Registry.all).
|
363
|
-
sort_by {|o| o.path }.
|
362
|
+
expect(@yardoc.options.verifier.run(Registry.all).
|
363
|
+
sort_by {|o| o.path }).to eq [P('Bar'), P('Foo')]
|
364
364
|
end
|
365
365
|
|
366
|
-
it "
|
366
|
+
it "allows --no-api to specify objects with no @api tag" do
|
367
367
|
YARD.parse_string <<-eof
|
368
368
|
# @api private
|
369
369
|
class Foo; end
|
@@ -372,13 +372,13 @@ describe YARD::CLI::Yardoc do
|
|
372
372
|
class Baz; end
|
373
373
|
eof
|
374
374
|
@yardoc.run('--api', '')
|
375
|
-
@yardoc.options.verifier.run(Registry.all).
|
375
|
+
expect(@yardoc.options.verifier.run(Registry.all)).to eq [P('Baz')]
|
376
376
|
@yardoc.options.verifier = Verifier.new
|
377
377
|
@yardoc.run('--no-api')
|
378
|
-
@yardoc.options.verifier.run(Registry.all).
|
378
|
+
expect(@yardoc.options.verifier.run(Registry.all)).to eq [P('Baz')]
|
379
379
|
end
|
380
380
|
|
381
|
-
it "
|
381
|
+
it "allows --no-api to work with other --api switches" do
|
382
382
|
YARD.parse_string <<-eof
|
383
383
|
# @api private
|
384
384
|
class Foo; end
|
@@ -387,21 +387,21 @@ describe YARD::CLI::Yardoc do
|
|
387
387
|
class Baz; end
|
388
388
|
eof
|
389
389
|
@yardoc.run('--no-api', '--api', 'public')
|
390
|
-
@yardoc.options.verifier.run(Registry.all).
|
391
|
-
sort_by {|o| o.path }.
|
390
|
+
expect(@yardoc.options.verifier.run(Registry.all).
|
391
|
+
sort_by {|o| o.path }).to eq [P('Bar'), P('Baz')]
|
392
392
|
end
|
393
393
|
|
394
|
-
it "
|
394
|
+
it "ensures Ruby code cannot be used" do
|
395
395
|
[':symbol', '42', '"; exit'].each do |ruby|
|
396
396
|
@yardoc.options.verifier.expressions = []
|
397
397
|
@yardoc.run('--api', ruby)
|
398
|
-
@yardoc.options.verifier.expressions[1].
|
398
|
+
expect(@yardoc.options.verifier.expressions[1]).to include(ruby.inspect)
|
399
399
|
end
|
400
400
|
end
|
401
401
|
end
|
402
402
|
|
403
|
-
describe
|
404
|
-
it "
|
403
|
+
describe "--hide-api option" do
|
404
|
+
it "allows --hide-api to hide objects with api tags" do
|
405
405
|
YARD.parse_string <<-eof
|
406
406
|
# @api private
|
407
407
|
class Foo; end
|
@@ -409,11 +409,11 @@ describe YARD::CLI::Yardoc do
|
|
409
409
|
class Baz; end
|
410
410
|
eof
|
411
411
|
@yardoc.run('--hide-api', 'private')
|
412
|
-
@yardoc.options.verifier.run(Registry.all).
|
413
|
-
sort_by {|o| o.path }.
|
412
|
+
expect(@yardoc.options.verifier.run(Registry.all).
|
413
|
+
sort_by {|o| o.path }).to eq [P('Bar'), P('Baz')]
|
414
414
|
end
|
415
415
|
|
416
|
-
it "
|
416
|
+
it "allows --hide-api to work with --api" do
|
417
417
|
YARD.parse_string <<-eof
|
418
418
|
# @api private
|
419
419
|
class Foo; end
|
@@ -422,59 +422,54 @@ describe YARD::CLI::Yardoc do
|
|
422
422
|
class Baz; end
|
423
423
|
eof
|
424
424
|
@yardoc.run('--api', 'public', '--hide-api', 'private')
|
425
|
-
@yardoc.options.verifier.run(Registry.all).
|
426
|
-
sort_by {|o| o.path }.
|
425
|
+
expect(@yardoc.options.verifier.run(Registry.all).
|
426
|
+
sort_by {|o| o.path }).to eq [P('Bar')]
|
427
427
|
end
|
428
428
|
end
|
429
429
|
|
430
|
-
describe
|
431
|
-
it "
|
432
|
-
obj =
|
433
|
-
obj.
|
430
|
+
describe "--no-private option" do
|
431
|
+
it "accepts --no-private" do
|
432
|
+
obj = double(:object)
|
433
|
+
expect(obj).to receive(:tag).ordered.with(:private).and_return(true)
|
434
434
|
@yardoc.parse_arguments *%w( --no-private )
|
435
|
-
@yardoc.options.verifier.call(obj).
|
435
|
+
expect(@yardoc.options.verifier.call(obj)).to be false
|
436
436
|
end
|
437
437
|
|
438
|
-
it "
|
439
|
-
ns =
|
440
|
-
ns.
|
441
|
-
|
442
|
-
obj
|
443
|
-
obj.stub!(:namespace).and_return(ns)
|
444
|
-
obj.should_receive(:tag).with(:private).and_return(false)
|
438
|
+
it "hides object if namespace is @private with --no-private" do
|
439
|
+
ns = double(:namespace, :type => :module)
|
440
|
+
expect(ns).to receive(:tag).with(:private).and_return(true)
|
441
|
+
obj = double(:object, :namespace => ns)
|
442
|
+
expect(obj).to receive(:tag).with(:private).and_return(false)
|
445
443
|
@yardoc.parse_arguments *%w( --no-private )
|
446
|
-
@yardoc.options.verifier.call(obj).
|
447
|
-
end
|
448
|
-
|
449
|
-
it "
|
450
|
-
ns =
|
451
|
-
ns.
|
452
|
-
ns.
|
453
|
-
obj =
|
454
|
-
obj.
|
455
|
-
obj.stub!(:namespace).and_return(ns)
|
456
|
-
obj.stub!(:visibility).and_return(:public)
|
457
|
-
obj.should_receive(:tag).ordered.with(:private).and_return(false)
|
444
|
+
expect(@yardoc.options.verifier.call(obj)).to be false
|
445
|
+
end
|
446
|
+
|
447
|
+
it "does not call #tag on namespace if namespace is proxy with --no-private" do
|
448
|
+
ns = double(:namespace)
|
449
|
+
expect(ns).to receive(:is_a?).with(CodeObjects::Proxy).and_return(true)
|
450
|
+
expect(ns).not_to receive(:tag)
|
451
|
+
obj = double(:object, :type => :class, :namespace => ns, :visibility => :public)
|
452
|
+
expect(obj).to receive(:tag).ordered.with(:private).and_return(false)
|
458
453
|
@yardoc.parse_arguments *%w( --no-private )
|
459
|
-
@yardoc.options.verifier.call(obj).
|
454
|
+
expect(@yardoc.options.verifier.call(obj)).to be true
|
460
455
|
end
|
461
456
|
|
462
457
|
# @bug gh-197
|
463
|
-
it "
|
458
|
+
it "does not call #tag on namespace if namespace is proxy with --no-private" do
|
464
459
|
Registry.clear
|
465
460
|
YARD.parse_string "module Qux; class Foo::Bar; end; end"
|
466
461
|
foobar = Registry.at('Foo::Bar')
|
467
462
|
foobar.namespace.type = :module
|
468
463
|
@yardoc.parse_arguments *%w( --no-private )
|
469
|
-
@yardoc.options.verifier.call(foobar).
|
464
|
+
expect(@yardoc.options.verifier.call(foobar)).to be true
|
470
465
|
end
|
471
466
|
|
472
|
-
it "
|
467
|
+
it "does not call #tag on proxy object" do # @bug gh-197
|
473
468
|
@yardoc.parse_arguments *%w( --no-private )
|
474
|
-
@yardoc.options.verifier.call(P('ProxyClass')).
|
469
|
+
expect(@yardoc.options.verifier.call(P('ProxyClass'))).to be true
|
475
470
|
end
|
476
471
|
|
477
|
-
it "
|
472
|
+
it "hides methods inside a 'private' class/module with --no-private" do
|
478
473
|
Registry.clear
|
479
474
|
YARD.parse_string <<-eof
|
480
475
|
# @private
|
@@ -483,321 +478,321 @@ describe YARD::CLI::Yardoc do
|
|
483
478
|
end
|
484
479
|
eof
|
485
480
|
@yardoc.parse_arguments *%w( --no-private )
|
486
|
-
@yardoc.options.verifier.call(Registry.at('ABC')).
|
487
|
-
@yardoc.options.verifier.call(Registry.at('ABC#foo')).
|
481
|
+
expect(@yardoc.options.verifier.call(Registry.at('ABC'))).to be false
|
482
|
+
expect(@yardoc.options.verifier.call(Registry.at('ABC#foo'))).to be false
|
488
483
|
end
|
489
484
|
end
|
490
485
|
|
491
|
-
describe
|
486
|
+
describe ".yardopts and .document handling" do
|
492
487
|
before do
|
493
488
|
@yardoc.use_yardopts_file = true
|
494
489
|
end
|
495
490
|
|
496
|
-
it "
|
497
|
-
File.
|
491
|
+
it "searches for and uses yardopts file specified by #options_file" do
|
492
|
+
expect(File).to receive(:read_binary).with("test").and_return("-o \n\nMYPATH\nFILE1 FILE2")
|
498
493
|
@yardoc.use_document_file = false
|
499
494
|
@yardoc.options_file = "test"
|
500
495
|
@yardoc.run
|
501
|
-
@yardoc.options.serializer.options[:basepath].
|
502
|
-
@yardoc.files.
|
496
|
+
expect(@yardoc.options.serializer.options[:basepath]).to eq "MYPATH"
|
497
|
+
expect(@yardoc.files).to eq ["FILE1", "FILE2"]
|
503
498
|
end
|
504
499
|
|
505
|
-
it "
|
500
|
+
it "uses String#shell_split to split .yardopts tokens" do
|
506
501
|
optsdata = "foo bar"
|
507
|
-
optsdata.
|
508
|
-
File.
|
502
|
+
expect(optsdata).to receive(:shell_split)
|
503
|
+
expect(File).to receive(:read_binary).with("test").and_return(optsdata)
|
509
504
|
@yardoc.options_file = "test"
|
510
505
|
@yardoc.run
|
511
506
|
end
|
512
507
|
|
513
|
-
it "
|
514
|
-
File.
|
508
|
+
it "allows opts specified in command line to override yardopts file" do
|
509
|
+
expect(File).to receive(:read_binary).with(".yardopts").and_return("-o NOTMYPATH")
|
515
510
|
@yardoc.run("-o", "MYPATH", "FILE")
|
516
|
-
@yardoc.options.serializer.options[:basepath].
|
517
|
-
@yardoc.files.
|
511
|
+
expect(@yardoc.options.serializer.options[:basepath]).to eq "MYPATH"
|
512
|
+
expect(@yardoc.files).to eq ["FILE"]
|
518
513
|
end
|
519
514
|
|
520
|
-
it "
|
521
|
-
File.
|
515
|
+
it "loads the RDoc .document file if found" do
|
516
|
+
expect(File).to receive(:read_binary).with(".yardopts").and_return("-o NOTMYPATH")
|
522
517
|
@yardoc.use_document_file = true
|
523
|
-
@yardoc.
|
518
|
+
allow(@yardoc).to receive(:support_rdoc_document_file!).and_return(["FILE2", "FILE3"])
|
524
519
|
@yardoc.run("-o", "MYPATH", "FILE1")
|
525
|
-
@yardoc.options.serializer.options[:basepath].
|
526
|
-
@yardoc.files.
|
520
|
+
expect(@yardoc.options.serializer.options[:basepath]).to eq "MYPATH"
|
521
|
+
expect(@yardoc.files).to eq ["FILE2", "FILE3", "FILE1"]
|
527
522
|
end
|
528
523
|
end
|
529
524
|
|
530
|
-
describe
|
525
|
+
describe "Query options" do
|
531
526
|
after { Registry.clear }
|
532
527
|
|
533
|
-
it "
|
528
|
+
it "hides private constants in with default visibilities" do
|
534
529
|
classobj = CodeObjects::ClassObject.new(:root, :Foo) {|o| o.visibility = :private }
|
535
530
|
@yardoc.run
|
536
|
-
@yardoc.options.verifier.run([classobj]).
|
531
|
+
expect(@yardoc.options.verifier.run([classobj])).to eq []
|
537
532
|
end
|
538
533
|
|
539
|
-
it "
|
534
|
+
it "sets up visibility rules as verifier" do
|
540
535
|
methobj = CodeObjects::MethodObject.new(:root, :test) {|o| o.visibility = :private }
|
541
|
-
File.
|
536
|
+
expect(File).to receive(:read_binary).with("test").and_return("--private")
|
542
537
|
@yardoc.use_yardopts_file = true
|
543
538
|
@yardoc.options_file = "test"
|
544
539
|
@yardoc.run
|
545
|
-
@yardoc.options.verifier.call(methobj).
|
540
|
+
expect(@yardoc.options.verifier.call(methobj)).to be true
|
546
541
|
end
|
547
542
|
|
548
|
-
it "
|
543
|
+
it "accepts a --query" do
|
549
544
|
@yardoc.parse_arguments *%w( --query @return )
|
550
|
-
@yardoc.options.verifier.
|
545
|
+
expect(@yardoc.options.verifier).to be_a(Verifier)
|
551
546
|
end
|
552
547
|
|
553
|
-
it "
|
554
|
-
obj =
|
555
|
-
obj.
|
556
|
-
obj.
|
548
|
+
it "accepts multiple --query arguments" do
|
549
|
+
obj = double(:object)
|
550
|
+
expect(obj).to receive(:tag).ordered.with('return').and_return(true)
|
551
|
+
expect(obj).to receive(:tag).ordered.with('tag').and_return(false)
|
557
552
|
@yardoc.parse_arguments *%w( --query @return --query @tag )
|
558
|
-
@yardoc.options.verifier.
|
559
|
-
@yardoc.options.verifier.call(obj).
|
553
|
+
expect(@yardoc.options.verifier).to be_a(Verifier)
|
554
|
+
expect(@yardoc.options.verifier.call(obj)).to be false
|
560
555
|
end
|
561
556
|
end
|
562
557
|
|
563
|
-
describe
|
564
|
-
it "
|
565
|
-
Dir.
|
566
|
-
File.
|
567
|
-
File.
|
568
|
-
File.
|
569
|
-
File.
|
558
|
+
describe "Extra file arguments" do
|
559
|
+
it "accepts extra files if specified after '-' with source files" do
|
560
|
+
expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return([])
|
561
|
+
expect(File).to receive(:file?).with('extra_file1').and_return(true)
|
562
|
+
expect(File).to receive(:file?).with('extra_file2').and_return(true)
|
563
|
+
expect(File).to receive(:read).with('extra_file1').and_return('')
|
564
|
+
expect(File).to receive(:read).with('extra_file2').and_return('')
|
570
565
|
@yardoc.parse_arguments *%w( file1 file2 - extra_file1 extra_file2 )
|
571
|
-
@yardoc.files.
|
572
|
-
@yardoc.options.files.
|
566
|
+
expect(@yardoc.files).to eq %w( file1 file2 )
|
567
|
+
expect(@yardoc.options.files).to eq(
|
573
568
|
[CodeObjects::ExtraFileObject.new('extra_file1', ''),
|
574
|
-
CodeObjects::ExtraFileObject.new('extra_file2', '')]
|
569
|
+
CodeObjects::ExtraFileObject.new('extra_file2', '')])
|
575
570
|
end
|
576
571
|
|
577
|
-
it "
|
578
|
-
Dir.
|
572
|
+
it "accepts files section only containing extra files" do
|
573
|
+
expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return([])
|
579
574
|
@yardoc.parse_arguments *%w( - LICENSE )
|
580
|
-
@yardoc.files.
|
581
|
-
@yardoc.options.files.
|
575
|
+
expect(@yardoc.files).to eq Parser::SourceParser::DEFAULT_PATH_GLOB
|
576
|
+
expect(@yardoc.options.files).to eq [CodeObjects::ExtraFileObject.new('LICENSE', '')]
|
582
577
|
end
|
583
578
|
|
584
|
-
it "
|
585
|
-
Dir.
|
586
|
-
Dir.
|
587
|
-
File.
|
588
|
-
File.
|
589
|
-
File.
|
590
|
-
File.
|
579
|
+
it "accepts globs as extra files" do
|
580
|
+
expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return []
|
581
|
+
expect(Dir).to receive(:glob).with('*.txt').and_return ['a.txt', 'b.txt']
|
582
|
+
expect(File).to receive(:read).with('a.txt').and_return('')
|
583
|
+
expect(File).to receive(:read).with('b.txt').and_return('')
|
584
|
+
expect(File).to receive(:file?).with('a.txt').and_return(true)
|
585
|
+
expect(File).to receive(:file?).with('b.txt').and_return(true)
|
591
586
|
@yardoc.parse_arguments *%w( file1 file2 - *.txt )
|
592
|
-
@yardoc.files.
|
593
|
-
@yardoc.options.files.
|
587
|
+
expect(@yardoc.files).to eq %w( file1 file2 )
|
588
|
+
expect(@yardoc.options.files).to eq(
|
594
589
|
[CodeObjects::ExtraFileObject.new('a.txt', ''),
|
595
|
-
CodeObjects::ExtraFileObject.new('b.txt', '')]
|
590
|
+
CodeObjects::ExtraFileObject.new('b.txt', '')])
|
596
591
|
end
|
597
592
|
|
598
|
-
it "
|
599
|
-
log.
|
593
|
+
it "warns if extra file is not found" do
|
594
|
+
expect(log).to receive(:warn).with(/Could not find extra file: UNKNOWN/)
|
600
595
|
@yardoc.parse_arguments *%w( - UNKNOWN )
|
601
596
|
end
|
602
597
|
|
603
|
-
it "
|
604
|
-
log.
|
598
|
+
it "warns if readme file is not found" do
|
599
|
+
expect(log).to receive(:warn).with(/Could not find readme file: UNKNOWN/)
|
605
600
|
@yardoc.parse_arguments *%w( -r UNKNOWN )
|
606
601
|
end
|
607
602
|
|
608
|
-
it "
|
609
|
-
Dir.
|
610
|
-
Dir.
|
611
|
-
File.
|
603
|
+
it "uses first file as readme if no readme is specified when using --one-file" do
|
604
|
+
expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return []
|
605
|
+
expect(Dir).to receive(:glob).with('lib/*.rb').and_return(['lib/foo.rb'])
|
606
|
+
expect(File).to receive(:read).with('lib/foo.rb').and_return('')
|
612
607
|
@yardoc.parse_arguments *%w( --one-file lib/*.rb )
|
613
|
-
@yardoc.options.readme.
|
608
|
+
expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('lib/foo.rb', '')
|
614
609
|
end
|
615
610
|
|
616
|
-
it "
|
617
|
-
Dir.
|
618
|
-
File.
|
611
|
+
it "uses readme it exists when using --one-file" do
|
612
|
+
expect(Dir).to receive(:glob).with('README{,*[^~]}').and_return ['README']
|
613
|
+
expect(File).to receive(:read).with('README').and_return('')
|
619
614
|
@yardoc.parse_arguments *%w( --one-file lib/*.rb )
|
620
|
-
@yardoc.options.readme.
|
615
|
+
expect(@yardoc.options.readme).to eq CodeObjects::ExtraFileObject.new('README', '')
|
621
616
|
end
|
622
617
|
|
623
|
-
it "
|
618
|
+
it "does not allow US-ASCII charset when using --one-file" do
|
624
619
|
ienc = Encoding.default_internal
|
625
620
|
eenc = Encoding.default_external
|
626
|
-
log.
|
621
|
+
expect(log).to receive(:warn).with(/not compatible with US-ASCII.*using ASCII-8BIT/)
|
627
622
|
@yardoc.parse_arguments *%w( --one-file --charset us-ascii )
|
628
|
-
Encoding.default_internal.name.
|
629
|
-
Encoding.default_external.name.
|
623
|
+
expect(Encoding.default_internal.name).to eq 'ASCII-8BIT'
|
624
|
+
expect(Encoding.default_external.name).to eq 'ASCII-8BIT'
|
630
625
|
Encoding.default_internal = ienc
|
631
626
|
Encoding.default_external = eenc
|
632
627
|
end if defined?(::Encoding)
|
633
628
|
end
|
634
629
|
|
635
|
-
describe
|
636
|
-
it "
|
630
|
+
describe "Source file arguments" do
|
631
|
+
it "accepts no params and parse {lib,app}/**/*.rb ext/**/*.c" do
|
637
632
|
@yardoc.parse_arguments
|
638
|
-
@yardoc.files.
|
633
|
+
expect(@yardoc.files).to eq Parser::SourceParser::DEFAULT_PATH_GLOB
|
639
634
|
end
|
640
635
|
end
|
641
636
|
|
642
|
-
describe
|
637
|
+
describe "Tags options" do
|
643
638
|
def tag_created(switch, factory_method)
|
644
|
-
visible_tags =
|
645
|
-
visible_tags.
|
646
|
-
visible_tags.
|
647
|
-
Tags::Library.
|
648
|
-
Tags::Library.
|
649
|
-
Tags::Library.
|
639
|
+
visible_tags = double(:visible_tags)
|
640
|
+
expect(visible_tags).to receive(:|).ordered.with([:foo])
|
641
|
+
expect(visible_tags).to receive(:-).ordered.with([]).and_return(visible_tags)
|
642
|
+
expect(Tags::Library).to receive(:define_tag).with('Foo', :foo, factory_method)
|
643
|
+
allow(Tags::Library).to receive(:visible_tags=)
|
644
|
+
expect(Tags::Library).to receive(:visible_tags).at_least(1).times.and_return(visible_tags)
|
650
645
|
@yardoc.parse_arguments("--#{switch}-tag", 'foo')
|
651
646
|
end
|
652
647
|
|
653
648
|
def tag_hidden(tag)
|
654
|
-
visible_tags =
|
655
|
-
visible_tags.
|
656
|
-
visible_tags.
|
657
|
-
Tags::Library.
|
658
|
-
Tags::Library.
|
659
|
-
Tags::Library.
|
649
|
+
visible_tags = double(:visible_tags)
|
650
|
+
expect(visible_tags).to receive(:|).ordered.with([tag])
|
651
|
+
expect(visible_tags).to receive(:-).ordered.with([tag]).and_return([])
|
652
|
+
expect(Tags::Library).to receive(:define_tag).with(tag.to_s.capitalize, tag, nil)
|
653
|
+
allow(Tags::Library).to receive(:visible_tags=)
|
654
|
+
expect(Tags::Library).to receive(:visible_tags).at_least(1).times.and_return(visible_tags)
|
660
655
|
end
|
661
656
|
|
662
|
-
it "
|
663
|
-
Tags::Library.
|
657
|
+
it "accepts --tag" do
|
658
|
+
expect(Tags::Library).to receive(:define_tag).with('Title of Foo', :foo, nil)
|
664
659
|
@yardoc.parse_arguments('--tag', 'foo:Title of Foo')
|
665
660
|
end
|
666
661
|
|
667
|
-
it "
|
668
|
-
Tags::Library.
|
662
|
+
it "accepts --tag without title (and default to captialized tag name)" do
|
663
|
+
expect(Tags::Library).to receive(:define_tag).with('Foo', :foo, nil)
|
669
664
|
@yardoc.parse_arguments('--tag', 'foo')
|
670
665
|
end
|
671
666
|
|
672
|
-
it "
|
667
|
+
it "only lists tag once if declared twice" do
|
673
668
|
visible_tags = []
|
674
|
-
Tags::Library.
|
675
|
-
Tags::Library.
|
676
|
-
Tags::Library.
|
669
|
+
allow(Tags::Library).to receive(:define_tag)
|
670
|
+
allow(Tags::Library).to receive(:visible_tags).and_return([:foo])
|
671
|
+
allow(Tags::Library).to receive(:visible_tags=) {|value| visible_tags = value }
|
677
672
|
@yardoc.parse_arguments('--tag', 'foo', '--tag', 'foo')
|
678
|
-
visible_tags.
|
673
|
+
expect(visible_tags).to eq [:foo]
|
679
674
|
end
|
680
675
|
|
681
|
-
it "
|
676
|
+
it "accepts --type-tag" do
|
682
677
|
tag_created 'type', :with_types
|
683
678
|
end
|
684
679
|
|
685
|
-
it "
|
680
|
+
it "accepts --type-name-tag" do
|
686
681
|
tag_created 'type-name', :with_types_and_name
|
687
682
|
end
|
688
683
|
|
689
|
-
it "
|
684
|
+
it "accepts --name-tag" do
|
690
685
|
tag_created 'name', :with_name
|
691
686
|
end
|
692
687
|
|
693
|
-
it "
|
688
|
+
it "accepts --title-tag" do
|
694
689
|
tag_created 'title', :with_title_and_text
|
695
690
|
end
|
696
691
|
|
697
|
-
it "
|
692
|
+
it "accepts --hide-tag before tag is listed" do
|
698
693
|
tag_hidden(:anewfoo)
|
699
694
|
@yardoc.parse_arguments('--hide-tag', 'anewfoo', '--tag', 'anewfoo')
|
700
695
|
end
|
701
696
|
|
702
|
-
it "
|
697
|
+
it "accepts --hide-tag after tag is listed" do
|
703
698
|
tag_hidden(:anewfoo2)
|
704
699
|
@yardoc.parse_arguments('--tag', 'anewfoo2', '--hide-tag', 'anewfoo2')
|
705
700
|
end
|
706
701
|
|
707
|
-
it "
|
702
|
+
it "accepts --transitive-tag" do
|
708
703
|
@yardoc.parse_arguments('--transitive-tag', 'foo')
|
709
|
-
Tags::Library.transitive_tags.
|
704
|
+
expect(Tags::Library.transitive_tags).to include(:foo)
|
710
705
|
end
|
711
706
|
|
712
|
-
it "
|
707
|
+
it "accepts --non-transitive-tag" do
|
713
708
|
Tags::Library.transitive_tags |= [:foo]
|
714
709
|
@yardoc.parse_arguments('--non-transitive-tag', 'foo')
|
715
|
-
Tags::Library.transitive_tags.
|
710
|
+
expect(Tags::Library.transitive_tags).not_to include(:foo)
|
716
711
|
end
|
717
712
|
end
|
718
713
|
|
719
|
-
describe
|
714
|
+
describe "Safe mode" do
|
720
715
|
before do
|
721
|
-
YARD::Config.
|
716
|
+
allow(YARD::Config).to receive(:options).and_return(:safe_mode => true)
|
722
717
|
end
|
723
718
|
|
724
|
-
it "
|
725
|
-
@yardoc.
|
719
|
+
it "does not allow --load or -e in safe mode" do
|
720
|
+
expect(@yardoc).not_to receive(:require)
|
726
721
|
@yardoc.run('--load', 'foo')
|
727
722
|
@yardoc.run('-e', 'foo')
|
728
723
|
end
|
729
724
|
|
730
|
-
it "
|
725
|
+
it "does not allow --query in safe mode" do
|
731
726
|
@yardoc.run('--query', 'foo')
|
732
|
-
@yardoc.options.verifier.expressions.
|
727
|
+
expect(@yardoc.options.verifier.expressions).not_to include("foo")
|
733
728
|
end
|
734
729
|
|
735
|
-
it "
|
736
|
-
YARD::Templates::Engine.
|
730
|
+
it "does not allow modifying the template paths" do
|
731
|
+
expect(YARD::Templates::Engine).not_to receive(:register_template_path)
|
737
732
|
@yardoc.run('-p', 'foo')
|
738
733
|
@yardoc.run('--template-path', 'foo')
|
739
734
|
end
|
740
735
|
end
|
741
736
|
|
742
|
-
describe
|
743
|
-
it "
|
737
|
+
describe "Markup Loading" do
|
738
|
+
it "loads rdoc markup if no markup is provided" do
|
744
739
|
@yardoc.generate = true
|
745
740
|
@yardoc.run
|
746
|
-
@yardoc.options.markup.
|
741
|
+
expect(@yardoc.options.markup).to eq :rdoc
|
747
742
|
end
|
748
743
|
|
749
|
-
it "
|
744
|
+
it "loads rdoc markup even when no output is specified" do
|
750
745
|
@yardoc.parse_arguments('--no-output')
|
751
|
-
@yardoc.options.markup.
|
746
|
+
expect(@yardoc.options.markup).to eq :rdoc
|
752
747
|
end
|
753
748
|
|
754
|
-
it "
|
749
|
+
it "warns if rdoc cannot be loaded and fallback to :none" do
|
755
750
|
mod = YARD::Templates::Helpers::MarkupHelper
|
756
751
|
mod.clear_markup_cache
|
757
|
-
mod.const_get(:MARKUP_PROVIDERS).
|
758
|
-
log.
|
759
|
-
@yardoc.
|
752
|
+
expect(mod.const_get(:MARKUP_PROVIDERS)).to receive(:[]).with(:rdoc).and_return([{:lib => 'INVALID'}])
|
753
|
+
expect(log).to receive(:warn).with(/Could not load default RDoc formatter/)
|
754
|
+
allow(@yardoc).to receive(:generate) { @yardoc.options.files = []; true }
|
760
755
|
@yardoc.run
|
761
|
-
@yardoc.options.markup.
|
756
|
+
expect(@yardoc.options.markup).to eq :none
|
762
757
|
mod.clear_markup_cache
|
763
758
|
end
|
764
759
|
|
765
|
-
it "
|
760
|
+
it "returns an error immediately if markup for any files are missing" do
|
766
761
|
mod = YARD::Templates::Helpers::MarkupHelper
|
767
762
|
mod.clear_markup_cache
|
768
|
-
mod.const_get(:MARKUP_PROVIDERS).
|
769
|
-
log.
|
763
|
+
expect(mod.const_get(:MARKUP_PROVIDERS)).to receive(:[]).with(:markdown).and_return([{:lib => 'INVALID'}])
|
764
|
+
expect(log).to receive(:error).with(/Missing 'INVALID' gem for Markdown formatting/)
|
770
765
|
files = [CodeObjects::ExtraFileObject.new('test.md', '')]
|
771
|
-
@yardoc.
|
766
|
+
allow(@yardoc).to receive(:generate) { @yardoc.options.files = files; true }
|
772
767
|
@yardoc.run
|
773
768
|
mod.clear_markup_cache
|
774
769
|
end
|
775
770
|
|
776
|
-
it "
|
771
|
+
it "returns an error immediately if markup for any files are missing (file markup specified in attributes)" do
|
777
772
|
mod = YARD::Templates::Helpers::MarkupHelper
|
778
773
|
mod.clear_markup_cache
|
779
|
-
mod.const_get(:MARKUP_PROVIDERS).
|
780
|
-
log.
|
774
|
+
expect(mod.const_get(:MARKUP_PROVIDERS)).to receive(:[]).with(:markdown).and_return([{:lib => 'INVALID'}])
|
775
|
+
expect(log).to receive(:error).with(/Missing 'INVALID' gem for Markdown formatting/)
|
781
776
|
files = [CodeObjects::ExtraFileObject.new('test', '# @markup markdown')]
|
782
|
-
@yardoc.
|
777
|
+
allow(@yardoc).to receive(:generate) { @yardoc.options.files = files; true }
|
783
778
|
@yardoc.run
|
784
779
|
mod.clear_markup_cache
|
785
780
|
end
|
786
781
|
end
|
787
782
|
|
788
|
-
describe
|
789
|
-
it "
|
790
|
-
@yardoc.
|
783
|
+
describe "#run" do
|
784
|
+
it "parses arguments if run() is called" do
|
785
|
+
expect(@yardoc).to receive(:parse_arguments)
|
791
786
|
@yardoc.run
|
792
787
|
end
|
793
788
|
|
794
|
-
it "
|
795
|
-
@yardoc.
|
789
|
+
it "parses arguments if run(arg1, arg2, ...) is called" do
|
790
|
+
expect(@yardoc).to receive(:parse_arguments)
|
796
791
|
@yardoc.run('--private', '-p', 'foo')
|
797
792
|
end
|
798
793
|
|
799
|
-
it "
|
800
|
-
@yardoc.
|
794
|
+
it "does not parse arguments if run(nil) is called" do
|
795
|
+
expect(@yardoc).not_to receive(:parse_arguments)
|
801
796
|
@yardoc.run(nil)
|
802
797
|
end
|
803
798
|
end
|