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
@@ -4,21 +4,22 @@ describe YARD::Templates::Helpers::HtmlSyntaxHighlightHelper do
|
|
4
4
|
include YARD::Templates::Helpers::HtmlHelper
|
5
5
|
include YARD::Templates::Helpers::HtmlSyntaxHighlightHelper
|
6
6
|
|
7
|
-
describe
|
7
|
+
describe "#html_syntax_highlight" do
|
8
|
+
let(:object) { Registry.root }
|
9
|
+
|
8
10
|
before do
|
9
|
-
stub!(:object).and_return Registry.root
|
10
11
|
Registry.root.source_type = :ruby
|
11
12
|
end
|
12
13
|
|
13
|
-
it "
|
14
|
-
|
15
|
-
html_syntax_highlight("def x\nend").
|
14
|
+
it "does not highlight source if options.highlight is false" do
|
15
|
+
expect(self).to receive(:options).and_return(Options.new.update(:highlight => false))
|
16
|
+
expect(html_syntax_highlight("def x\nend")).to eq "def x\nend"
|
16
17
|
end
|
17
18
|
|
18
|
-
it "
|
19
|
+
it "highlights source (legacy)" do
|
19
20
|
type = Parser::SourceParser.parser_type
|
20
21
|
Parser::SourceParser.parser_type = :ruby18
|
21
|
-
|
22
|
+
expect(self).to receive(:options).and_return(Options.new.update(:highlight => true))
|
22
23
|
expect = "<span class='rubyid_def def kw'>def</span><span class='rubyid_x identifier id'>x</span>
|
23
24
|
<span class='string val'>'x'</span><span class='plus op'>+</span>
|
24
25
|
<span class='regexp val'>/x/i</span><span class='rubyid_end end kw'>end</span>"
|
@@ -27,8 +28,8 @@ describe YARD::Templates::Helpers::HtmlSyntaxHighlightHelper do
|
|
27
28
|
Parser::SourceParser.parser_type = type
|
28
29
|
end
|
29
30
|
|
30
|
-
it "
|
31
|
-
|
31
|
+
it "highlights source (ripper)" do
|
32
|
+
expect(self).to receive(:options).and_return(Options.new.update(:highlight => true))
|
32
33
|
Parser::SourceParser.parser_type = :ruby
|
33
34
|
expect = "<span class='kw'>def</span> <span class='id identifier rubyid_x'>x</span>
|
34
35
|
<span class='tstring'><span class='tstring_beg'>'</span>
|
@@ -40,14 +41,14 @@ describe YARD::Templates::Helpers::HtmlSyntaxHighlightHelper do
|
|
40
41
|
html_equals_string(result, expect)
|
41
42
|
end if HAVE_RIPPER
|
42
43
|
|
43
|
-
it "
|
44
|
-
|
45
|
-
html_syntax_highlight("def &x; ... end").
|
44
|
+
it "returns escaped unhighlighted source if a syntax error is found (ripper)" do
|
45
|
+
expect(self).to receive(:options).and_return(Options.new.update(:highlight => true))
|
46
|
+
expect(html_syntax_highlight("def &x; ... end")).to eq "def &x; ... end"
|
46
47
|
end if HAVE_RIPPER
|
47
48
|
|
48
|
-
it "
|
49
|
-
|
50
|
-
html_syntax_highlight("$ git clone http://url").
|
49
|
+
it "returns escaped unhighlighted source if a syntax error is found (ripper)" do
|
50
|
+
expect(self).to receive(:options).and_return(Options.new.update(:highlight => true))
|
51
|
+
expect(html_syntax_highlight("$ git clone http://url")).to eq "$ git clone http://url"
|
51
52
|
end if HAVE_RIPPER
|
52
53
|
end
|
53
54
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/../../spec_helper"
|
2
2
|
|
3
3
|
describe YARD::Templates::Helpers::Markup::RDocMarkup do
|
4
|
-
describe
|
4
|
+
describe "loading mechanism" do
|
5
5
|
before { @good_libs = [] }
|
6
6
|
|
7
7
|
def require(lib)
|
@@ -25,69 +25,62 @@ describe YARD::Templates::Helpers::Markup::RDocMarkup do
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
28
|
+
it "loads RDoc2.x if rdoc/markup is present" do
|
29
29
|
@good_libs += ['rdoc/markup', 'rdoc/markup/to_html']
|
30
|
-
load_markup.
|
30
|
+
expect(load_markup).to eq :RDoc2
|
31
31
|
end
|
32
32
|
|
33
|
-
it "
|
33
|
+
it "fails on RDoc2.x if rdoc/markup/to_html is not present" do
|
34
34
|
@good_libs += ['rdoc/markup']
|
35
|
-
|
35
|
+
expect { load_markup }.to raise_error(NameError)
|
36
36
|
end
|
37
37
|
|
38
|
-
it "
|
38
|
+
it "loads RDoc1.x if RDoc2 fails and rdoc/markup/simple_markup is present" do
|
39
39
|
@good_libs += ['rdoc/markup/simple_markup', 'rdoc/markup/simple_markup/to_html']
|
40
|
-
load_markup.
|
40
|
+
expect(load_markup).to eq :RDoc1
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
44
|
-
|
43
|
+
it "raises an error on loading if neither lib is present" do
|
44
|
+
expect { load_markup }.to raise_error(NameError)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
-
describe
|
48
|
+
describe "#to_html" do
|
49
49
|
def to_html(text)
|
50
50
|
html = YARD::Templates::Helpers::Markup::RDocMarkup.new(text).to_html
|
51
51
|
html.strip.gsub(/\r?\n/, '')
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
55
|
-
to_html('Hello +<code>+').
|
54
|
+
it "handles typewriter text" do
|
55
|
+
expect(to_html('Hello +<code>+')).to eq '<p>Hello <tt><code></tt></p>'
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
describe
|
59
|
+
describe "#fix_typewriter" do
|
60
60
|
def fix_typewriter(text)
|
61
61
|
YARD::Templates::Helpers::Markup::RDocMarkup.new('').send(:fix_typewriter, text)
|
62
62
|
end
|
63
63
|
|
64
|
-
it "
|
65
|
-
fix_typewriter("Some +typewriter text <+.").
|
66
|
-
|
67
|
-
fix_typewriter("
|
68
|
-
|
69
|
-
fix_typewriter("
|
70
|
-
|
71
|
-
fix_typewriter("No ++problem.").should ==
|
72
|
-
"No ++problem."
|
73
|
-
fix_typewriter("Math + stuff +is ok+").should ==
|
74
|
-
"Math + stuff <tt>is ok</tt>"
|
75
|
-
fix_typewriter("Hello +{Foo}+ World").should == "Hello <tt>{Foo}</tt> World"
|
64
|
+
it "converts +text+ to <tt>text</tt>" do
|
65
|
+
expect(fix_typewriter("Some +typewriter text <+.")).to eq "Some <tt>typewriter text <</tt>."
|
66
|
+
expect(fix_typewriter("Not +typewriter text.")).to eq "Not +typewriter text."
|
67
|
+
expect(fix_typewriter("Alternating +type writer+ text +here+.")).to eq "Alternating <tt>type writer</tt> text <tt>here</tt>."
|
68
|
+
expect(fix_typewriter("No ++problem.")).to eq "No ++problem."
|
69
|
+
expect(fix_typewriter("Math + stuff +is ok+")).to eq "Math + stuff <tt>is ok</tt>"
|
70
|
+
expect(fix_typewriter("Hello +{Foo}+ World")).to eq "Hello <tt>{Foo}</tt> World"
|
76
71
|
end
|
77
72
|
|
78
|
-
it "
|
79
|
-
fix_typewriter("<code>Hello +hello+</code>").
|
73
|
+
it "does not apply to code blocks" do
|
74
|
+
expect(fix_typewriter("<code>Hello +hello+</code>")).to eq "<code>Hello +hello+</code>"
|
80
75
|
end
|
81
76
|
|
82
|
-
it "
|
83
|
-
fix_typewriter("<a href='http://foo.com/A+b+c'>A+b+c</a>").
|
84
|
-
|
85
|
-
fix_typewriter("<foo class='foo+bar+baz'/>").should ==
|
86
|
-
"<foo class='foo+bar+baz'/>"
|
77
|
+
it "does not apply to HTML tag attributes" do
|
78
|
+
expect(fix_typewriter("<a href='http://foo.com/A+b+c'>A+b+c</a>")).to eq "<a href='http://foo.com/A+b+c'>A+b+c</a>"
|
79
|
+
expect(fix_typewriter("<foo class='foo+bar+baz'/>")).to eq "<foo class='foo+bar+baz'/>"
|
87
80
|
end
|
88
81
|
|
89
|
-
it "
|
90
|
-
fix_typewriter("<p>+foo+</p>").
|
82
|
+
it "still applies inside of other tags" do
|
83
|
+
expect(fix_typewriter("<p>+foo+</p>")).to eq "<p><tt>foo</tt></p>"
|
91
84
|
end
|
92
85
|
end
|
93
86
|
end
|
@@ -17,117 +17,117 @@ describe YARD::Templates::Helpers::MarkupHelper do
|
|
17
17
|
YARD::Templates::Helpers::MarkupHelper.clear_markup_cache
|
18
18
|
end
|
19
19
|
|
20
|
-
describe
|
20
|
+
describe "#load_markup_provider" do
|
21
21
|
before do
|
22
|
-
log.
|
22
|
+
allow(log).to receive(:error)
|
23
23
|
@gen = GeneratorMock.new
|
24
24
|
@gen.options.reset_defaults
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "exits on an invalid markup type" do
|
28
28
|
@gen.options.markup = :invalid
|
29
|
-
@gen.load_markup_provider.
|
29
|
+
expect(@gen.load_markup_provider).to be false
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
32
|
+
it "fails when an invalid markup provider is specified" do
|
33
33
|
@gen.options.update(:markup => :markdown, :markup_provider => :invalid)
|
34
|
-
@gen.load_markup_provider.
|
35
|
-
@gen.markup_class.
|
34
|
+
expect(@gen.load_markup_provider).to be false
|
35
|
+
expect(@gen.markup_class).to eq nil
|
36
36
|
end
|
37
37
|
|
38
|
-
it "
|
38
|
+
it "loads RDocMarkup if rdoc is specified and it is installed" do
|
39
39
|
@gen.options.markup = :rdoc
|
40
|
-
@gen.load_markup_provider.
|
41
|
-
@gen.markup_class.
|
40
|
+
expect(@gen.load_markup_provider).to be true
|
41
|
+
expect(@gen.markup_class).to eq YARD::Templates::Helpers::Markup::RDocMarkup
|
42
42
|
end
|
43
43
|
|
44
|
-
it "
|
44
|
+
it "fails if RDoc cannot be loaded" do
|
45
45
|
@gen.options.markup = :rdoc
|
46
|
-
@gen.
|
47
|
-
@gen.load_markup_provider.
|
48
|
-
@gen.markup_provider.
|
46
|
+
expect(@gen).to receive(:eval).with('::YARD::Templates::Helpers::Markup::RDocMarkup').and_raise(NameError)
|
47
|
+
expect(@gen.load_markup_provider).to be false
|
48
|
+
expect(@gen.markup_provider).to eq nil
|
49
49
|
end
|
50
50
|
|
51
|
-
it "
|
52
|
-
@gen.
|
53
|
-
@gen.
|
54
|
-
@gen.
|
51
|
+
it "searches through available markup providers for the markup type if none is set" do
|
52
|
+
expect(@gen).to receive(:eval).with('::RedcarpetCompat').and_return(double(:bluecloth))
|
53
|
+
expect(@gen).to receive(:require).with('redcarpet').and_return(true)
|
54
|
+
expect(@gen).not_to receive(:require).with('maruku')
|
55
55
|
@gen.options.markup = :markdown
|
56
56
|
# this only raises an exception because we mock out require to avoid
|
57
57
|
# loading any libraries but our implementation tries to return the library
|
58
58
|
# name as a constant
|
59
|
-
@gen.load_markup_provider.
|
60
|
-
@gen.markup_provider.
|
59
|
+
expect(@gen.load_markup_provider).to be true
|
60
|
+
expect(@gen.markup_provider).to eq :redcarpet
|
61
61
|
end
|
62
62
|
|
63
|
-
it "
|
64
|
-
@gen.
|
65
|
-
@gen.
|
66
|
-
@gen.
|
67
|
-
@gen.
|
68
|
-
@gen.
|
69
|
-
@gen.
|
70
|
-
@gen.
|
63
|
+
it "continues searching if some of the providers are unavailable" do
|
64
|
+
expect(@gen).to receive(:require).with('redcarpet').and_raise(LoadError)
|
65
|
+
expect(@gen).to receive(:require).with('rdiscount').and_raise(LoadError)
|
66
|
+
expect(@gen).to receive(:require).with('kramdown').and_raise(LoadError)
|
67
|
+
expect(@gen).to receive(:require).with('bluecloth').and_raise(LoadError)
|
68
|
+
expect(@gen).to receive(:require).with('maruku').and_raise(LoadError)
|
69
|
+
expect(@gen).to receive(:require).with('rpeg-markdown').and_return(true)
|
70
|
+
expect(@gen).to receive(:eval).with('::PEGMarkdown').and_return(true)
|
71
71
|
@gen.options.markup = :markdown
|
72
72
|
# this only raises an exception because we mock out require to avoid
|
73
73
|
# loading any libraries but our implementation tries to return the library
|
74
74
|
# name as a constant
|
75
|
-
@gen.load_markup_provider
|
76
|
-
@gen.markup_provider.
|
75
|
+
@gen.load_markup_provider
|
76
|
+
expect(@gen.markup_provider).to eq :"rpeg-markdown"
|
77
77
|
end
|
78
78
|
|
79
|
-
it "
|
80
|
-
@gen.
|
81
|
-
@gen.
|
79
|
+
it "overrides the search if `:markup_provider` is set in options" do
|
80
|
+
expect(@gen).to receive(:require).with('rdiscount').and_return(true)
|
81
|
+
expect(@gen).to receive(:eval).with('::RDiscount').and_return(true)
|
82
82
|
@gen.options.update(:markup => :markdown, :markup_provider => :rdiscount)
|
83
|
-
@gen.load_markup_provider
|
84
|
-
@gen.markup_provider.
|
83
|
+
@gen.load_markup_provider
|
84
|
+
expect(@gen.markup_provider).to eq :rdiscount
|
85
85
|
end
|
86
86
|
|
87
|
-
it "
|
87
|
+
it "fails if no provider is found" do
|
88
88
|
YARD::Templates::Helpers::MarkupHelper::MARKUP_PROVIDERS[:markdown].each do |p|
|
89
|
-
@gen.
|
89
|
+
expect(@gen).to receive(:require).with(p[:lib].to_s).and_raise(LoadError)
|
90
90
|
end
|
91
91
|
@gen.options.markup = :markdown
|
92
|
-
@gen.load_markup_provider.
|
93
|
-
@gen.markup_provider.
|
92
|
+
expect(@gen.load_markup_provider).to be false
|
93
|
+
expect(@gen.markup_provider).to eq nil
|
94
94
|
end
|
95
95
|
|
96
|
-
it "
|
97
|
-
@gen.
|
96
|
+
it "fails if overridden provider is not found" do
|
97
|
+
expect(@gen).to receive(:require).with('rdiscount').and_raise(LoadError)
|
98
98
|
@gen.options.update(:markup => :markdown, :markup_provider => :rdiscount)
|
99
|
-
@gen.load_markup_provider.
|
100
|
-
@gen.markup_provider.
|
99
|
+
expect(@gen.load_markup_provider).to be false
|
100
|
+
expect(@gen.markup_provider).to eq nil
|
101
101
|
end
|
102
102
|
|
103
|
-
it "
|
104
|
-
log.
|
103
|
+
it "fails if the markup type is not found" do
|
104
|
+
expect(log).to receive(:error).with(/Invalid markup/)
|
105
105
|
@gen.options.markup = :xxx
|
106
|
-
@gen.load_markup_provider.
|
107
|
-
@gen.markup_provider.
|
106
|
+
expect(@gen.load_markup_provider).to be false
|
107
|
+
expect(@gen.markup_provider).to eq nil
|
108
108
|
end
|
109
109
|
end
|
110
110
|
|
111
|
-
describe
|
111
|
+
describe "#markup_for_file" do
|
112
112
|
include YARD::Templates::Helpers::MarkupHelper
|
113
113
|
|
114
|
-
it "
|
115
|
-
markup_for_file("#!text\ntext here", 'file.rdoc').
|
114
|
+
it "looks for a shebang line" do
|
115
|
+
expect(markup_for_file("#!text\ntext here", 'file.rdoc')).to eq :text
|
116
116
|
end
|
117
117
|
|
118
|
-
it "
|
119
|
-
|
120
|
-
markup_for_file('', 'filename').
|
118
|
+
it "returns the default markup type if no shebang is found or no valid ext is found" do
|
119
|
+
allow(self).to receive(:options).and_return(Options.new.update(:markup => :default_type))
|
120
|
+
expect(markup_for_file('', 'filename')).to eq :default_type
|
121
121
|
end
|
122
122
|
|
123
|
-
it "
|
124
|
-
markup_for_file('', 'filename.MD').
|
123
|
+
it "looks for a file extension if no shebang is found" do
|
124
|
+
expect(markup_for_file('', 'filename.MD')).to eq :markdown
|
125
125
|
end
|
126
126
|
|
127
127
|
Templates::Helpers::MarkupHelper::MARKUP_EXTENSIONS.each do |type, exts|
|
128
128
|
exts.each do |ext|
|
129
|
-
it "
|
130
|
-
markup_for_file('', "filename.#{ext}").
|
129
|
+
it "recognizes .#{ext} as #{type} markup type" do
|
130
|
+
expect(markup_for_file('', "filename.#{ext}")).to eq type
|
131
131
|
end
|
132
132
|
end
|
133
133
|
end
|
@@ -4,60 +4,60 @@ describe YARD::Templates::Helpers::MethodHelper do
|
|
4
4
|
include YARD::Templates::Helpers::BaseHelper
|
5
5
|
include YARD::Templates::Helpers::MethodHelper
|
6
6
|
|
7
|
-
describe
|
8
|
-
it "
|
7
|
+
describe "#format_args" do
|
8
|
+
it "displays keyword arguments" do
|
9
9
|
params = [['a:', '1'], ['b:', '2'], ['**kwargs', nil]]
|
10
10
|
YARD.parse_string 'def foo; end'
|
11
|
-
Registry.at('#foo').
|
12
|
-
format_args(Registry.at('#foo')).
|
11
|
+
allow(Registry.at('#foo')).to receive(:parameters) { params }
|
12
|
+
expect(format_args(Registry.at('#foo'))).to eq '(a: 1, b: 2, **kwargs)'
|
13
13
|
end
|
14
14
|
|
15
|
-
it "
|
15
|
+
it "does not show &blockarg if no @param tag and has @yield" do
|
16
16
|
YARD.parse_string <<-'eof'
|
17
17
|
# @yield blah
|
18
18
|
def foo(&block); end
|
19
19
|
eof
|
20
|
-
format_args(Registry.at('#foo')).
|
20
|
+
expect(format_args(Registry.at('#foo'))).to eq ''
|
21
21
|
end
|
22
22
|
|
23
|
-
it "
|
23
|
+
it "does not show &blockarg if no @param tag and has @yieldparam" do
|
24
24
|
YARD.parse_string <<-'eof'
|
25
25
|
# @yieldparam blah test
|
26
26
|
def foo(&block); end
|
27
27
|
eof
|
28
|
-
format_args(Registry.at('#foo')).
|
28
|
+
expect(format_args(Registry.at('#foo'))).to eq ''
|
29
29
|
end
|
30
30
|
|
31
|
-
it "
|
31
|
+
it "shows &blockarg if @param block is documented (even with @yield)" do
|
32
32
|
YARD.parse_string <<-'eof'
|
33
33
|
# @yield [a,b]
|
34
34
|
# @yieldparam a test
|
35
35
|
# @param block test
|
36
36
|
def foo(&block) end
|
37
37
|
eof
|
38
|
-
format_args(Registry.at('#foo')).
|
38
|
+
expect(format_args(Registry.at('#foo'))).to eq '(&block)'
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
describe
|
42
|
+
describe "#format_block" do
|
43
43
|
before { YARD::Registry.clear }
|
44
44
|
|
45
|
-
it "
|
45
|
+
it "shows block for method with yield" do
|
46
46
|
YARD.parse_string <<-'eof'
|
47
47
|
def foo; yield(a, b, c) end
|
48
48
|
eof
|
49
|
-
format_block(Registry.at('#foo')).
|
49
|
+
expect(format_block(Registry.at('#foo'))).to eq "{|a, b, c| ... }"
|
50
50
|
end
|
51
51
|
|
52
|
-
it "
|
52
|
+
it "shows block for method with @yieldparam tags" do
|
53
53
|
YARD.parse_string <<-'eof'
|
54
54
|
# @yieldparam _self me!
|
55
55
|
def foo; end
|
56
56
|
eof
|
57
|
-
format_block(Registry.at('#foo')).
|
57
|
+
expect(format_block(Registry.at('#foo'))).to eq "{|_self| ... }"
|
58
58
|
end
|
59
59
|
|
60
|
-
it "
|
60
|
+
it "shows block for method with @yield but no types" do
|
61
61
|
YARD.parse_string <<-'eof'
|
62
62
|
# @yield blah
|
63
63
|
# @yieldparam a
|
@@ -66,17 +66,17 @@ describe YARD::Templates::Helpers::MethodHelper do
|
|
66
66
|
# @yield blah
|
67
67
|
def foo2; end
|
68
68
|
eof
|
69
|
-
format_block(Registry.at('#foo')).
|
70
|
-
format_block(Registry.at('#foo2')).
|
69
|
+
expect(format_block(Registry.at('#foo'))).to eq "{|a| ... }"
|
70
|
+
expect(format_block(Registry.at('#foo2'))).to eq "{ ... }"
|
71
71
|
end
|
72
72
|
|
73
|
-
it "
|
73
|
+
it "shows block for method with @yield and types" do
|
74
74
|
YARD.parse_string <<-'eof'
|
75
75
|
# @yield [a, b, c] blah
|
76
76
|
# @yieldparam a
|
77
77
|
def foo; end
|
78
78
|
eof
|
79
|
-
format_block(Registry.at('#foo')).
|
79
|
+
expect(format_block(Registry.at('#foo'))).to eq "{|a, b, c| ... }"
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -3,121 +3,123 @@ shared_examples_for "signature" do
|
|
3
3
|
YARD::Registry.clear
|
4
4
|
@options = Templates::TemplateOptions.new
|
5
5
|
@options.reset_defaults
|
6
|
-
|
6
|
+
allow(self).to receive(:options).and_return(@options)
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
def trim(sig) sig.gsub(/\s+/, ' ') end
|
10
|
+
|
11
|
+
it "shows signature for regular instance method" do
|
10
12
|
YARD.parse_string "def foo; end"
|
11
|
-
signature(Registry.at('#foo')).
|
13
|
+
expect(trim(signature(Registry.at('#foo')))).to eq @results[:regular]
|
12
14
|
end
|
13
15
|
|
14
|
-
it "
|
16
|
+
it "allows default return type to be changed" do
|
15
17
|
@options.default_return = "Hello"
|
16
18
|
YARD.parse_string "def foo; end"
|
17
|
-
signature(Registry.at('#foo')).
|
19
|
+
expect(trim(signature(Registry.at('#foo')))).to eq @results[:default_return]
|
18
20
|
end
|
19
21
|
|
20
|
-
it "
|
22
|
+
it "allows default return type to be omitted" do
|
21
23
|
@options.default_return = ""
|
22
24
|
YARD.parse_string "def foo; end"
|
23
|
-
signature(Registry.at('#foo')).
|
25
|
+
expect(trim(signature(Registry.at('#foo')))).to eq @results[:no_default_return]
|
24
26
|
end
|
25
27
|
|
26
|
-
it "
|
28
|
+
it "shows signature for private class method" do
|
27
29
|
YARD.parse_string "class A; private; def self.foo; end end"
|
28
|
-
signature(Registry.at('A.foo')).
|
30
|
+
expect(trim(signature(Registry.at('A.foo')))).to eq @results[:private_class]
|
29
31
|
end
|
30
32
|
|
31
|
-
it "
|
33
|
+
it "shows return type for single type" do
|
32
34
|
YARD.parse_string <<-'eof'
|
33
35
|
# @return [String]
|
34
36
|
def foo; end
|
35
37
|
eof
|
36
|
-
signature(Registry.at('#foo')).
|
38
|
+
expect(trim(signature(Registry.at('#foo')))).to eq @results[:single]
|
37
39
|
end
|
38
40
|
|
39
|
-
it "
|
41
|
+
it "shows return type for 2 types" do
|
40
42
|
YARD.parse_string <<-'eof'
|
41
43
|
# @return [String, Symbol]
|
42
44
|
def foo; end
|
43
45
|
eof
|
44
|
-
signature(Registry.at('#foo')).
|
46
|
+
expect(trim(signature(Registry.at('#foo')))).to eq @results[:two_types]
|
45
47
|
end
|
46
48
|
|
47
|
-
it "
|
49
|
+
it "shows return type for 2 types over multiple tags" do
|
48
50
|
YARD.parse_string <<-'eof'
|
49
51
|
# @return [String]
|
50
52
|
# @return [Symbol]
|
51
53
|
def foo; end
|
52
54
|
eof
|
53
|
-
signature(Registry.at('#foo')).
|
55
|
+
expect(trim(signature(Registry.at('#foo')))).to eq @results[:two_types_multitag]
|
54
56
|
end
|
55
57
|
|
56
|
-
it "
|
58
|
+
it "shows 'Type?' if return types are [Type, nil]" do
|
57
59
|
YARD.parse_string <<-'eof'
|
58
60
|
# @return [Type, nil]
|
59
61
|
def foo; end
|
60
62
|
eof
|
61
|
-
signature(Registry.at('#foo')).
|
63
|
+
expect(trim(signature(Registry.at('#foo')))).to eq @results[:type_nil]
|
62
64
|
end
|
63
65
|
|
64
|
-
it "
|
66
|
+
it "shows 'Type?' if return types are [Type, nil, nil] (extra nil)" do
|
65
67
|
YARD.parse_string <<-'eof'
|
66
68
|
# @return [Type, nil]
|
67
69
|
# @return [nil]
|
68
70
|
def foo; end
|
69
71
|
eof
|
70
|
-
signature(Registry.at('#foo')).
|
72
|
+
expect(trim(signature(Registry.at('#foo')))).to eq @results[:type_nil]
|
71
73
|
end
|
72
74
|
|
73
|
-
it "
|
75
|
+
it "shows 'Type+' if return types are [Type, Array<Type>]" do
|
74
76
|
YARD.parse_string <<-'eof'
|
75
77
|
# @return [Type, <Type>]
|
76
78
|
def foo; end
|
77
79
|
eof
|
78
|
-
signature(Registry.at('#foo')).
|
80
|
+
expect(trim(signature(Registry.at('#foo')))).to eq @results[:type_array]
|
79
81
|
end
|
80
82
|
|
81
|
-
it "
|
83
|
+
it "shows (Type, ...) for more than 2 return types" do
|
82
84
|
YARD.parse_string <<-'eof'
|
83
85
|
# @return [Type, <Type>]
|
84
86
|
# @return [AnotherType]
|
85
87
|
def foo; end
|
86
88
|
eof
|
87
|
-
signature(Registry.at('#foo')).
|
89
|
+
expect(trim(signature(Registry.at('#foo')))).to eq @results[:multitype]
|
88
90
|
end
|
89
91
|
|
90
|
-
it "
|
92
|
+
it "shows (void) for @return [void] by default" do
|
91
93
|
YARD.parse_string <<-'eof'
|
92
94
|
# @return [void]
|
93
95
|
def foo; end
|
94
96
|
eof
|
95
|
-
signature(Registry.at('#foo')).
|
97
|
+
expect(trim(signature(Registry.at('#foo')))).to eq @results[:void]
|
96
98
|
end
|
97
99
|
|
98
|
-
it "
|
100
|
+
it "does not show return for @return [void] if :hide_void_return is true" do
|
99
101
|
@options.hide_void_return = true
|
100
102
|
YARD.parse_string <<-'eof'
|
101
103
|
# @return [void]
|
102
104
|
def foo; end
|
103
105
|
eof
|
104
|
-
signature(Registry.at('#foo')).
|
106
|
+
expect(trim(signature(Registry.at('#foo')))).to eq @results[:hide_void]
|
105
107
|
end
|
106
108
|
|
107
|
-
it "
|
109
|
+
it "shows block for method with yield" do
|
108
110
|
YARD.parse_string <<-'eof'
|
109
111
|
def foo; yield(a, b, c) end
|
110
112
|
eof
|
111
|
-
signature(Registry.at('#foo')).
|
113
|
+
expect(trim(signature(Registry.at('#foo')))).to eq @results[:block]
|
112
114
|
end
|
113
115
|
|
114
|
-
it "
|
116
|
+
it "uses regular return tag if the @overload is empty" do
|
115
117
|
YARD.parse_string <<-'eof'
|
116
118
|
# @overload foobar
|
117
119
|
# Hello world
|
118
120
|
# @return [String]
|
119
121
|
def foo; end
|
120
122
|
eof
|
121
|
-
signature(Registry.at('#foo').tag(:overload)).
|
123
|
+
expect(trim(signature(Registry.at('#foo').tag(:overload)))).to eq @results[:empty_overload]
|
122
124
|
end
|
123
125
|
end
|