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/tags/library_spec.rb
CHANGED
@@ -5,30 +5,30 @@ describe YARD::Tags::Library do
|
|
5
5
|
Docstring.new(docstring).tags.first
|
6
6
|
end
|
7
7
|
|
8
|
-
describe
|
9
|
-
it "
|
10
|
-
tag("@see http://example.com").name.
|
8
|
+
describe "#see_tag" do
|
9
|
+
it "takes a URL" do
|
10
|
+
expect(tag("@see http://example.com").name).to eq "http://example.com"
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
14
|
-
tag("@see String#reverse").name.
|
13
|
+
it "takes an object path" do
|
14
|
+
expect(tag("@see String#reverse").name).to eq "String#reverse"
|
15
15
|
end
|
16
16
|
|
17
|
-
it "
|
17
|
+
it "takes a description after the url/object" do
|
18
18
|
tag = tag("@see http://example.com An Example Site")
|
19
|
-
tag.name.
|
20
|
-
tag.text.
|
19
|
+
expect(tag.name).to eq "http://example.com"
|
20
|
+
expect(tag.text).to eq "An Example Site"
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
describe
|
25
|
-
it "
|
24
|
+
describe ".define_tag" do
|
25
|
+
it "allows defining tags with '.' in the name (x.y.z defines method x_y_z)" do
|
26
26
|
Tags::Library.define_tag("foo", 'x.y.z')
|
27
27
|
Tags::Library.define_tag("foo2", 'x.y.zz', Tags::OverloadTag)
|
28
|
-
Tags::Library.instance.method(:x_y_z_tag).
|
29
|
-
Tags::Library.instance.method(:x_y_zz_tag).
|
30
|
-
tag('@x.y.z foo bar').text.
|
31
|
-
tag('@x.y.zz foo(bar)').signature.
|
28
|
+
expect(Tags::Library.instance.method(:x_y_z_tag)).not_to be nil
|
29
|
+
expect(Tags::Library.instance.method(:x_y_zz_tag)).not_to be nil
|
30
|
+
expect(tag('@x.y.z foo bar').text).to eq 'foo bar'
|
31
|
+
expect(tag('@x.y.zz foo(bar)').signature).to eq 'foo(bar)'
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -10,44 +10,44 @@ describe YARD::Tags::OverloadTag do
|
|
10
10
|
eof
|
11
11
|
end
|
12
12
|
|
13
|
-
it "
|
14
|
-
@tag.signature.
|
15
|
-
@tag.parameters.
|
13
|
+
it "parses the first line as a method signature" do
|
14
|
+
expect(@tag.signature).to eq "def bar(a, b = 1, &block)"
|
15
|
+
expect(@tag.parameters).to eq [['a', nil], ['b', "1"], ['&block', nil]]
|
16
16
|
end
|
17
17
|
|
18
|
-
it "
|
19
|
-
@tag.docstring.
|
20
|
-
@tag.docstring.
|
18
|
+
it "parses the rest of the text as a new Docstring" do
|
19
|
+
expect(@tag.docstring).to be_instance_of(Docstring)
|
20
|
+
expect(@tag.docstring).to eq "Hello world"
|
21
21
|
end
|
22
22
|
|
23
|
-
it "
|
24
|
-
m =
|
23
|
+
it "sets Docstring's object after #object= is called" do
|
24
|
+
m = double(:object)
|
25
25
|
@tag.object = m
|
26
|
-
@tag.docstring.object.
|
26
|
+
expect(@tag.docstring.object).to eq m
|
27
27
|
end
|
28
28
|
|
29
|
-
it "
|
30
|
-
@tag.object =
|
31
|
-
@tag.tags.size.
|
32
|
-
@tag.tag(:param).name.
|
33
|
-
@tag.has_tag?(:return).
|
29
|
+
it "responds to #tag, #tags and #has_tag?" do
|
30
|
+
@tag.object = double(:object)
|
31
|
+
expect(@tag.tags.size).to eq 2
|
32
|
+
expect(@tag.tag(:param).name).to eq "a"
|
33
|
+
expect(@tag.has_tag?(:return)).to be true
|
34
34
|
end
|
35
35
|
|
36
|
-
it "
|
36
|
+
it "is not a CodeObjects::Base when not hooked up to an object" do
|
37
37
|
@tag.object = nil
|
38
|
-
@tag.is_a?(CodeObjects::Base).
|
38
|
+
expect(@tag.is_a?(CodeObjects::Base)).to be false
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
42
|
-
@tag.object =
|
43
|
-
@tag.object.
|
44
|
-
@tag.is_a?(CodeObjects::Base).
|
45
|
-
@tag.kind_of?(CodeObjects::Base).
|
46
|
-
(CodeObjects::Base === @tag).
|
41
|
+
it "is a CodeObjects::Base when hooked up to an object" do
|
42
|
+
@tag.object = double(:object)
|
43
|
+
expect(@tag.object).to receive(:is_a?).at_least(3).times.with(CodeObjects::Base).and_return(true)
|
44
|
+
expect(@tag.is_a?(CodeObjects::Base)).to be true
|
45
|
+
expect(@tag.kind_of?(CodeObjects::Base)).to be true
|
46
|
+
expect(CodeObjects::Base === @tag).to be true
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
49
|
+
it "does not parse 'def' out of method name" do
|
50
50
|
tag = Tags::OverloadTag.new(:overload, "default")
|
51
|
-
tag.signature.
|
51
|
+
expect(tag.signature).to eq "default"
|
52
52
|
end
|
53
53
|
end
|
@@ -3,27 +3,27 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
3
3
|
describe YARD::Tags::RefTagList do
|
4
4
|
before { YARD::Registry.clear }
|
5
5
|
|
6
|
-
it "
|
6
|
+
it "accepts symbol or string as owner's path and convert it into a proxy" do
|
7
7
|
t = Tags::RefTagList.new('author', :String)
|
8
|
-
t.owner.
|
8
|
+
expect(t.owner).to eq P(:String)
|
9
9
|
end
|
10
10
|
|
11
|
-
it "
|
11
|
+
it "accepts proxy object as owner" do
|
12
12
|
t = Tags::RefTagList.new('author', P(:String))
|
13
|
-
t.owner.
|
13
|
+
expect(t.owner).to eq P(:String)
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
16
|
+
it "returns tags from a proxy object" do
|
17
17
|
o = CodeObjects::ClassObject.new(:root, :String)
|
18
18
|
t = Tags::Tag.new(:author, 'foo')
|
19
19
|
o.docstring.add_tag(t)
|
20
20
|
|
21
21
|
ref = Tags::RefTagList.new('author', :String)
|
22
|
-
ref.tags.
|
23
|
-
ref.tags.first.text.
|
22
|
+
expect(ref.tags).to eq [t]
|
23
|
+
expect(ref.tags.first.text).to eq 'foo'
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
26
|
+
it "returns named tags from a proxy object" do
|
27
27
|
o = CodeObjects::ClassObject.new(:root, :String)
|
28
28
|
p1 = Tags::Tag.new(:param, 'bar1', nil, 'foo')
|
29
29
|
p2 = Tags::Tag.new(:param, 'bar2', nil, 'foo')
|
@@ -32,8 +32,8 @@ describe YARD::Tags::RefTagList do
|
|
32
32
|
o.docstring.add_tag(p1, t1, p2, p3)
|
33
33
|
|
34
34
|
ref = Tags::RefTagList.new('param', :String, 'foo')
|
35
|
-
ref.tags.
|
36
|
-
ref.tags.first.text.
|
35
|
+
expect(ref.tags).to eq [p1, p2]
|
36
|
+
expect(ref.tags.first.text).to eq 'bar1'
|
37
37
|
end
|
38
38
|
|
39
39
|
it "all tags should respond to #owner and be a RefTag" do
|
@@ -46,8 +46,8 @@ describe YARD::Tags::RefTagList do
|
|
46
46
|
|
47
47
|
ref = Tags::RefTagList.new('param', :String)
|
48
48
|
ref.tags.each do |t|
|
49
|
-
t.
|
50
|
-
t.owner.
|
49
|
+
expect(t).to be_kind_of(Tags::RefTag)
|
50
|
+
expect(t.owner).to eq o
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -30,15 +30,15 @@ describe YARD::Templates::Engine.template(:default, :docstring) do
|
|
30
30
|
eof
|
31
31
|
end
|
32
32
|
|
33
|
-
it "
|
33
|
+
it "renders html format correctly" do
|
34
34
|
html_equals(Registry.at('A').format(html_options), :class001)
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
37
|
+
it "renders text format correctly" do
|
38
38
|
text_equals(Registry.at('A').format, :class001)
|
39
39
|
end
|
40
40
|
|
41
|
-
it "
|
41
|
+
it "hides private constructors" do
|
42
42
|
html_equals(Registry.at('D').format(html_options(:verifier => Verifier.new("!@private"))), :class002)
|
43
43
|
end
|
44
44
|
end
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require File.dirname(__FILE__) + "/spec_helper"
|
2
2
|
|
3
3
|
describe YARD::Templates::Engine.template(:default, :constant) do
|
4
|
-
describe
|
5
|
-
it "
|
4
|
+
describe "fully dressed constant" do
|
5
|
+
it "renders text format correctly" do
|
6
6
|
YARD.parse_string <<-'eof'
|
7
7
|
class YARD::CLI::YRI
|
8
8
|
# Default search paths that should be loaded dynamically into YRI. These paths
|
@@ -20,8 +20,8 @@ describe YARD::Templates::Engine.template(:default, :constant) do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
it "
|
23
|
+
describe "simple constant with no documentation" do
|
24
|
+
it "renders text format correctly" do
|
25
25
|
# Short constant should show on single line
|
26
26
|
YARD.parse_string <<-'eof'
|
27
27
|
MYCONST = 'foo'
|
@@ -1,84 +1,84 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/spec_helper'
|
2
2
|
|
3
3
|
describe YARD::Templates::Engine do
|
4
|
-
describe
|
5
|
-
it "
|
4
|
+
describe ".register_template_path" do
|
5
|
+
it "registers a String path" do
|
6
6
|
Engine.register_template_path('.')
|
7
|
-
Engine.template_paths.pop.
|
7
|
+
expect(Engine.template_paths.pop).to eq '.'
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
describe
|
12
|
-
it "
|
11
|
+
describe ".template!" do
|
12
|
+
it "creates a module including Template" do
|
13
13
|
mod = Engine.template!('path/to/template')
|
14
|
-
mod.
|
15
|
-
mod.full_path.to_s.
|
14
|
+
expect(mod).to include(Template)
|
15
|
+
expect(mod.full_path.to_s).to eq 'path/to/template'
|
16
16
|
end
|
17
17
|
|
18
|
-
it "
|
18
|
+
it "creates a module including Template with full_path" do
|
19
19
|
mod = Engine.template!('path/to/template2', '/full/path/to/template2')
|
20
|
-
mod.
|
21
|
-
mod.full_path.to_s.
|
20
|
+
expect(mod).to include(Template)
|
21
|
+
expect(mod.full_path.to_s).to eq '/full/path/to/template2'
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
describe
|
26
|
-
it "
|
27
|
-
|
25
|
+
describe ".template" do
|
26
|
+
it "raises an error if the template is not found" do
|
27
|
+
expect { Engine.template(:a, :b, :c) }.to raise_error(ArgumentError)
|
28
28
|
end
|
29
29
|
|
30
|
-
it "
|
31
|
-
mock =
|
32
|
-
Engine.
|
33
|
-
Engine.
|
34
|
-
Engine.template('template/name').
|
30
|
+
it "creates a module including Template" do
|
31
|
+
mock = double(:template)
|
32
|
+
expect(Engine).to receive(:find_template_paths).with(nil, 'template/name').and_return(['/full/path/template/name'])
|
33
|
+
expect(Engine).to receive(:template!).with('template/name', ['/full/path/template/name']).and_return(mock)
|
34
|
+
expect(Engine.template('template/name')).to eq mock
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
38
|
-
Engine.
|
39
|
-
File.
|
40
|
-
start_template =
|
41
|
-
|
42
|
-
|
43
|
-
start_template.
|
37
|
+
it "creates a Template from a relative Template path" do
|
38
|
+
expect(Engine).to receive(:template_paths).and_return([])
|
39
|
+
expect(File).to receive(:directory?).with("/full/path/template/notname").and_return(true)
|
40
|
+
start_template = double(:start_template,
|
41
|
+
:full_path => '/full/path/template/name',
|
42
|
+
:full_paths => ['/full/path/template/name'])
|
43
|
+
expect(start_template).to receive(:is_a?).with(Template).and_return(true)
|
44
44
|
mod = Engine.template(start_template, '..', 'notname')
|
45
|
-
mod.
|
46
|
-
mod.full_path.to_s.
|
45
|
+
expect(mod).to include(Template)
|
46
|
+
expect(mod.full_path.to_s).to eq "/full/path/template/notname"
|
47
47
|
end
|
48
48
|
|
49
|
-
it "
|
49
|
+
it "creates a Template including other matching templates in path" do
|
50
50
|
paths = ['/full/path/template/name', '/full/path2/template/name']
|
51
|
-
Engine.
|
52
|
-
Engine.
|
51
|
+
expect(Engine).to receive(:find_template_paths).with(nil, 'template').at_least(1).times.and_return([])
|
52
|
+
expect(Engine).to receive(:find_template_paths).with(nil, 'template/name').and_return(paths)
|
53
53
|
ancestors = Engine.template('template/name').ancestors.map {|m| m.class_name }
|
54
|
-
ancestors.
|
54
|
+
expect(ancestors).to include("Template__full_path2_template_name")
|
55
55
|
end
|
56
56
|
|
57
|
-
it "
|
57
|
+
it "includes parent directories before other template paths" do
|
58
58
|
paths = ['/full/path/template/name', '/full/path2/template/name']
|
59
|
-
Engine.
|
59
|
+
expect(Engine).to receive(:find_template_paths).with(nil, 'template/name').and_return(paths)
|
60
60
|
ancestors = Engine.template('template/name').ancestors.map {|m| m.class_name }
|
61
|
-
ancestors[0, 4].
|
61
|
+
expect(ancestors[0, 4]).to eq ["Template__full_path_template_name", "Template__full_path_template",
|
62
62
|
"Template__full_path2_template_name", "Template__full_path2_template"]
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
describe
|
67
|
-
it "
|
68
|
-
mod =
|
66
|
+
describe ".generate" do
|
67
|
+
it "generates with fulldoc template" do
|
68
|
+
mod = double(:template)
|
69
69
|
options = TemplateOptions.new
|
70
70
|
options.reset_defaults
|
71
71
|
options.objects = [:a, :b, :c]
|
72
72
|
options.object = Registry.root
|
73
|
-
mod.
|
74
|
-
Engine.
|
73
|
+
expect(mod).to receive(:run).with(options)
|
74
|
+
expect(Engine).to receive(:template).with(:default, :fulldoc, :text).and_return(mod)
|
75
75
|
Engine.generate([:a, :b, :c])
|
76
76
|
end
|
77
77
|
end
|
78
78
|
|
79
|
-
describe
|
79
|
+
describe ".render" do
|
80
80
|
def loads_template(*args)
|
81
|
-
Engine.
|
81
|
+
expect(Engine).to receive(:template).with(*args).and_return(@template)
|
82
82
|
end
|
83
83
|
|
84
84
|
before(:all) do
|
@@ -90,29 +90,28 @@ describe YARD::Templates::Engine do
|
|
90
90
|
@options.reset_defaults
|
91
91
|
@options.object = @object
|
92
92
|
@options.type = @object.type
|
93
|
-
@template =
|
94
|
-
@template.
|
95
|
-
@template.should_receive(:run).with(@options)
|
93
|
+
@template = double(:template, :include => nil)
|
94
|
+
expect(@template).to receive(:run).with(@options)
|
96
95
|
end
|
97
96
|
|
98
|
-
it "
|
97
|
+
it "accepts method call with no parameters" do
|
99
98
|
loads_template(:default, :method, :text)
|
100
99
|
@object.format
|
101
100
|
end
|
102
101
|
|
103
|
-
it "
|
102
|
+
it "allows template key to be changed" do
|
104
103
|
loads_template(:javadoc, :method, :text)
|
105
104
|
@options.template = :javadoc
|
106
105
|
@object.format(:template => :javadoc)
|
107
106
|
end
|
108
107
|
|
109
|
-
it "
|
108
|
+
it "allows type key to be changed" do
|
110
109
|
loads_template(:default, :fulldoc, :text)
|
111
110
|
@options.type = :fulldoc
|
112
111
|
@object.format(:type => :fulldoc)
|
113
112
|
end
|
114
113
|
|
115
|
-
it "
|
114
|
+
it "allows format key to be changed" do
|
116
115
|
loads_template(:default, :method, :html)
|
117
116
|
@options.format = :html
|
118
117
|
@object.format(:format => :html)
|
@@ -1,38 +1,44 @@
|
|
1
1
|
<h1>Class: A
|
2
2
|
<span class="abstract note title">Abstract</span>
|
3
|
-
|
3
|
+
|
4
|
+
|
4
5
|
</h1>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
<dt
|
9
|
-
<dd
|
6
|
+
<div class="box_info">
|
7
|
+
|
8
|
+
<dl>
|
9
|
+
<dt>Inherits:</dt>
|
10
|
+
<dd>
|
10
11
|
<span class="inheritName">B</span>
|
11
|
-
|
12
|
+
|
12
13
|
<ul class="fullTree">
|
13
14
|
<li>Object</li>
|
14
|
-
|
15
|
+
|
15
16
|
<li class="next">B</li>
|
16
|
-
|
17
|
+
|
17
18
|
<li class="next">A</li>
|
18
|
-
|
19
|
+
|
19
20
|
</ul>
|
20
21
|
<a href="#" class="inheritanceTree">show all</a>
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
<
|
22
|
+
|
23
|
+
</dd>
|
24
|
+
</dl>
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
|
36
|
+
<dl>
|
37
|
+
<dt>Defined in:</dt>
|
38
|
+
<dd>(stdin)</dd>
|
39
|
+
</dl>
|
40
|
+
|
41
|
+
</div>
|
36
42
|
|
37
43
|
<h2>Overview</h2><div class="docstring">
|
38
44
|
<div class="discussion">
|
@@ -45,42 +51,43 @@ Comments
|
|
45
51
|
</div>
|
46
52
|
</div>
|
47
53
|
<div class="tags">
|
54
|
+
|
48
55
|
|
49
56
|
<p class="tag_title">See Also:</p>
|
50
57
|
<ul class="see">
|
51
|
-
|
58
|
+
|
52
59
|
<li>A</li>
|
53
|
-
|
60
|
+
|
54
61
|
<li><a href="http://example.com" target="_parent" title="Example">Example</a></li>
|
55
|
-
|
62
|
+
|
56
63
|
</ul>
|
57
64
|
<p class="tag_title">Author:</p>
|
58
65
|
<ul class="author">
|
59
|
-
|
66
|
+
|
60
67
|
<li>
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
|
72
|
+
|
66
73
|
<div class='inline'>Test</div>
|
67
|
-
|
74
|
+
|
68
75
|
</li>
|
69
|
-
|
76
|
+
|
70
77
|
</ul>
|
71
78
|
<p class="tag_title">Version:</p>
|
72
79
|
<ul class="version">
|
73
|
-
|
80
|
+
|
74
81
|
<li>
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
82
|
+
|
83
|
+
|
84
|
+
|
85
|
+
|
86
|
+
|
80
87
|
<div class='inline'>1.0</div>
|
81
|
-
|
88
|
+
|
82
89
|
</li>
|
83
|
-
|
90
|
+
|
84
91
|
</ul>
|
85
92
|
|
86
93
|
</div><div id="subclasses">
|
@@ -92,86 +99,100 @@ Comments
|
|
92
99
|
|
93
100
|
|
94
101
|
|
95
|
-
<h2>Instance Method Summary <small>(<a href="#" class="summary_toggle">collapse</a>)</small></h2>
|
96
102
|
|
97
|
-
<ul class="summary">
|
98
103
|
|
104
|
+
|
105
|
+
<h2>
|
106
|
+
Instance Method Summary
|
107
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
108
|
+
</h2>
|
109
|
+
|
110
|
+
<ul class="summary">
|
111
|
+
|
99
112
|
<li class="public deprecated">
|
100
113
|
<span class="summary_signature">
|
114
|
+
|
115
|
+
<a title="#a (instance method)">#<strong>a</strong> </a>
|
116
|
+
|
101
117
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
118
|
+
|
106
119
|
</span>
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
111
125
|
<span class="deprecated note title">deprecated</span>
|
126
|
+
|
112
127
|
|
113
|
-
|
128
|
+
|
114
129
|
<span class="summary_desc"><strong>Deprecated.</strong> <div class='inline'></div></span>
|
115
|
-
|
130
|
+
|
116
131
|
</li>
|
117
132
|
|
118
|
-
|
133
|
+
|
119
134
|
<li class="public ">
|
120
135
|
<span class="summary_signature">
|
136
|
+
|
137
|
+
<a title="#initialize (instance method)">#<strong>initialize</strong>(test) ⇒ A </a>
|
138
|
+
|
121
139
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
140
|
+
|
126
141
|
</span>
|
127
|
-
|
142
|
+
|
143
|
+
|
128
144
|
<span class="note title constructor">constructor</span>
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
136
153
|
<span class="summary_desc"><div class='inline'>constructor method!.</div></span>
|
137
|
-
|
154
|
+
|
138
155
|
</li>
|
139
156
|
|
140
|
-
|
157
|
+
|
141
158
|
<li class="public ">
|
142
159
|
<span class="summary_signature">
|
160
|
+
|
161
|
+
<a title="#method_missing (instance method)">#<strong>method_missing</strong>(*args) </a>
|
162
|
+
|
143
163
|
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
164
|
+
|
148
165
|
</span>
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
166
|
+
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
|
171
|
+
|
172
|
+
|
173
|
+
|
174
|
+
|
156
175
|
<span class="summary_desc"><div class='inline'>HI.</div></span>
|
157
|
-
|
176
|
+
|
158
177
|
</li>
|
159
178
|
|
160
|
-
|
179
|
+
|
161
180
|
</ul>
|
162
|
-
|
181
|
+
|
163
182
|
|
164
183
|
|
165
184
|
<div id="constructor_details" class="method_details_list">
|
166
185
|
<h2>Constructor Details</h2>
|
167
|
-
|
186
|
+
|
168
187
|
<div class="method_details first">
|
169
188
|
<h3 class="signature first" id="initialize-instance_method">
|
189
|
+
|
190
|
+
#<strong>initialize</strong>(test) ⇒ <tt>A</tt>
|
191
|
+
|
170
192
|
|
171
|
-
|
172
|
-
|
173
|
-
|
193
|
+
|
174
194
|
|
195
|
+
|
175
196
|
</h3><div class="docstring">
|
176
197
|
<div class="discussion">
|
177
198
|
constructor method!
|
@@ -179,6 +200,7 @@ Comments
|
|
179
200
|
</div>
|
180
201
|
</div>
|
181
202
|
<div class="tags">
|
203
|
+
|
182
204
|
|
183
205
|
</div><table class="source_code">
|
184
206
|
<tr>
|
@@ -196,22 +218,24 @@ def initialize(test) end</pre>
|
|
196
218
|
</tr>
|
197
219
|
</table>
|
198
220
|
</div>
|
199
|
-
|
221
|
+
|
200
222
|
</div>
|
201
223
|
<div id="method_missing_details" class="method_details_list">
|
202
224
|
<h2>Dynamic Method Handling</h2>
|
203
225
|
<p class="notice this">
|
204
226
|
This class handles dynamic methods through the <tt>method_missing</tt> method
|
205
|
-
|
227
|
+
|
206
228
|
</p>
|
207
|
-
|
229
|
+
|
208
230
|
<div class="method_details first">
|
209
231
|
<h3 class="signature first" id="method_missing-instance_method">
|
232
|
+
|
233
|
+
#<strong>method_missing</strong>(*args)
|
234
|
+
|
210
235
|
|
211
|
-
|
212
|
-
|
213
|
-
|
236
|
+
|
214
237
|
|
238
|
+
|
215
239
|
</h3><div class="docstring">
|
216
240
|
<div class="discussion">
|
217
241
|
HI
|
@@ -219,6 +243,7 @@ def initialize(test) end</pre>
|
|
219
243
|
</div>
|
220
244
|
</div>
|
221
245
|
<div class="tags">
|
246
|
+
|
222
247
|
|
223
248
|
</div><table class="source_code">
|
224
249
|
<tr>
|
@@ -236,21 +261,23 @@ def method_missing(*args) end</pre>
|
|
236
261
|
</tr>
|
237
262
|
</table>
|
238
263
|
</div>
|
239
|
-
|
264
|
+
|
240
265
|
</div>
|
241
266
|
|
242
267
|
|
243
268
|
<div id="instance_method_details" class="method_details_list">
|
244
269
|
<h2>Instance Method Details</h2>
|
245
270
|
|
246
|
-
|
271
|
+
|
247
272
|
<div class="method_details first">
|
248
273
|
<h3 class="signature first" id="a-instance_method">
|
274
|
+
|
275
|
+
#<strong>a</strong>
|
276
|
+
|
249
277
|
|
250
|
-
|
251
|
-
|
252
|
-
|
278
|
+
|
253
279
|
|
280
|
+
|
254
281
|
</h3><div class="docstring">
|
255
282
|
<div class="discussion">
|
256
283
|
<div class="note deprecated"><strong>Deprecated.</strong> <div class='inline'></div></div>
|
@@ -259,6 +286,7 @@ def method_missing(*args) end</pre>
|
|
259
286
|
</div>
|
260
287
|
</div>
|
261
288
|
<div class="tags">
|
289
|
+
|
262
290
|
|
263
291
|
</div><table class="source_code">
|
264
292
|
<tr>
|
@@ -276,5 +304,5 @@ def a; end</pre>
|
|
276
304
|
</tr>
|
277
305
|
</table>
|
278
306
|
</div>
|
279
|
-
|
307
|
+
|
280
308
|
</div>
|