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
@@ -1,15 +1,15 @@
|
|
1
1
|
require File.dirname(__FILE__) + '/../spec_helper'
|
2
2
|
|
3
3
|
describe Module do
|
4
|
-
describe
|
5
|
-
it "
|
6
|
-
YARD::CodeObjects::Base.class_name.
|
4
|
+
describe "#class_name" do
|
5
|
+
it "returns just the name of the class/module" do
|
6
|
+
expect(YARD::CodeObjects::Base.class_name).to eq "Base"
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
describe
|
11
|
-
it "
|
12
|
-
YARD::CodeObjects::Base.namespace_name.
|
10
|
+
describe "#namespace" do
|
11
|
+
it "returns everything before the class name" do
|
12
|
+
expect(YARD::CodeObjects::Base.namespace_name).to eq "YARD::CodeObjects"
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
@@ -4,39 +4,39 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
4
4
|
#described_in_docs String, '#underscore'
|
5
5
|
|
6
6
|
describe String do
|
7
|
-
describe
|
8
|
-
it "
|
9
|
-
"a b c".shell_split.
|
7
|
+
describe "#shell_split" do
|
8
|
+
it "splits simple non-quoted text" do
|
9
|
+
expect("a b c".shell_split).to eq %w(a b c)
|
10
10
|
end
|
11
11
|
|
12
|
-
it "
|
13
|
-
'a "b c d" e'.shell_split.
|
12
|
+
it "splits double quoted text into single token" do
|
13
|
+
expect('a "b c d" e'.shell_split).to eq ["a", "b c d", "e"]
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
17
|
-
"a 'b c d' e".shell_split.
|
16
|
+
it "splits single quoted text into single token" do
|
17
|
+
expect("a 'b c d' e".shell_split).to eq ["a", "b c d", "e"]
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
21
|
-
"'a \\' b'".shell_split.
|
20
|
+
it "handles escaped quotations in quotes" do
|
21
|
+
expect("'a \\' b'".shell_split).to eq ["a ' b"]
|
22
22
|
end
|
23
23
|
|
24
|
-
it "
|
25
|
-
"\\'a 'b'".shell_split.
|
24
|
+
it "handles escaped quotations outside quotes" do
|
25
|
+
expect("\\'a 'b'".shell_split).to eq %w('a b)
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
29
|
-
"\\\\'a b c'".shell_split.
|
28
|
+
it "handles escaped backslash" do
|
29
|
+
expect("\\\\'a b c'".shell_split).to eq ['\a b c']
|
30
30
|
end
|
31
31
|
|
32
|
-
it "
|
32
|
+
it "handles any whitespace as space" do
|
33
33
|
text = "foo\tbar\nbaz\r\nfoo2 bar2"
|
34
|
-
text.shell_split.
|
34
|
+
expect(text.shell_split).to eq %w(foo bar baz foo2 bar2)
|
35
35
|
end
|
36
36
|
|
37
|
-
it "
|
37
|
+
it "handles complex input" do
|
38
38
|
text = "hello \\\"world \"1 2\\\" 3\" a 'b \"\\\\\\'' c"
|
39
|
-
text.shell_split.
|
39
|
+
expect(text.shell_split).to eq ["hello", "\"world", "1 2\" 3", "a", "b \"\\'", "c"]
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -1,86 +1,89 @@
|
|
1
1
|
require File.join(File.dirname(__FILE__), '..', 'spec_helper')
|
2
2
|
|
3
3
|
describe SymbolHash do
|
4
|
-
|
5
|
-
it "should allow access to keys as String or Symbol" do
|
4
|
+
it "allows access to keys as String or Symbol" do
|
6
5
|
h = SymbolHash.new(false)
|
7
6
|
h['test'] = true
|
8
|
-
h[:test].
|
9
|
-
h['test'].
|
7
|
+
expect(h[:test]).to be true
|
8
|
+
expect(h['test']).to be true
|
10
9
|
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
describe "#delete" do
|
12
|
+
it "accepts either Strings or Symbols as deletion key" do
|
13
|
+
h = SymbolHash.new
|
14
|
+
expect(h.keys.length).to eq 0
|
15
15
|
|
16
|
-
|
17
|
-
|
16
|
+
h['test'] = true
|
17
|
+
expect(h.keys.length).to eq 1
|
18
18
|
|
19
|
-
|
20
|
-
|
19
|
+
h.delete(:test)
|
20
|
+
expect(h.keys.length).to eq 0
|
21
21
|
|
22
|
-
|
23
|
-
|
22
|
+
h[:test] = true
|
23
|
+
expect(h.keys.length).to eq 1
|
24
24
|
|
25
|
-
|
26
|
-
|
25
|
+
h.delete('test')
|
26
|
+
expect(h.keys.length).to eq 0
|
27
|
+
end
|
27
28
|
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
describe "#has_key?" do
|
31
|
+
it "returns same result for String or Symbol" do
|
32
|
+
h = SymbolHash.new
|
33
|
+
h[:test] = 1
|
34
|
+
expect(h.has_key?(:test)).to be true
|
35
|
+
expect(h.has_key?('test')).to be true
|
36
|
+
end
|
34
37
|
end
|
35
38
|
|
36
|
-
it "
|
39
|
+
it "symbolizes value if it is a String (and only a string)" do
|
37
40
|
class Substring < String; end
|
38
41
|
|
39
42
|
h = SymbolHash.new
|
40
43
|
h['test1'] = "hello"
|
41
44
|
h['test2'] = Substring.new("hello")
|
42
|
-
h['test1'].
|
43
|
-
h['test2'].
|
45
|
+
expect(h['test1']).to eq :hello
|
46
|
+
expect(h['test2']).to eq "hello"
|
44
47
|
end
|
45
48
|
|
46
|
-
it "
|
49
|
+
it "does not symbolize value if SymbolHash.new(false) is created" do
|
47
50
|
h = SymbolHash.new(false)
|
48
51
|
h['test'] = "hello"
|
49
|
-
h[:test].
|
52
|
+
expect(h[:test]).to eq "hello"
|
50
53
|
end
|
51
54
|
|
52
|
-
it "
|
55
|
+
it "does not symbolize value if it is not a String" do
|
53
56
|
h = SymbolHash.new
|
54
57
|
h['test'] = [1,2,3]
|
55
|
-
h['test'].
|
58
|
+
expect(h['test']).to eq [1,2,3]
|
56
59
|
end
|
57
60
|
|
58
|
-
it "
|
61
|
+
it "supports symbolization using #update or #merge!" do
|
59
62
|
h = SymbolHash.new
|
60
63
|
h.update('test' => 'value')
|
61
|
-
h[:test].
|
64
|
+
expect(h[:test]).to eq :value
|
62
65
|
h.merge!('test' => 'value2')
|
63
|
-
h[:test].
|
66
|
+
expect(h[:test]).to eq :value2
|
64
67
|
end
|
65
68
|
|
66
|
-
it "
|
69
|
+
it "supports symbolization non-destructively using #merge" do
|
67
70
|
h = SymbolHash.new
|
68
|
-
h.merge('test' => 'value')[:test].
|
69
|
-
h.
|
71
|
+
expect(h.merge('test' => 'value')[:test]).to eq :value
|
72
|
+
expect(h).to eq SymbolHash.new
|
70
73
|
end
|
71
74
|
|
72
|
-
it "
|
75
|
+
it "supports #initializing of a hash" do
|
73
76
|
h = SymbolHash[:test => 1]
|
74
|
-
h[:test].
|
75
|
-
h[:somethingelse].
|
77
|
+
expect(h[:test]).to eq 1
|
78
|
+
expect(h[:somethingelse]).to be nil
|
76
79
|
end
|
77
80
|
|
78
|
-
it "
|
81
|
+
it "supports reverse merge syntax" do
|
79
82
|
opts = {}
|
80
83
|
opts = SymbolHash[
|
81
84
|
'default' => 1
|
82
85
|
].update(opts)
|
83
|
-
opts.keys.
|
84
|
-
opts[:default].
|
86
|
+
expect(opts.keys).to eq [:default]
|
87
|
+
expect(opts[:default]).to eq 1
|
85
88
|
end
|
86
89
|
end
|
@@ -16,8 +16,8 @@ describe YARD::DocstringParser do
|
|
16
16
|
parse(content, object, handler).to_docstring
|
17
17
|
end
|
18
18
|
|
19
|
-
describe
|
20
|
-
it "
|
19
|
+
describe "#parse" do
|
20
|
+
it "parses comments into tags" do
|
21
21
|
doc = docstring(<<-eof)
|
22
22
|
@param name Hello world
|
23
23
|
how are you?
|
@@ -29,25 +29,25 @@ describe YARD::DocstringParser do
|
|
29
29
|
right here.
|
30
30
|
eof
|
31
31
|
tags = doc.tags(:param)
|
32
|
-
tags[0].name.
|
33
|
-
tags[0].text.
|
34
|
-
tags[1].name.
|
35
|
-
tags[1].text.
|
36
|
-
tags[2].name.
|
37
|
-
tags[2].text.
|
32
|
+
expect(tags[0].name).to eq "name"
|
33
|
+
expect(tags[0].text).to eq "Hello world\nhow are you?"
|
34
|
+
expect(tags[1].name).to eq "name2"
|
35
|
+
expect(tags[1].text).to eq "this is a new line"
|
36
|
+
expect(tags[2].name).to eq "name3"
|
37
|
+
expect(tags[2].text).to eq "and this\nis a new paragraph:\n\nright here."
|
38
38
|
end
|
39
39
|
|
40
|
-
it "
|
40
|
+
it "ends parsing a tag on de-dent" do
|
41
41
|
doc = docstring(<<-eof)
|
42
42
|
@note test
|
43
43
|
one two three
|
44
44
|
rest of docstring
|
45
45
|
eof
|
46
|
-
doc.tag(:note).text.
|
47
|
-
doc.
|
46
|
+
expect(doc.tag(:note).text).to eq "test\none two three"
|
47
|
+
expect(doc).to eq "rest of docstring"
|
48
48
|
end
|
49
49
|
|
50
|
-
it "
|
50
|
+
it "parses examples embedded in doc" do
|
51
51
|
doc = docstring(<<-eof)
|
52
52
|
test string here
|
53
53
|
@example code
|
@@ -59,21 +59,21 @@ test string here
|
|
59
59
|
|
60
60
|
more stuff
|
61
61
|
eof
|
62
|
-
doc.
|
63
|
-
doc.tag(:example).text.
|
62
|
+
expect(doc).to eq "test string here\nmore stuff"
|
63
|
+
expect(doc.tag(:example).text).to eq "\ndef foo(x, y, z)\nend\n\nclass A; end"
|
64
64
|
end
|
65
65
|
|
66
|
-
it "
|
66
|
+
it "removes only original indentation from beginning of line in tags" do
|
67
67
|
doc = docstring(<<-eof)
|
68
68
|
@param name
|
69
69
|
some value
|
70
70
|
foo bar
|
71
71
|
baz
|
72
72
|
eof
|
73
|
-
doc.tag(:param).text.
|
73
|
+
expect(doc.tag(:param).text).to eq "some value\nfoo bar\n baz"
|
74
74
|
end
|
75
75
|
|
76
|
-
it "
|
76
|
+
it "allows numbers in tags" do
|
77
77
|
Tags::Library.define_tag(nil, :foo1)
|
78
78
|
Tags::Library.define_tag(nil, :foo2)
|
79
79
|
Tags::Library.define_tag(nil, :foo3)
|
@@ -82,142 +82,142 @@ eof
|
|
82
82
|
@foo2 bar2
|
83
83
|
@foo3 bar3
|
84
84
|
eof
|
85
|
-
doc.tag(:foo1).text.
|
86
|
-
doc.tag(:foo2).text.
|
85
|
+
expect(doc.tag(:foo1).text).to eq "bar1"
|
86
|
+
expect(doc.tag(:foo2).text).to eq "bar2"
|
87
87
|
end
|
88
88
|
|
89
|
-
it "
|
89
|
+
it "ends tag on newline if next line is not indented" do
|
90
90
|
doc = docstring(<<-eof)
|
91
91
|
@author bar1
|
92
92
|
@api bar2
|
93
93
|
Hello world
|
94
94
|
eof
|
95
|
-
doc.tag(:author).text.
|
96
|
-
doc.tag(:api).text.
|
95
|
+
expect(doc.tag(:author).text).to eq "bar1"
|
96
|
+
expect(doc.tag(:api).text).to eq "bar2"
|
97
97
|
end
|
98
98
|
|
99
|
-
it "
|
100
|
-
log.
|
99
|
+
it "warns about unknown tag" do
|
100
|
+
expect(log).to receive(:warn).with(/Unknown tag @hello$/)
|
101
101
|
docstring("@hello world")
|
102
102
|
end
|
103
103
|
|
104
|
-
it "
|
104
|
+
it "does not add trailing whitespace to freeform tags" do
|
105
105
|
doc = docstring("@api private \t ")
|
106
|
-
doc.tag(:api).text.
|
106
|
+
expect(doc.tag(:api).text).to eq "private"
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
-
describe
|
110
|
+
describe "#parse with custom tag library" do
|
111
111
|
class TestLibrary < Tags::Library; end
|
112
112
|
|
113
113
|
before { @library = TestLibrary.new }
|
114
114
|
|
115
|
-
it "
|
115
|
+
it "accepts valid tags" do
|
116
116
|
valid = %w( testing valid is_a is_A __ )
|
117
117
|
valid.each do |tag|
|
118
118
|
TestLibrary.define_tag("Tag", tag)
|
119
119
|
doc = docstring('@' + tag + ' foo bar')
|
120
|
-
doc.tag(tag).text.
|
120
|
+
expect(doc.tag(tag).text).to eq 'foo bar'
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
-
it "
|
124
|
+
it "does not parse invalid tag names" do
|
125
125
|
invalid = %w( @ @return@ @param, @x-y @.x.y.z )
|
126
126
|
invalid.each do |tag|
|
127
|
-
docstring(tag + ' foo bar').
|
127
|
+
expect(docstring(tag + ' foo bar')).to eq tag + ' foo bar'
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
-
it "
|
131
|
+
it "allows namespaced tags in the form @x.y.z" do
|
132
132
|
TestLibrary.define_tag("Tag", 'x.y.z')
|
133
133
|
doc = docstring("@x.y.z foo bar")
|
134
|
-
doc.tag('x.y.z').text.
|
134
|
+
expect(doc.tag('x.y.z').text).to eq 'foo bar'
|
135
135
|
end
|
136
136
|
|
137
|
-
it "
|
137
|
+
it "ignores new directives without @! prefix syntax" do
|
138
138
|
TestLibrary.define_directive('dir1', Tags::ScopeDirective)
|
139
|
-
log.
|
139
|
+
expect(log).to receive(:warn).with(/@dir1/)
|
140
140
|
docstring("@dir1")
|
141
141
|
end
|
142
142
|
|
143
143
|
%w(attribute endgroup group macro method scope visibility).each do |tag|
|
144
|
-
it "
|
144
|
+
it "handles non prefixed @#{tag} syntax as directive, not tag" do
|
145
145
|
TestLibrary.define_directive(tag, Tags::ScopeDirective)
|
146
146
|
parse("@#{tag}")
|
147
|
-
@parser.directives.first.
|
147
|
+
expect(@parser.directives.first).to be_a(Tags::ScopeDirective)
|
148
148
|
end
|
149
149
|
end
|
150
150
|
|
151
|
-
it "
|
151
|
+
it "handles directives with @! prefix syntax" do
|
152
152
|
TestLibrary.define_directive('dir1', Tags::ScopeDirective)
|
153
153
|
docstring("@!dir1 class")
|
154
|
-
@parser.state.scope.
|
154
|
+
expect(@parser.state.scope).to eq :class
|
155
155
|
end
|
156
156
|
end
|
157
157
|
|
158
|
-
describe
|
159
|
-
it "
|
158
|
+
describe "#text" do
|
159
|
+
it "only returns text data" do
|
160
160
|
parse("Foo\n@param foo x y z\nBar")
|
161
|
-
@parser.text.
|
161
|
+
expect(@parser.text).to eq "Foo\nBar"
|
162
162
|
end
|
163
163
|
end
|
164
164
|
|
165
|
-
describe
|
166
|
-
it "
|
165
|
+
describe "#raw_text" do
|
166
|
+
it "returns the entire original data" do
|
167
167
|
data = "Foo\n@param foo x y z\nBar"
|
168
168
|
parse(data)
|
169
|
-
@parser.raw_text.
|
169
|
+
expect(@parser.raw_text).to eq data
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
173
|
-
describe
|
174
|
-
it "
|
173
|
+
describe "#tags" do
|
174
|
+
it "returns the parsed tags" do
|
175
175
|
data = "Foo\n@param foo x y z\nBar"
|
176
176
|
parse(data)
|
177
|
-
@parser.tags.size.
|
178
|
-
@parser.tags.first.tag_name.
|
177
|
+
expect(@parser.tags.size).to eq 1
|
178
|
+
expect(@parser.tags.first.tag_name).to eq 'param'
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
182
|
-
describe
|
183
|
-
it "
|
182
|
+
describe "#directives" do
|
183
|
+
it "groups all processed directives" do
|
184
184
|
data = "Foo\n@!scope class\n@!visibility private\nBar"
|
185
185
|
parse(data)
|
186
186
|
dirs = @parser.directives
|
187
187
|
dirs.size == 2
|
188
|
-
dirs[0].
|
189
|
-
dirs[0].tag.text.
|
190
|
-
dirs[1].
|
191
|
-
dirs[1].tag.text.
|
188
|
+
expect(dirs[0]).to be_a(Tags::ScopeDirective)
|
189
|
+
expect(dirs[0].tag.text).to eq 'class'
|
190
|
+
expect(dirs[1]).to be_a(Tags::VisibilityDirective)
|
191
|
+
expect(dirs[1].tag.text).to eq 'private'
|
192
192
|
end
|
193
193
|
end
|
194
194
|
|
195
|
-
describe
|
196
|
-
it "
|
195
|
+
describe "#state" do
|
196
|
+
it "handles modified state" do
|
197
197
|
parse("@!scope class")
|
198
|
-
@parser.state.scope.
|
198
|
+
expect(@parser.state.scope).to eq :class
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
202
|
-
describe
|
203
|
-
it "
|
202
|
+
describe "after_parse" do
|
203
|
+
it "allows specifying of callbacks" do
|
204
204
|
parser = DocstringParser.new
|
205
205
|
the_yielded_obj = nil
|
206
206
|
DocstringParser.after_parse {|obj| the_yielded_obj = obj }
|
207
207
|
parser.parse("Some text")
|
208
|
-
the_yielded_obj.
|
208
|
+
expect(the_yielded_obj).to eq parser
|
209
209
|
end
|
210
210
|
|
211
|
-
it "
|
212
|
-
log.
|
211
|
+
it "warns about invalid named parameters" do
|
212
|
+
expect(log).to receive(:warn).with(/@param tag has unknown parameter name: notaparam/)
|
213
213
|
YARD.parse_string <<-eof
|
214
214
|
# @param notaparam foo
|
215
215
|
def foo(a) end
|
216
216
|
eof
|
217
217
|
end
|
218
218
|
|
219
|
-
it "
|
220
|
-
log.
|
219
|
+
it "warns about duplicate named parameters" do
|
220
|
+
expect(log).to receive(:warn).with(/@param tag has duplicate parameter name: a/)
|
221
221
|
YARD.parse_string <<-eof
|
222
222
|
# @param a foo
|
223
223
|
# @param a foo
|