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/i18n/locale_spec.rb
CHANGED
@@ -10,15 +10,15 @@ describe YARD::I18n::Locale do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "#name" do
|
13
|
-
it "
|
14
|
-
locale("fr").name.
|
13
|
+
it "returns name" do
|
14
|
+
expect(locale("fr").name).to eq "fr"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "#load" do
|
19
|
-
it "
|
20
|
-
File.
|
21
|
-
@locale.load('foo').
|
19
|
+
it "returns false for nonexistent PO" do
|
20
|
+
expect(File).to receive(:exist?).with('foo/fr.po').and_return(false)
|
21
|
+
expect(@locale.load('foo')).to be false
|
22
22
|
end
|
23
23
|
|
24
24
|
have_gettext_gem = true
|
@@ -40,7 +40,7 @@ describe YARD::I18n::Locale do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
43
|
+
it "returns true for existent PO", :if => have_gettext_gem do
|
44
44
|
data = <<-eop
|
45
45
|
msgid ""
|
46
46
|
msgstr ""
|
@@ -53,14 +53,14 @@ msgid "Hello"
|
|
53
53
|
msgstr "Bonjour"
|
54
54
|
eop
|
55
55
|
parser = GetText::POParser.new
|
56
|
-
File.
|
57
|
-
GetText::POParser.
|
58
|
-
parser.
|
59
|
-
file.
|
56
|
+
expect(File).to receive(:exist?).with('foo/fr.po').and_return(true)
|
57
|
+
expect(GetText::POParser).to receive(:new).and_return(parser)
|
58
|
+
expect(parser).to receive(:parse_file) do |file, hash|
|
59
|
+
expect(file).to eq 'foo/fr.po'
|
60
60
|
parser.parse(data, hash)
|
61
61
|
end
|
62
|
-
@locale.load('foo').
|
63
|
-
@locale.translate('Hello').
|
62
|
+
expect(@locale.load('foo')).to be true
|
63
|
+
expect(@locale.translate('Hello')).to eq "Bonjour"
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -70,12 +70,12 @@ eop
|
|
70
70
|
messages["Hello"] = "Bonjour"
|
71
71
|
end
|
72
72
|
|
73
|
-
it "
|
74
|
-
@locale.translate("Hello") == "Bonjour"
|
73
|
+
it "returns translated string for existent string" do
|
74
|
+
expect(@locale.translate("Hello")) == "Bonjour"
|
75
75
|
end
|
76
76
|
|
77
|
-
it "
|
78
|
-
@locale.translate("nonexistent") == "nonexistent"
|
77
|
+
it "returns original string for nonexistent string" do
|
78
|
+
expect(@locale.translate("nonexistent")) == "nonexistent"
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
data/spec/i18n/message_spec.rb
CHANGED
@@ -10,29 +10,29 @@ describe YARD::I18n::Message do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
describe "#id" do
|
13
|
-
it "
|
14
|
-
message("Hello World!").id.
|
13
|
+
it "returns ID" do
|
14
|
+
expect(message("Hello World!").id).to eq "Hello World!"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
18
|
describe "#add_location" do
|
19
|
-
it "
|
19
|
+
it "adds some locations" do
|
20
20
|
@message.add_location("hello.rb", 10)
|
21
21
|
@message.add_location("message.rb", 5)
|
22
|
-
@message.locations.
|
22
|
+
expect(@message.locations).to eq Set.new([["hello.rb", 10], ["message.rb", 5]])
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "#add_comment" do
|
27
|
-
it "
|
27
|
+
it "adds some comments" do
|
28
28
|
@message.add_comment("YARD.title")
|
29
29
|
@message.add_comment("Hello#message")
|
30
|
-
@message.comments.
|
30
|
+
expect(@message.comments).to eq Set.new(["YARD.title", "Hello#message"])
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "#==" do
|
35
|
-
it "
|
35
|
+
it "returns true for same value messages" do
|
36
36
|
locations = [["hello.rb", 10], ["message.rb", 5]]
|
37
37
|
comments = ["YARD.title", "Hello#message"]
|
38
38
|
|
@@ -46,7 +46,7 @@ describe YARD::I18n::Message do
|
|
46
46
|
other_message.add_comment(comment)
|
47
47
|
end
|
48
48
|
|
49
|
-
@message.
|
49
|
+
expect(@message).to eq other_message
|
50
50
|
end
|
51
51
|
end
|
52
52
|
end
|
data/spec/i18n/messages_spec.rb
CHANGED
@@ -14,7 +14,7 @@ describe YARD::I18n::Messages do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "#each" do
|
17
|
-
it "
|
17
|
+
it "enumerates messages" do
|
18
18
|
@messages.register("Hello World!")
|
19
19
|
@messages.register("Title")
|
20
20
|
enumerated_messages = []
|
@@ -22,46 +22,46 @@ describe YARD::I18n::Messages do
|
|
22
22
|
enumerated_messages << message
|
23
23
|
end
|
24
24
|
enumerated_messages = enumerated_messages.sort_by {|m| m.id }
|
25
|
-
enumerated_messages.
|
25
|
+
expect(enumerated_messages).to eq [message("Hello World!"), message("Title")]
|
26
26
|
end
|
27
27
|
|
28
|
-
it "
|
28
|
+
it "does not yield any message if there are none" do
|
29
29
|
enumerated_messages = []
|
30
30
|
@messages.each do |message|
|
31
31
|
enumerated_messages << message
|
32
32
|
end
|
33
|
-
enumerated_messages.
|
33
|
+
expect(enumerated_messages).to eq []
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
describe "#[]" do
|
38
|
-
it "
|
38
|
+
it "returns registered message" do
|
39
39
|
@messages.register("Hello World!")
|
40
|
-
@messages["Hello World!"].
|
40
|
+
expect(@messages["Hello World!"]).to eq message("Hello World!")
|
41
41
|
end
|
42
42
|
|
43
|
-
it "
|
44
|
-
@messages["Hello World!"].
|
43
|
+
it "returns nil for nonexistent message ID" do
|
44
|
+
expect(@messages["Hello World!"]).to eq nil
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
48
|
describe "#register" do
|
49
|
-
it "
|
50
|
-
@messages.register("Hello World!").
|
49
|
+
it "returns registered message" do
|
50
|
+
expect(@messages.register("Hello World!")).to eq message("Hello World!")
|
51
51
|
end
|
52
52
|
|
53
|
-
it "
|
53
|
+
it "returns existent message" do
|
54
54
|
message = @messages.register("Hello World!")
|
55
|
-
@messages.register("Hello World!").object_id.
|
55
|
+
expect(@messages.register("Hello World!").object_id).to eq message.object_id
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
describe "#==" do
|
60
|
-
it "
|
60
|
+
it "returns true for same value messages" do
|
61
61
|
@messages.register("Hello World!")
|
62
62
|
other_messages = messages
|
63
63
|
other_messages.register("Hello World!")
|
64
|
-
@messages.
|
64
|
+
expect(@messages).to eq other_messages
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -24,11 +24,11 @@ describe YARD::I18n::PotGenerator do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "Generate" do
|
27
|
-
it "
|
27
|
+
it "generates the default header" do
|
28
28
|
current_time = Time.parse("2011-11-20 22:17+0900")
|
29
|
-
@generator.
|
29
|
+
allow(@generator).to receive(:current_time).and_return(current_time)
|
30
30
|
pot_creation_date = current_time.strftime("%Y-%m-%d %H:%M%z")
|
31
|
-
@generator.generate.
|
31
|
+
expect(@generator.generate).to eq <<-eoh
|
32
32
|
# SOME DESCRIPTIVE TITLE.
|
33
33
|
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
|
34
34
|
# This file is distributed under the same license as the PACKAGE package.
|
@@ -51,8 +51,8 @@ msgstr ""
|
|
51
51
|
eoh
|
52
52
|
end
|
53
53
|
|
54
|
-
it "
|
55
|
-
@generator.
|
54
|
+
it "generates messages in location order" do
|
55
|
+
allow(@generator).to receive(:header).and_return("HEADER\n\n")
|
56
56
|
messages = {
|
57
57
|
"tag|see|Parser::SourceParser.parse" => {
|
58
58
|
:locations => [["yard.rb", 14]],
|
@@ -64,7 +64,7 @@ eoh
|
|
64
64
|
}
|
65
65
|
}
|
66
66
|
add_messages(@generator.messages, messages)
|
67
|
-
@generator.generate.
|
67
|
+
expect(@generator.generate).to eq <<-'eoh'
|
68
68
|
HEADER
|
69
69
|
|
70
70
|
# YARD.parse
|
@@ -91,24 +91,24 @@ eoh
|
|
91
91
|
pot
|
92
92
|
end
|
93
93
|
|
94
|
-
it "
|
95
|
-
generate_message_pot("hello \\ world").
|
94
|
+
it "escapes <\\>" do
|
95
|
+
expect(generate_message_pot("hello \\ world")).to eq <<-'eop'
|
96
96
|
msgid "hello \\ world"
|
97
97
|
msgstr ""
|
98
98
|
|
99
99
|
eop
|
100
100
|
end
|
101
101
|
|
102
|
-
it "
|
103
|
-
generate_message_pot("hello \" world").
|
102
|
+
it "escapes <\">" do
|
103
|
+
expect(generate_message_pot("hello \" world")).to eq <<-'eop'
|
104
104
|
msgid "hello \" world"
|
105
105
|
msgstr ""
|
106
106
|
|
107
107
|
eop
|
108
108
|
end
|
109
109
|
|
110
|
-
it "
|
111
|
-
generate_message_pot("hello \n world").
|
110
|
+
it "escapes <\\n>" do
|
111
|
+
expect(generate_message_pot("hello \n world")).to eq <<-'eop'
|
112
112
|
msgid "hello \n"
|
113
113
|
" world"
|
114
114
|
msgstr ""
|
@@ -123,12 +123,12 @@ eop
|
|
123
123
|
@yard = YARD::CodeObjects::ModuleObject.new(:root, :YARD)
|
124
124
|
end
|
125
125
|
|
126
|
-
it "
|
126
|
+
it "extracts at docstring" do
|
127
127
|
object = YARD::CodeObjects::MethodObject.new(@yard, :parse, :module) do |o|
|
128
128
|
o.docstring = "An alias to {Parser::SourceParser}'s parsing method"
|
129
129
|
end
|
130
130
|
@generator.parse_objects([object])
|
131
|
-
@generator.messages.
|
131
|
+
expect(@generator.messages).to eq create_messages({
|
132
132
|
"An alias to {Parser::SourceParser}'s parsing method" => {
|
133
133
|
:locations => [],
|
134
134
|
:comments => ["YARD.parse"],
|
@@ -136,13 +136,13 @@ eop
|
|
136
136
|
})
|
137
137
|
end
|
138
138
|
|
139
|
-
it "
|
139
|
+
it "extracts at location" do
|
140
140
|
object = YARD::CodeObjects::MethodObject.new(@yard, :parse, :module) do |o|
|
141
141
|
o.docstring = "An alias to {Parser::SourceParser}'s parsing method"
|
142
142
|
o.files = [["yard.rb", 12]]
|
143
143
|
end
|
144
144
|
@generator.parse_objects([object])
|
145
|
-
@generator.messages.
|
145
|
+
expect(@generator.messages).to eq create_messages({
|
146
146
|
"An alias to {Parser::SourceParser}'s parsing method" => {
|
147
147
|
:locations => [["yard.rb", 13]],
|
148
148
|
:comments => ["YARD.parse"],
|
@@ -150,13 +150,13 @@ eop
|
|
150
150
|
})
|
151
151
|
end
|
152
152
|
|
153
|
-
it "
|
153
|
+
it "extracts at tag name" do
|
154
154
|
object = YARD::CodeObjects::MethodObject.new(@yard, :parse, :module) do |o|
|
155
155
|
o.docstring = "@see Parser::SourceParser.parse"
|
156
156
|
o.files = [["yard.rb", 12]]
|
157
157
|
end
|
158
158
|
@generator.parse_objects([object])
|
159
|
-
@generator.messages.
|
159
|
+
expect(@generator.messages).to eq create_messages({
|
160
160
|
"tag|see|Parser::SourceParser.parse" => {
|
161
161
|
:locations => [["yard.rb", 12]],
|
162
162
|
:comments => ["@see"],
|
@@ -164,7 +164,7 @@ eop
|
|
164
164
|
})
|
165
165
|
end
|
166
166
|
|
167
|
-
it "
|
167
|
+
it "extracts at tag text" do
|
168
168
|
object = YARD::CodeObjects::MethodObject.new(@yard, :parse, :module) do |o|
|
169
169
|
o.docstring = <<-eod
|
170
170
|
@example Parse a glob of files
|
@@ -173,7 +173,7 @@ eod
|
|
173
173
|
o.files = [["yard.rb", 12]]
|
174
174
|
end
|
175
175
|
@generator.parse_objects([object])
|
176
|
-
@generator.messages.
|
176
|
+
expect(@generator.messages).to eq create_messages({
|
177
177
|
"tag|example|Parse a glob of files" => {
|
178
178
|
:locations => [["yard.rb", 12]],
|
179
179
|
:comments => ["@example"],
|
@@ -185,7 +185,7 @@ eod
|
|
185
185
|
})
|
186
186
|
end
|
187
187
|
|
188
|
-
it "
|
188
|
+
it "extracts at tag types" do
|
189
189
|
object = YARD::CodeObjects::MethodObject.new(@yard, :parse, :module) do |o|
|
190
190
|
o.docstring = <<-eod
|
191
191
|
@param [String, Array<String>] paths a path, glob, or list of paths to
|
@@ -194,7 +194,7 @@ eod
|
|
194
194
|
o.files = [["yard.rb", 12]]
|
195
195
|
end
|
196
196
|
@generator.parse_objects([object])
|
197
|
-
@generator.messages.
|
197
|
+
expect(@generator.messages).to eq create_messages({
|
198
198
|
"tag|param|paths" => {
|
199
199
|
:locations => [["yard.rb", 12]],
|
200
200
|
:comments => ["@param [String, Array<String>]"],
|
@@ -206,7 +206,7 @@ eod
|
|
206
206
|
})
|
207
207
|
end
|
208
208
|
|
209
|
-
it "
|
209
|
+
it "extracts at overload tag recursively" do
|
210
210
|
object = YARD::CodeObjects::MethodObject.new(@yard, :parse, :module) do |o|
|
211
211
|
o.docstring = <<-eod
|
212
212
|
@overload foo(i)
|
@@ -216,7 +216,7 @@ eod
|
|
216
216
|
end
|
217
217
|
|
218
218
|
@generator.parse_objects([object])
|
219
|
-
@generator.messages.
|
219
|
+
expect(@generator.messages).to eq create_messages({
|
220
220
|
"tag|overload|foo" => {
|
221
221
|
:locations => [],
|
222
222
|
:comments => ["@overload"]
|
@@ -238,18 +238,18 @@ eod
|
|
238
238
|
end
|
239
239
|
|
240
240
|
describe "File" do
|
241
|
-
it "
|
241
|
+
it "extracts at attribute" do
|
242
242
|
path = "GettingStarted.md"
|
243
243
|
text = <<-eor
|
244
244
|
# @title Getting Started Guide
|
245
245
|
|
246
246
|
# Getting Started with YARD
|
247
247
|
eor
|
248
|
-
File.
|
249
|
-
File.
|
248
|
+
allow(File).to receive(:open).with(path).and_yield(StringIO.new(text))
|
249
|
+
allow(File).to receive(:read).with(path).and_return(text)
|
250
250
|
file = YARD::CodeObjects::ExtraFileObject.new(path)
|
251
251
|
@generator.parse_files([file])
|
252
|
-
@generator.messages.
|
252
|
+
expect(@generator.messages).to eq create_messages({
|
253
253
|
"Getting Started Guide" => {
|
254
254
|
:locations => [[path, 1]],
|
255
255
|
:comments => ["title"],
|
@@ -261,7 +261,7 @@ eor
|
|
261
261
|
})
|
262
262
|
end
|
263
263
|
|
264
|
-
it "
|
264
|
+
it "extracts at paragraphs" do
|
265
265
|
path = "README.md"
|
266
266
|
paragraph1 = <<-eop.strip
|
267
267
|
Note that class methods must not be referred to with the "::" namespace
|
@@ -276,11 +276,11 @@ eop
|
|
276
276
|
|
277
277
|
#{paragraph2}
|
278
278
|
eot
|
279
|
-
File.
|
280
|
-
File.
|
279
|
+
allow(File).to receive(:open).with(path).and_yield(StringIO.new(text))
|
280
|
+
allow(File).to receive(:read).with(path).and_return(text)
|
281
281
|
file = YARD::CodeObjects::ExtraFileObject.new(path)
|
282
282
|
@generator.parse_files([file])
|
283
|
-
@generator.messages.
|
283
|
+
expect(@generator.messages).to eq create_messages({
|
284
284
|
paragraph1 => {
|
285
285
|
:locations => [[path, 1]],
|
286
286
|
:comments => [],
|
data/spec/i18n/text_spec.rb
CHANGED
@@ -12,45 +12,45 @@ describe YARD::I18n::Text do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
describe "Header" do
|
15
|
-
it "
|
15
|
+
it "extracts at attribute" do
|
16
16
|
text = <<-eot
|
17
17
|
# @title Getting Started Guide
|
18
18
|
|
19
19
|
# Getting Started with YARD
|
20
20
|
eot
|
21
|
-
extract_messages(text, :have_header => true).
|
21
|
+
expect(extract_messages(text, :have_header => true)).to eq(
|
22
22
|
[[:attribute, "title", "Getting Started Guide", 1],
|
23
|
-
[:paragraph, "# Getting Started with YARD", 3]]
|
23
|
+
[:paragraph, "# Getting Started with YARD", 3]])
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
26
|
+
it "ignores markup line" do
|
27
27
|
text = <<-eot
|
28
28
|
#!markdown
|
29
29
|
# @title Getting Started Guide
|
30
30
|
|
31
31
|
# Getting Started with YARD
|
32
32
|
eot
|
33
|
-
extract_messages(text, :have_header => true).
|
33
|
+
expect(extract_messages(text, :have_header => true)).to eq(
|
34
34
|
[[:attribute, "title", "Getting Started Guide", 2],
|
35
|
-
[:paragraph, "# Getting Started with YARD", 4]]
|
35
|
+
[:paragraph, "# Getting Started with YARD", 4]])
|
36
36
|
end
|
37
37
|
|
38
|
-
it "
|
38
|
+
it "terminates header block by markup line not at the first line" do
|
39
39
|
text = <<-eot
|
40
40
|
# @title Getting Started Guide
|
41
41
|
#!markdown
|
42
42
|
|
43
43
|
# Getting Started with YARD
|
44
44
|
eot
|
45
|
-
extract_messages(text, :have_header => true).
|
45
|
+
expect(extract_messages(text, :have_header => true)).to eq(
|
46
46
|
[[:attribute, "title", "Getting Started Guide", 1],
|
47
47
|
[:paragraph, "#!markdown", 2],
|
48
|
-
[:paragraph, "# Getting Started with YARD", 4]]
|
48
|
+
[:paragraph, "# Getting Started with YARD", 4]])
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
52
|
describe "Body" do
|
53
|
-
it "
|
53
|
+
it "splits to paragraphs" do
|
54
54
|
paragraph1 = <<-eop.strip
|
55
55
|
Note that class methods must not be referred to with the "::" namespace
|
56
56
|
separator. Only modules, classes and constants should use "::".
|
@@ -64,9 +64,9 @@ eop
|
|
64
64
|
|
65
65
|
#{paragraph2}
|
66
66
|
eot
|
67
|
-
extract_messages(text).
|
67
|
+
expect(extract_messages(text)).to eq(
|
68
68
|
[[:paragraph, paragraph1, 1],
|
69
|
-
[:paragraph, paragraph2, 4]]
|
69
|
+
[:paragraph, paragraph2, 4]])
|
70
70
|
end
|
71
71
|
end
|
72
72
|
end
|
@@ -88,7 +88,7 @@ eot
|
|
88
88
|
end
|
89
89
|
|
90
90
|
describe "Header" do
|
91
|
-
it "
|
91
|
+
it "extracts at attribute" do
|
92
92
|
text = <<-eot
|
93
93
|
# @title Hello
|
94
94
|
|
@@ -96,7 +96,7 @@ eot
|
|
96
96
|
|
97
97
|
Paragraph.
|
98
98
|
eot
|
99
|
-
translate(text, :have_header => true).
|
99
|
+
expect(translate(text, :have_header => true)).to eq <<-eot
|
100
100
|
# @title Bonjour (Hello in fr)
|
101
101
|
|
102
102
|
# Getting Started with YARD
|
@@ -105,7 +105,7 @@ Paragraph.
|
|
105
105
|
eot
|
106
106
|
end
|
107
107
|
|
108
|
-
it "
|
108
|
+
it "ignores markup line" do
|
109
109
|
text = <<-eot
|
110
110
|
#!markdown
|
111
111
|
# @title Hello
|
@@ -114,7 +114,7 @@ eot
|
|
114
114
|
|
115
115
|
Paragraph.
|
116
116
|
eot
|
117
|
-
translate(text, :have_header => true).
|
117
|
+
expect(translate(text, :have_header => true)).to eq <<-eot
|
118
118
|
#!markdown
|
119
119
|
# @title Bonjour (Hello in fr)
|
120
120
|
|
@@ -126,7 +126,7 @@ eot
|
|
126
126
|
end
|
127
127
|
|
128
128
|
describe "Body" do
|
129
|
-
it "
|
129
|
+
it "splits to paragraphs" do
|
130
130
|
paragraph1 = <<-eop.strip
|
131
131
|
Paragraph 1.
|
132
132
|
eop
|
@@ -138,26 +138,26 @@ eop
|
|
138
138
|
|
139
139
|
#{paragraph2}
|
140
140
|
eot
|
141
|
-
translate(text).
|
141
|
+
expect(translate(text)).to eq <<-eot
|
142
142
|
Paragraphe 1.
|
143
143
|
|
144
144
|
Paragraphe 2.
|
145
145
|
eot
|
146
146
|
end
|
147
147
|
|
148
|
-
it "
|
148
|
+
it "does not modify non-translated message" do
|
149
149
|
nonexistent_paragraph = <<-eop.strip
|
150
150
|
Nonexsitent paragraph.
|
151
151
|
eop
|
152
152
|
text = <<-eot
|
153
153
|
#{nonexistent_paragraph}
|
154
154
|
eot
|
155
|
-
translate(text).
|
155
|
+
expect(translate(text)).to eq <<-eot
|
156
156
|
#{nonexistent_paragraph}
|
157
157
|
eot
|
158
158
|
end
|
159
159
|
|
160
|
-
it "
|
160
|
+
it "keeps empty lines" do
|
161
161
|
text = <<-eot
|
162
162
|
Paragraph 1.
|
163
163
|
|
@@ -166,7 +166,7 @@ Paragraph 1.
|
|
166
166
|
|
167
167
|
Paragraph 2.
|
168
168
|
eot
|
169
|
-
translate(text).
|
169
|
+
expect(translate(text)).to eq <<-eot
|
170
170
|
Paragraphe 1.
|
171
171
|
|
172
172
|
|