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
@@ -3,11 +3,11 @@
|
|
3
3
|
|
4
4
|
|
5
5
|
</h1>
|
6
|
-
|
7
|
-
<dl class="box">
|
6
|
+
<div class="box_info">
|
8
7
|
|
9
|
-
|
10
|
-
<
|
8
|
+
<dl>
|
9
|
+
<dt>Inherits:</dt>
|
10
|
+
<dd>
|
11
11
|
<span class="inheritName">Object</span>
|
12
12
|
|
13
13
|
<ul class="fullTree">
|
@@ -18,41 +18,47 @@
|
|
18
18
|
</ul>
|
19
19
|
<a href="#" class="inheritanceTree">show all</a>
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
</dd>
|
22
|
+
</dl>
|
23
23
|
|
24
|
+
|
24
25
|
|
25
|
-
|
26
|
-
<dt class="r2">Extended by:</dt>
|
27
|
-
<dd class="r2">Bar</dd>
|
28
|
-
|
29
|
-
|
30
26
|
|
31
|
-
|
32
|
-
<dt
|
33
|
-
<dd
|
34
|
-
|
35
|
-
|
27
|
+
<dl>
|
28
|
+
<dt>Extended by:</dt>
|
29
|
+
<dd>Bar</dd>
|
30
|
+
</dl>
|
36
31
|
|
37
32
|
|
38
33
|
|
39
|
-
|
40
|
-
|
34
|
+
<dl>
|
35
|
+
<dt>Includes:</dt>
|
36
|
+
<dd>BarFooBar, Baz::ABC, Baz::XYZ, Foo</dd>
|
37
|
+
</dl>
|
41
38
|
|
42
|
-
|
43
|
-
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
<dl>
|
45
|
+
<dt>Defined in:</dt>
|
46
|
+
<dd>(stdin)</dd>
|
47
|
+
</dl>
|
48
|
+
|
49
|
+
</div>
|
44
50
|
|
45
51
|
|
46
52
|
|
47
53
|
|
48
54
|
|
49
|
-
<h2>Instance Attribute Summary <small
|
55
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
50
56
|
<ul class="summary">
|
51
57
|
|
52
58
|
<li class="public ">
|
53
59
|
<span class="summary_signature">
|
54
60
|
|
55
|
-
<a title="#bar_attr (instance method)"
|
61
|
+
<a title="#bar_attr (instance method)">#<strong>bar_attr</strong> </a>
|
56
62
|
|
57
63
|
|
58
64
|
|
@@ -87,7 +93,7 @@
|
|
87
93
|
|
88
94
|
<h2>
|
89
95
|
Booya
|
90
|
-
<small
|
96
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
91
97
|
</h2>
|
92
98
|
|
93
99
|
<ul class="summary">
|
@@ -95,7 +101,7 @@
|
|
95
101
|
<li class="public ">
|
96
102
|
<span class="summary_signature">
|
97
103
|
|
98
|
-
<a title="#baz (class method)"
|
104
|
+
<a title="#baz (class method)">.<strong>baz</strong> </a>
|
99
105
|
|
100
106
|
|
101
107
|
|
@@ -122,7 +128,7 @@
|
|
122
128
|
<li class="public ">
|
123
129
|
<span class="summary_signature">
|
124
130
|
|
125
|
-
<a title="#baz_abc (instance method)"
|
131
|
+
<a title="#baz_abc (instance method)">#<strong>baz_abc</strong> </a>
|
126
132
|
|
127
133
|
|
128
134
|
|
@@ -150,7 +156,7 @@
|
|
150
156
|
|
151
157
|
<h2>
|
152
158
|
Instance Method Summary
|
153
|
-
<small
|
159
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
154
160
|
</h2>
|
155
161
|
|
156
162
|
<ul class="summary">
|
@@ -158,7 +164,7 @@
|
|
158
164
|
<li class="public ">
|
159
165
|
<span class="summary_signature">
|
160
166
|
|
161
|
-
<a title="#foo (instance method)"
|
167
|
+
<a title="#foo (instance method)">#<strong>foo</strong> </a>
|
162
168
|
|
163
169
|
|
164
170
|
|
@@ -180,7 +186,7 @@
|
|
180
186
|
<li class="public ">
|
181
187
|
<span class="summary_signature">
|
182
188
|
|
183
|
-
<a title="#xyz (instance method)"
|
189
|
+
<a title="#xyz (instance method)">#<strong>xyz</strong> </a>
|
184
190
|
|
185
191
|
|
186
192
|
|
@@ -244,7 +250,7 @@
|
|
244
250
|
<div class="method_details first">
|
245
251
|
<h3 class="signature first" id="bar_attr-instance_method">
|
246
252
|
|
247
|
-
|
253
|
+
#<strong>bar_attr</strong>
|
248
254
|
|
249
255
|
|
250
256
|
|
@@ -277,7 +283,7 @@
|
|
277
283
|
<div class="method_details first">
|
278
284
|
<h3 class="signature first" id="baz-class_method">
|
279
285
|
|
280
|
-
|
286
|
+
.<strong>baz</strong>
|
281
287
|
|
282
288
|
|
283
289
|
|
@@ -309,7 +315,7 @@
|
|
309
315
|
<div class="method_details first">
|
310
316
|
<h3 class="signature first" id="baz_abc-instance_method">
|
311
317
|
|
312
|
-
|
318
|
+
#<strong>baz_abc</strong>
|
313
319
|
|
314
320
|
|
315
321
|
|
@@ -326,7 +332,7 @@
|
|
326
332
|
<div class="method_details ">
|
327
333
|
<h3 class="signature " id="foo-instance_method">
|
328
334
|
|
329
|
-
|
335
|
+
#<strong>foo</strong>
|
330
336
|
|
331
337
|
|
332
338
|
|
@@ -361,7 +367,7 @@ def foo; end</pre>
|
|
361
367
|
<div class="method_details ">
|
362
368
|
<h3 class="signature " id="xyz-instance_method">
|
363
369
|
|
364
|
-
|
370
|
+
#<strong>xyz</strong>
|
365
371
|
|
366
372
|
|
367
373
|
|
@@ -385,3 +391,4 @@ def foo; end</pre>
|
|
385
391
|
</div>
|
386
392
|
|
387
393
|
</div>
|
394
|
+
|
@@ -3,173 +3,169 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
3
3
|
describe YARD::Templates::Helpers::BaseHelper do
|
4
4
|
include YARD::Templates::Helpers::BaseHelper
|
5
5
|
|
6
|
-
describe
|
7
|
-
it "
|
6
|
+
describe "#run_verifier" do
|
7
|
+
it "runs verifier proc against list if provided" do
|
8
8
|
mock = Verifier.new
|
9
|
-
mock.
|
10
|
-
mock.
|
11
|
-
mock.
|
12
|
-
|
9
|
+
expect(mock).to receive(:call).with(1)
|
10
|
+
expect(mock).to receive(:call).with(2)
|
11
|
+
expect(mock).to receive(:call).with(3)
|
12
|
+
expect(self).to receive(:options).at_least(1).times.and_return(Options.new.update(:verifier => mock))
|
13
13
|
run_verifier [1, 2, 3]
|
14
14
|
end
|
15
15
|
|
16
|
-
it "
|
16
|
+
it "prunes list if lambda returns false and only false" do
|
17
17
|
mock = Verifier.new
|
18
|
-
|
19
|
-
mock.
|
20
|
-
mock.
|
21
|
-
mock.
|
22
|
-
mock.
|
23
|
-
run_verifier([1, 2, 3, 4]).
|
18
|
+
expect(self).to receive(:options).at_least(1).times.and_return(Options.new.update(:verifier => mock))
|
19
|
+
expect(mock).to receive(:call).with(1).and_return(false)
|
20
|
+
expect(mock).to receive(:call).with(2).and_return(true)
|
21
|
+
expect(mock).to receive(:call).with(3).and_return(nil)
|
22
|
+
expect(mock).to receive(:call).with(4).and_return("value")
|
23
|
+
expect(run_verifier([1, 2, 3, 4])).to eq [2, 3, 4]
|
24
24
|
end
|
25
25
|
|
26
|
-
it "
|
27
|
-
|
28
|
-
run_verifier([1, 2, 3]).
|
26
|
+
it "returns list if no verifier exists" do
|
27
|
+
expect(self).to receive(:options).at_least(1).times.and_return(Options.new)
|
28
|
+
expect(run_verifier([1, 2, 3])).to eq [1, 2, 3]
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
describe
|
33
|
-
it "
|
34
|
-
h("hello world").
|
35
|
-
h(nil).
|
32
|
+
describe "#h" do
|
33
|
+
it "returns just the text" do
|
34
|
+
expect(h("hello world")).to eq "hello world"
|
35
|
+
expect(h(nil)).to eq nil
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
-
describe
|
40
|
-
it "
|
41
|
-
link_object(1, "title").
|
42
|
-
link_object(Registry.root, "title").
|
39
|
+
describe "#link_object" do
|
40
|
+
it "returns the title if provided" do
|
41
|
+
expect(link_object(1, "title")).to eq "title"
|
42
|
+
expect(link_object(Registry.root, "title")).to eq "title"
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
46
|
-
link_object(Registry.root).
|
47
|
-
link_object(P("Array")).
|
45
|
+
it "returns a path if argument is a Proxy or object" do
|
46
|
+
expect(link_object(Registry.root)).to eq "Top Level Namespace"
|
47
|
+
expect(link_object(P("Array"))).to eq "Array"
|
48
48
|
end
|
49
49
|
|
50
|
-
it "
|
51
|
-
link_object("Array").
|
52
|
-
link_object(:"A::B").
|
50
|
+
it "returns path of Proxified object if argument is a String or Symbol" do
|
51
|
+
expect(link_object("Array")).to eq "Array"
|
52
|
+
expect(link_object(:"A::B")).to eq "A::B"
|
53
53
|
end
|
54
54
|
|
55
|
-
it "
|
56
|
-
link_object(1).
|
55
|
+
it "returns the argument if not an object, proxy, String or Symbol" do
|
56
|
+
expect(link_object(1)).to eq 1
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
describe
|
61
|
-
it "
|
62
|
-
link_url("http://url").
|
60
|
+
describe "#link_url" do
|
61
|
+
it "returns the URL" do
|
62
|
+
expect(link_url("http://url")).to eq "http://url"
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
describe
|
67
|
-
|
68
|
-
|
69
|
-
|
66
|
+
describe "#linkify" do
|
67
|
+
let(:object) { Registry.root }
|
68
|
+
# before do
|
69
|
+
# stub!(:object).and_return(Registry.root)
|
70
|
+
# end
|
70
71
|
|
71
|
-
it "
|
72
|
-
|
72
|
+
it "calls #link_url for mailto: links" do
|
73
|
+
expect(self).to receive(:link_url)
|
73
74
|
linkify("mailto:steve@example.com")
|
74
75
|
end
|
75
76
|
|
76
|
-
it "
|
77
|
-
|
77
|
+
it "calls #link_url for URL schemes (http://)" do
|
78
|
+
expect(self).to receive(:link_url)
|
78
79
|
linkify("http://example.com")
|
79
80
|
end
|
80
81
|
|
81
|
-
it "
|
82
|
-
|
82
|
+
it "calls #link_file for file: links" do
|
83
|
+
expect(self).to receive(:link_file).with('Filename', nil, 'anchor')
|
83
84
|
linkify("file:Filename#anchor")
|
84
85
|
end
|
85
86
|
|
86
|
-
it "
|
87
|
+
it "passes off to #link_object if argument is an object" do
|
87
88
|
obj = CodeObjects::NamespaceObject.new(nil, :YARD)
|
88
|
-
|
89
|
+
expect(self).to receive(:link_object).with(obj)
|
89
90
|
linkify obj
|
90
91
|
end
|
91
92
|
|
92
|
-
it "
|
93
|
-
log.
|
94
|
-
linkify('include:NotExist').
|
93
|
+
it "returns empty string and warn if object does not exist" do
|
94
|
+
expect(log).to receive(:warn).with(/Cannot find object .* for inclusion/)
|
95
|
+
expect(linkify('include:NotExist')).to eq ''
|
95
96
|
end
|
96
97
|
|
97
|
-
it "
|
98
|
+
it "passes off to #link_url if argument is recognized as a URL" do
|
98
99
|
url = "http://yardoc.org/"
|
99
|
-
|
100
|
+
expect(self).to receive(:link_url).with(url, nil, {:target => '_parent'})
|
100
101
|
linkify url
|
101
102
|
end
|
102
103
|
|
103
|
-
it "
|
104
|
+
it "calls #link_include_object for include:ObjectName" do
|
104
105
|
obj = CodeObjects::NamespaceObject.new(:root, :Foo)
|
105
|
-
|
106
|
+
expect(self).to receive(:link_include_object).with(obj)
|
106
107
|
linkify 'include:Foo'
|
107
108
|
end
|
108
109
|
|
109
|
-
it "
|
110
|
-
File.
|
111
|
-
File.
|
112
|
-
linkify('include:file:path/to/file').
|
110
|
+
it "calls #link_include_file for include:file:path/to/file" do
|
111
|
+
expect(File).to receive(:file?).with('path/to/file').and_return(true)
|
112
|
+
expect(File).to receive(:read).with('path/to/file').and_return('FOO')
|
113
|
+
expect(linkify('include:file:path/to/file')).to eq 'FOO'
|
113
114
|
end
|
114
115
|
|
115
|
-
it "
|
116
|
-
log.
|
117
|
-
linkify('include:file:a/b/../../../../file').
|
116
|
+
it "does not allow include:file for path above pwd" do
|
117
|
+
expect(log).to receive(:warn).with("Cannot include file from path `a/b/../../../../file'")
|
118
|
+
expect(linkify('include:file:a/b/../../../../file')).to eq ''
|
118
119
|
end
|
119
120
|
|
120
|
-
it "
|
121
|
-
log.
|
122
|
-
linkify('include:file:notexist').
|
121
|
+
it "warns if include:file:path does not exist" do
|
122
|
+
expect(log).to receive(:warn).with(/Cannot find file .+ for inclusion/)
|
123
|
+
expect(linkify('include:file:notexist')).to eq ''
|
123
124
|
end
|
124
125
|
end
|
125
126
|
|
126
|
-
describe
|
127
|
-
it "
|
128
|
-
format_types(['a', 'b', 'c']).
|
127
|
+
describe "#format_types" do
|
128
|
+
it "returns the list of types separated by commas surrounded by brackets" do
|
129
|
+
expect(format_types(['a', 'b', 'c'])).to eq '(a, b, c)'
|
129
130
|
end
|
130
131
|
|
131
|
-
it "
|
132
|
-
format_types(['a', 'b', 'c'], false).
|
132
|
+
it "returns the list of types without brackets if brackets=false" do
|
133
|
+
expect(format_types(['a', 'b', 'c'], false)).to eq 'a, b, c'
|
133
134
|
end
|
134
135
|
|
135
|
-
it "
|
136
|
-
format_types(nil).
|
137
|
-
format_types([]).
|
136
|
+
it "returns an empty string if list is empty or nil" do
|
137
|
+
expect(format_types(nil)).to eq ""
|
138
|
+
expect(format_types([])).to eq ""
|
138
139
|
end
|
139
140
|
end
|
140
141
|
|
141
|
-
describe
|
142
|
-
it "
|
143
|
-
obj =
|
144
|
-
obj.
|
145
|
-
obj
|
146
|
-
format_object_type(obj).should == "Exception"
|
142
|
+
describe "#format_object_type" do
|
143
|
+
it "returns Exception if type is Exception" do
|
144
|
+
obj = double(:object, :is_exception? => true)
|
145
|
+
allow(obj).to receive(:is_a?) { |arg| arg == YARD::CodeObjects::ClassObject }
|
146
|
+
expect(format_object_type(obj)).to eq "Exception"
|
147
147
|
end
|
148
148
|
|
149
|
-
it "
|
150
|
-
obj =
|
151
|
-
obj.
|
152
|
-
obj
|
153
|
-
format_object_type(obj).should == "Class"
|
149
|
+
it "returns Class if type is Class" do
|
150
|
+
obj = double(:object, :is_exception? => false)
|
151
|
+
allow(obj).to receive(:is_a?) { |arg| arg == YARD::CodeObjects::ClassObject }
|
152
|
+
expect(format_object_type(obj)).to eq "Class"
|
154
153
|
end
|
155
154
|
|
156
|
-
it "
|
157
|
-
obj =
|
158
|
-
obj
|
159
|
-
format_object_type(obj).should == "Value"
|
155
|
+
it "returns object type in other cases" do
|
156
|
+
obj = double(:object, :type => "value")
|
157
|
+
expect(format_object_type(obj)).to eq "Value"
|
160
158
|
end
|
161
159
|
end
|
162
160
|
|
163
|
-
describe
|
164
|
-
it "
|
165
|
-
format_object_title(Registry.root).
|
161
|
+
describe "#format_object_title" do
|
162
|
+
it "returns Top Level Namespace for root object" do
|
163
|
+
expect(format_object_title(Registry.root)).to eq "Top Level Namespace"
|
166
164
|
end
|
167
165
|
|
168
|
-
it "
|
169
|
-
obj =
|
170
|
-
obj
|
171
|
-
obj.stub!(:title).and_return("A::B::C")
|
172
|
-
format_object_title(obj).should == "Class: A::B::C"
|
166
|
+
it "returns 'type: title' in other cases" do
|
167
|
+
obj = double(:object, :type => :class, :title => "A::B::C")
|
168
|
+
expect(format_object_title(obj)).to eq "Class: A::B::C"
|
173
169
|
end
|
174
170
|
end
|
175
171
|
end
|
@@ -14,71 +14,71 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
|
-
describe
|
18
|
-
it "
|
19
|
-
h('Usage: foo "bar" <baz>').
|
17
|
+
describe "#h" do
|
18
|
+
it "uses #h to escape HTML" do
|
19
|
+
expect(h('Usage: foo "bar" <baz>')).to eq "Usage: foo "bar" <baz>"
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
describe
|
24
|
-
it "
|
25
|
-
ENV.
|
26
|
-
Encoding.default_external.
|
27
|
-
charset.
|
23
|
+
describe "#charset" do
|
24
|
+
it "returns foo if LANG=foo" do
|
25
|
+
expect(ENV).to receive(:[]).with('LANG').and_return('shift_jis') if YARD.ruby18?
|
26
|
+
expect(Encoding.default_external).to receive(:name).and_return('shift_jis') if defined?(Encoding)
|
27
|
+
expect(charset).to eq 'shift_jis'
|
28
28
|
end
|
29
29
|
|
30
30
|
['US-ASCII', 'ASCII-7BIT', 'ASCII-8BIT'].each do |type|
|
31
|
-
it "
|
32
|
-
ENV.
|
33
|
-
Encoding.default_external.
|
34
|
-
charset.
|
31
|
+
it "converts #{type} to iso-8859-1" do
|
32
|
+
expect(ENV).to receive(:[]).with('LANG').and_return(type) if YARD.ruby18?
|
33
|
+
expect(Encoding.default_external).to receive(:name).and_return(type) if defined?(Encoding)
|
34
|
+
expect(charset).to eq 'iso-8859-1'
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
it "
|
38
|
+
it "supports utf8 as an encoding value for utf-8" do
|
39
39
|
type = 'utf8'
|
40
|
-
ENV.
|
41
|
-
Encoding.default_external.
|
42
|
-
charset.
|
40
|
+
expect(ENV).to receive(:[]).with('LANG').and_return(type) if YARD.ruby18?
|
41
|
+
expect(Encoding.default_external).to receive(:name).and_return(type) if defined?(Encoding)
|
42
|
+
expect(charset).to eq 'utf-8'
|
43
43
|
end
|
44
44
|
|
45
|
-
it "
|
45
|
+
it "takes file encoding if there is a file" do
|
46
46
|
@file = OpenStruct.new(:contents => 'foo'.force_encoding('sjis'))
|
47
47
|
# not the correct charset name, but good enough
|
48
|
-
['Shift_JIS', 'Windows-31J'].
|
48
|
+
expect(['Shift_JIS', 'Windows-31J']).to include(charset)
|
49
49
|
end if YARD.ruby19?
|
50
50
|
|
51
|
-
it "
|
52
|
-
ENV.
|
51
|
+
it "takes file encoding if there is a file" do
|
52
|
+
allow(ENV).to receive(:[]).with('LANG').and_return('utf-8') if YARD.ruby18?
|
53
53
|
@file = OpenStruct.new(:contents => 'foo')
|
54
|
-
charset.
|
54
|
+
expect(charset).to eq 'utf-8'
|
55
55
|
end if YARD.ruby18?
|
56
56
|
|
57
57
|
if YARD.ruby18?
|
58
|
-
it "
|
59
|
-
ENV.
|
60
|
-
charset.
|
58
|
+
it "returns utf-8 if no LANG env is set" do
|
59
|
+
expect(ENV).to receive(:[]).with('LANG').and_return(nil)
|
60
|
+
expect(charset).to eq 'utf-8'
|
61
61
|
end
|
62
62
|
|
63
|
-
it "
|
64
|
-
ENV.
|
65
|
-
charset.
|
63
|
+
it "only returns charset part of lang" do
|
64
|
+
expect(ENV).to receive(:[]).with('LANG').and_return('en_US.UTF-8')
|
65
|
+
expect(charset).to eq 'utf-8'
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
-
describe
|
71
|
-
it "
|
70
|
+
describe "#format_types" do
|
71
|
+
it "includes brackets by default" do
|
72
72
|
text = ["String"]
|
73
|
-
|
74
|
-
format_types(text).
|
75
|
-
format_types(text).
|
73
|
+
expect(self).to receive(:linkify).at_least(1).times.with("String", "String").and_return("String")
|
74
|
+
expect(format_types(text)).to eq format_types(text, true)
|
75
|
+
expect(format_types(text)).to eq "(<tt>String</tt>)"
|
76
76
|
end
|
77
77
|
|
78
|
-
it "
|
79
|
-
|
80
|
-
|
81
|
-
format_types(["String", "Symbol"], false).
|
78
|
+
it "avoids brackets if brackets=false" do
|
79
|
+
expect(self).to receive(:linkify).with("String", "String").and_return("String")
|
80
|
+
expect(self).to receive(:linkify).with("Symbol", "Symbol").and_return("Symbol")
|
81
|
+
expect(format_types(["String", "Symbol"], false)).to eq "<tt>String</tt>, <tt>Symbol</tt>"
|
82
82
|
end
|
83
83
|
|
84
84
|
{ "String" => [["String"],
|
@@ -93,28 +93,32 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
93
93
|
"<tt><a href=''>Array</a><{<a href=''>String</a> => " +
|
94
94
|
"<a href=''>Array</a><<a href=''>Symbol</a>>}></tt>"]
|
95
95
|
}.each do |text, values|
|
96
|
-
it "
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
96
|
+
it "links all classes in #{text}" do
|
97
|
+
if text.count('<') > 0
|
98
|
+
expect(self).to receive(:h).with('<').at_least(text.count('<')).times.and_return("<")
|
99
|
+
end
|
100
|
+
if text.count('>') > 0
|
101
|
+
expect(self).to receive(:h).with('>').at_least(text.count('>')).times.and_return(">")
|
102
|
+
end
|
103
|
+
values[0].each {|v| expect(self).to receive(:linkify).with(v, v).and_return("<a href=''>#{v}</a>") }
|
104
|
+
expect(format_types([text], false)).to eq values[1]
|
101
105
|
end
|
102
106
|
end
|
103
107
|
end
|
104
108
|
|
105
|
-
describe
|
106
|
-
it "
|
109
|
+
describe "#htmlify" do
|
110
|
+
it "does not use hard breaks for textile markup (RedCloth specific)" do
|
107
111
|
begin; require 'redcloth'; rescue LoadError; pending 'test requires redcloth gem' end
|
108
|
-
htmlify("A\nB", :textile).
|
112
|
+
expect(htmlify("A\nB", :textile)).not_to include("<br")
|
109
113
|
end
|
110
114
|
|
111
|
-
it "
|
115
|
+
it "uses hard breaks for textile_strict markup (RedCloth specific)" do
|
112
116
|
begin; require 'redcloth'; rescue LoadError; pending 'test requires redcloth gem' end
|
113
|
-
htmlify("A\nB", :textile_strict).
|
117
|
+
expect(htmlify("A\nB", :textile_strict)).to include("<br")
|
114
118
|
end
|
115
119
|
|
116
|
-
it "
|
117
|
-
|
120
|
+
it "handles various encodings" do
|
121
|
+
allow(self).to receive(:object).and_return(Registry.root)
|
118
122
|
text = "\xB0\xB1"
|
119
123
|
if defined?(Encoding)
|
120
124
|
Encoding.default_internal = 'utf-8'
|
@@ -124,53 +128,53 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
124
128
|
# TODO: add more encoding tests
|
125
129
|
end
|
126
130
|
|
127
|
-
it "
|
128
|
-
htmlify("fo\no\n\nbar<>", :pre).
|
131
|
+
it "returns pre-formatted text with :pre markup" do
|
132
|
+
expect(htmlify("fo\no\n\nbar<>", :pre)).to eq "<pre>fo\no\n\nbar<></pre>"
|
129
133
|
end
|
130
134
|
|
131
|
-
it "
|
132
|
-
htmlify("fo\no\n\nbar<>", :text).
|
135
|
+
it "returns regular text with :text markup" do
|
136
|
+
expect(htmlify("fo\no\n\nbar<>", :text)).to eq "fo<br/>o<br/><br/>bar<>"
|
133
137
|
end
|
134
138
|
|
135
|
-
it "
|
136
|
-
htmlify("fo\no\n\nbar<>", :none).
|
139
|
+
it "returns unmodified text with :none markup" do
|
140
|
+
expect(htmlify("fo\no\n\nbar<>", :none)).to eq "fo\no\n\nbar<>"
|
137
141
|
end
|
138
142
|
|
139
|
-
it "
|
140
|
-
htmlify("class Foo; end", :ruby).
|
143
|
+
it "highlights ruby if markup is :ruby" do
|
144
|
+
expect(htmlify("class Foo; end", :ruby)).to match /\A<pre class="code ruby"><span/
|
141
145
|
end
|
142
146
|
|
143
|
-
it "
|
147
|
+
it "includes file and htmlifies it" do
|
144
148
|
load_markup_provider(:rdoc)
|
145
|
-
File.
|
146
|
-
File.
|
147
|
-
htmlify("{include:file:foo.rdoc}", :rdoc).gsub(/\s+/, '').
|
149
|
+
expect(File).to receive(:file?).with('foo.rdoc').and_return(true)
|
150
|
+
expect(File).to receive(:read).with('foo.rdoc').and_return('HI')
|
151
|
+
expect(htmlify("{include:file:foo.rdoc}", :rdoc).gsub(/\s+/, '')).to eq "<p><p>HI</p></p>"
|
148
152
|
end
|
149
153
|
|
150
|
-
it "
|
154
|
+
it "autolinks URLs (markdown specific)" do
|
151
155
|
log.enter_level(Logger::FATAL) do
|
152
156
|
unless markup_class(:markdown).to_s == "RedcarpetCompat"
|
153
157
|
pending 'This test depends on a markdown engine that supports autolinking'
|
154
158
|
end
|
155
159
|
end
|
156
|
-
htmlify('http://example.com', :markdown).chomp.gsub('/', '/').
|
157
|
-
'<p><a href="http://example.com">http://example.com</a></p>'
|
160
|
+
expect(htmlify('http://example.com', :markdown).chomp.gsub('/', '/')).to eq(
|
161
|
+
'<p><a href="http://example.com">http://example.com</a></p>')
|
158
162
|
end
|
159
163
|
|
160
|
-
it "
|
164
|
+
it "does not autolink URLs inside of {} (markdown specific)" do
|
161
165
|
log.enter_level(Logger::FATAL) do
|
162
166
|
pending 'This test depends on markdown' unless markup_class(:markdown)
|
163
167
|
end
|
164
|
-
htmlify('{http://example.com Title}', :markdown).chomp.
|
165
|
-
%r{<p><a href="http://example.com".*>Title</a></p>}
|
166
|
-
htmlify('{http://example.com}', :markdown).chomp.
|
167
|
-
%r{<p><a href="http://example.com".*>http://example.com</a></p>}
|
168
|
+
expect(htmlify('{http://example.com Title}', :markdown).chomp).to match(
|
169
|
+
%r{<p><a href="http://example.com".*>Title</a></p>})
|
170
|
+
expect(htmlify('{http://example.com}', :markdown).chomp).to match(
|
171
|
+
%r{<p><a href="http://example.com".*>http://example.com</a></p>})
|
168
172
|
end
|
169
173
|
|
170
|
-
it "
|
174
|
+
it "creates tables (markdown specific)" do
|
171
175
|
log.enter_level(Logger::FATAL) do
|
172
176
|
unless markup_class(:markdown).to_s == "RedcarpetCompat"
|
173
|
-
|
177
|
+
skip "This test depends on a markdown engine that supports tables"
|
174
178
|
end
|
175
179
|
end
|
176
180
|
|
@@ -182,12 +186,12 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
182
186
|
EOF
|
183
187
|
|
184
188
|
html = htmlify(markdown, :markdown)
|
185
|
-
html.
|
186
|
-
html.
|
187
|
-
html.
|
189
|
+
expect(html).to match %r{<table>}
|
190
|
+
expect(html).to match %r{<th>City</th>}
|
191
|
+
expect(html).to match %r{<td>NC</td>}
|
188
192
|
end
|
189
193
|
|
190
|
-
it
|
194
|
+
it "handles fenced code blocks (Redcarpet specific)" do
|
191
195
|
log.enter_level(Logger::FATAL) do
|
192
196
|
unless markup_class(:markdown).to_s == 'RedcarpetCompat'
|
193
197
|
pending 'This test is Redcarpet specific'
|
@@ -196,26 +200,24 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
196
200
|
|
197
201
|
markdown = "Introduction:\n```ruby\nputs\n\nputs\n```"
|
198
202
|
html = htmlify(markdown, :markdown)
|
199
|
-
html.
|
203
|
+
expect(html).to match %r{^<p>Introduction:</p>.*<code class="ruby">}m
|
200
204
|
end
|
201
205
|
end
|
202
206
|
|
203
207
|
describe "#link_object" do
|
204
|
-
|
205
|
-
stub!(:object).and_return(CodeObjects::NamespaceObject.new(nil, :YARD))
|
206
|
-
end
|
208
|
+
let(:object) { CodeObjects::NamespaceObject.new(nil, :YARD) }
|
207
209
|
|
208
|
-
it "
|
209
|
-
|
210
|
-
link_object(CodeObjects::NamespaceObject.new(nil, :YARD)).
|
210
|
+
it "returns the object path if there's no serializer and no title" do
|
211
|
+
allow(self).to receive(:serializer).and_return(nil)
|
212
|
+
expect(link_object(CodeObjects::NamespaceObject.new(nil, :YARD))).to eq "YARD"
|
211
213
|
end
|
212
214
|
|
213
|
-
it "
|
214
|
-
|
215
|
-
link_object(CodeObjects::NamespaceObject.new(nil, :YARD), 'title').
|
215
|
+
it "returns the title if there's a title but no serializer" do
|
216
|
+
allow(self).to receive(:serializer).and_return(nil)
|
217
|
+
expect(link_object(CodeObjects::NamespaceObject.new(nil, :YARD), 'title')).to eq "title"
|
216
218
|
end
|
217
219
|
|
218
|
-
it "
|
220
|
+
it "links objects from overload tag" do
|
219
221
|
YARD.parse_string <<-'eof'
|
220
222
|
module Foo
|
221
223
|
class Bar; def a; end end
|
@@ -228,50 +230,46 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
228
230
|
obj = Registry.at('Foo::Baz#a').tag(:overload)
|
229
231
|
foobar = Registry.at('Foo::Bar')
|
230
232
|
foobaz = Registry.at('Foo::Baz')
|
231
|
-
serializer
|
232
|
-
|
233
|
-
|
234
|
-
link_object("Bar#a").should =~ %r{href="Bar.html#a-instance_method"}
|
233
|
+
allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
|
234
|
+
allow(self).to receive(:object).and_return(obj)
|
235
|
+
expect(link_object("Bar#a")).to match %r{href="Bar.html#a-instance_method"}
|
235
236
|
end
|
236
237
|
|
237
|
-
it "
|
238
|
+
it "uses relative path in title" do
|
238
239
|
CodeObjects::ModuleObject.new(:root, :YARD)
|
239
240
|
CodeObjects::ClassObject.new(P('YARD'), :Bar)
|
240
|
-
|
241
|
-
serializer
|
242
|
-
|
243
|
-
link_object("Bar").should =~ %r{>Bar</a>}
|
241
|
+
allow(self).to receive(:object).and_return(CodeObjects::ModuleObject.new(P('YARD'), :Foo))
|
242
|
+
allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
|
243
|
+
expect(link_object("Bar")).to match %r{>Bar</a>}
|
244
244
|
end
|
245
245
|
|
246
|
-
it "
|
246
|
+
it "uses #title if overridden" do
|
247
247
|
CodeObjects::ModuleObject.new(:root, :YARD)
|
248
248
|
CodeObjects::ClassObject.new(P('YARD'), :Bar)
|
249
|
-
Registry.at('YARD::Bar').
|
250
|
-
|
249
|
+
allow(Registry.at('YARD::Bar')).to receive(:title).and_return('TITLE!')
|
250
|
+
allow(self).to receive(:object).and_return(Registry.at('YARD::Bar'))
|
251
251
|
serializer = Serializers::FileSystemSerializer.new
|
252
|
-
|
253
|
-
link_object("Bar").
|
252
|
+
allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
|
253
|
+
expect(link_object("Bar")).to match %r{>TITLE!</a>}
|
254
254
|
end
|
255
255
|
|
256
|
-
it "
|
256
|
+
it "uses relative path to parent class in title" do
|
257
257
|
root = CodeObjects::ModuleObject.new(:root, :YARD)
|
258
258
|
obj = CodeObjects::ModuleObject.new(root, :SubModule)
|
259
|
-
|
260
|
-
serializer
|
261
|
-
|
262
|
-
link_object("YARD").should =~ %r{>YARD</a>}
|
259
|
+
allow(self).to receive(:object).and_return(obj)
|
260
|
+
allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
|
261
|
+
expect(link_object("YARD")).to match %r{>YARD</a>}
|
263
262
|
end
|
264
263
|
|
265
|
-
it "
|
264
|
+
it "uses Klass.foo when linking to class method in current namespace" do
|
266
265
|
root = CodeObjects::ModuleObject.new(:root, :Klass)
|
267
266
|
obj = CodeObjects::MethodObject.new(root, :foo, :class)
|
268
|
-
|
269
|
-
serializer
|
270
|
-
|
271
|
-
link_object("foo").should =~ %r{>Klass.foo</a>}
|
267
|
+
allow(self).to receive(:object).and_return(root)
|
268
|
+
allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
|
269
|
+
expect(link_object("foo")).to match %r{>Klass.foo</a>}
|
272
270
|
end
|
273
271
|
|
274
|
-
it "
|
272
|
+
it "escapes method name in title" do
|
275
273
|
YARD.parse_string <<-'eof'
|
276
274
|
class Array
|
277
275
|
def &(other)
|
@@ -279,73 +277,71 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
279
277
|
end
|
280
278
|
eof
|
281
279
|
obj = Registry.at('Array#&')
|
282
|
-
serializer
|
283
|
-
|
284
|
-
|
285
|
-
link_object("Array#&").should =~ %r{title="Array#& \(method\)"}
|
280
|
+
allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
|
281
|
+
allow(self).to receive(:object).and_return(obj)
|
282
|
+
expect(link_object("Array#&")).to match %r{title="Array#& \(method\)"}
|
286
283
|
end
|
287
284
|
end
|
288
285
|
|
289
|
-
describe
|
286
|
+
describe "#url_for" do
|
290
287
|
before { Registry.clear }
|
291
288
|
|
292
|
-
it "
|
293
|
-
|
294
|
-
|
295
|
-
url_for(P("Mod::Class#meth")).
|
289
|
+
it "returns nil if serializer is nil" do
|
290
|
+
allow(self).to receive(:serializer).and_return nil
|
291
|
+
allow(self).to receive(:object).and_return Registry.root
|
292
|
+
expect(url_for(P("Mod::Class#meth"))).to be nil
|
296
293
|
end
|
297
294
|
|
298
|
-
it "
|
295
|
+
it "returns nil if object is hidden" do
|
299
296
|
yard = CodeObjects::ModuleObject.new(:root, :YARD)
|
300
297
|
|
301
|
-
|
302
|
-
|
303
|
-
|
298
|
+
allow(self).to receive(:serializer).and_return(Serializers::FileSystemSerializer.new)
|
299
|
+
allow(self).to receive(:object).and_return Registry.root
|
300
|
+
allow(self).to receive(:options).and_return OpenStruct.new(:verifier => Verifier.new('false'))
|
304
301
|
|
305
|
-
url_for(yard).
|
302
|
+
expect(url_for(yard)).to be nil
|
306
303
|
end
|
307
304
|
|
308
|
-
it "
|
309
|
-
|
310
|
-
|
311
|
-
url_for(P("Mod::Class#meth")).
|
305
|
+
it "returns nil if serializer does not implement #serialized_path" do
|
306
|
+
allow(self).to receive(:serializer).and_return Serializers::Base.new
|
307
|
+
allow(self).to receive(:object).and_return Registry.root
|
308
|
+
expect(url_for(P("Mod::Class#meth"))).to be nil
|
312
309
|
end
|
313
310
|
|
314
|
-
it "
|
315
|
-
|
316
|
-
|
311
|
+
it "links to a path/file for a namespace object" do
|
312
|
+
allow(self).to receive(:serializer).and_return Serializers::FileSystemSerializer.new
|
313
|
+
allow(self).to receive(:object).and_return Registry.root
|
317
314
|
|
318
315
|
yard = CodeObjects::ModuleObject.new(:root, :YARD)
|
319
|
-
url_for(yard).
|
316
|
+
expect(url_for(yard)).to eq 'YARD.html'
|
320
317
|
end
|
321
318
|
|
322
|
-
it "
|
323
|
-
|
324
|
-
|
319
|
+
it "links to the object's namespace path/file and use the object as the anchor" do
|
320
|
+
allow(self).to receive(:serializer).and_return Serializers::FileSystemSerializer.new
|
321
|
+
allow(self).to receive(:object).and_return Registry.root
|
325
322
|
|
326
323
|
yard = CodeObjects::ModuleObject.new(:root, :YARD)
|
327
324
|
meth = CodeObjects::MethodObject.new(yard, :meth)
|
328
|
-
url_for(meth).
|
325
|
+
expect(url_for(meth)).to eq 'YARD.html#meth-instance_method'
|
329
326
|
end
|
330
327
|
|
331
|
-
it "
|
328
|
+
it "properly urlencodes methods with punctuation in links" do
|
332
329
|
obj = CodeObjects::MethodObject.new(nil, :/)
|
333
|
-
serializer =
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
url_for(obj).should == "#%2F-instance_method"
|
330
|
+
serializer = double(:serializer, :serialized_path => "file.html")
|
331
|
+
allow(self).to receive(:serializer).and_return serializer
|
332
|
+
allow(self).to receive(:object).and_return obj
|
333
|
+
expect(url_for(obj)).to eq "#%2F-instance_method"
|
338
334
|
end
|
339
335
|
end
|
340
336
|
|
341
|
-
describe
|
342
|
-
it "
|
337
|
+
describe "#anchor_for" do
|
338
|
+
it "does not urlencode data when called directly" do
|
343
339
|
obj = CodeObjects::MethodObject.new(nil, :/)
|
344
|
-
anchor_for(obj).
|
340
|
+
expect(anchor_for(obj)).to eq "/-instance_method"
|
345
341
|
end
|
346
342
|
end
|
347
343
|
|
348
|
-
describe
|
344
|
+
describe "#resolve_links" do
|
349
345
|
def parse_link(link)
|
350
346
|
results = {}
|
351
347
|
link =~ /<a (.+?)>(.+?)<\/a>/m
|
@@ -356,119 +352,119 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
356
352
|
results
|
357
353
|
end
|
358
354
|
|
359
|
-
it "
|
355
|
+
it "escapes {} syntax with backslash (\\{foo bar})" do
|
360
356
|
input = '\{foo bar} \{XYZ} \{file:FOO} $\{N-M}'
|
361
357
|
output = '{foo bar} {XYZ} {file:FOO} ${N-M}'
|
362
|
-
resolve_links(input).
|
358
|
+
expect(resolve_links(input)).to eq output
|
363
359
|
end
|
364
360
|
|
365
|
-
it "
|
361
|
+
it "escapes {} syntax with ! (!{foo bar})" do
|
366
362
|
input = '!{foo bar} !{XYZ} !{file:FOO} $!{N-M}'
|
367
363
|
output = '{foo bar} {XYZ} {file:FOO} ${N-M}'
|
368
|
-
resolve_links(input).
|
364
|
+
expect(resolve_links(input)).to eq output
|
369
365
|
end
|
370
366
|
|
371
|
-
it "
|
372
|
-
|
373
|
-
|
367
|
+
it "links static files with file: prefix" do
|
368
|
+
allow(self).to receive(:serializer).and_return Serializers::FileSystemSerializer.new
|
369
|
+
allow(self).to receive(:object).and_return Registry.root
|
374
370
|
|
375
|
-
parse_link(resolve_links("{file:TEST.txt#abc}")).
|
371
|
+
expect(parse_link(resolve_links("{file:TEST.txt#abc}"))).to eq({
|
376
372
|
:inner_text => "TEST",
|
377
373
|
:title => "TEST",
|
378
374
|
:href => "file.TEST.html#abc"
|
379
|
-
}
|
380
|
-
parse_link(resolve_links("{file:TEST.txt title}")).
|
375
|
+
})
|
376
|
+
expect(parse_link(resolve_links("{file:TEST.txt title}"))).to eq({
|
381
377
|
:inner_text => "title",
|
382
378
|
:title => "title",
|
383
379
|
:href => "file.TEST.html"
|
384
|
-
}
|
380
|
+
})
|
385
381
|
end
|
386
382
|
|
387
|
-
it "
|
388
|
-
parse_link(resolve_links("{http://example.com}")).
|
383
|
+
it "creates regular links with http:// or https:// prefixes" do
|
384
|
+
expect(parse_link(resolve_links("{http://example.com}"))).to eq({
|
389
385
|
:inner_text => "http://example.com",
|
390
386
|
:target => "_parent",
|
391
387
|
:href => "http://example.com",
|
392
388
|
:title => "http://example.com"
|
393
|
-
}
|
394
|
-
parse_link(resolve_links("{http://example.com title}")).
|
389
|
+
})
|
390
|
+
expect(parse_link(resolve_links("{http://example.com title}"))).to eq({
|
395
391
|
:inner_text => "title",
|
396
392
|
:target => "_parent",
|
397
393
|
:href => "http://example.com",
|
398
394
|
:title => "title"
|
399
|
-
}
|
395
|
+
})
|
400
396
|
end
|
401
397
|
|
402
|
-
it "
|
403
|
-
parse_link(resolve_links('{mailto:joanna@example.com}')).
|
398
|
+
it "creates mailto links with mailto: prefixes" do
|
399
|
+
expect(parse_link(resolve_links('{mailto:joanna@example.com}'))).to eq({
|
404
400
|
:inner_text => 'mailto:joanna@example.com',
|
405
401
|
:target => '_parent',
|
406
402
|
:href => 'mailto:joanna@example.com',
|
407
403
|
:title => 'mailto:joanna@example.com'
|
408
|
-
}
|
409
|
-
parse_link(resolve_links('{mailto:steve@example.com Steve}')).
|
404
|
+
})
|
405
|
+
expect(parse_link(resolve_links('{mailto:steve@example.com Steve}'))).to eq({
|
410
406
|
:inner_text => 'Steve',
|
411
407
|
:target => '_parent',
|
412
408
|
:href => 'mailto:steve@example.com',
|
413
409
|
:title => 'Steve'
|
414
|
-
}
|
410
|
+
})
|
415
411
|
end
|
416
412
|
|
417
|
-
it "
|
418
|
-
resolve_links("{|x|x == 1}").
|
413
|
+
it "ignores {links} that begin with |...|" do
|
414
|
+
expect(resolve_links("{|x|x == 1}")).to eq "{|x|x == 1}"
|
419
415
|
end
|
420
416
|
|
421
|
-
it "
|
422
|
-
|
423
|
-
resolve_links("{} {} {Foo Foo}").
|
417
|
+
it "gracefully ignores {} in links" do
|
418
|
+
allow(self).to receive(:linkify).with('Foo', 'Foo').and_return('FOO')
|
419
|
+
expect(resolve_links("{} {} {Foo Foo}")).to eq '{} {} FOO'
|
424
420
|
end
|
425
421
|
|
426
422
|
%w(tt code pre).each do |tag|
|
427
|
-
it "
|
423
|
+
it "ignores links in <#{tag}>" do
|
428
424
|
text = "<#{tag}>{Foo}</#{tag}>"
|
429
|
-
resolve_links(text).
|
425
|
+
expect(resolve_links(text)).to eq text
|
430
426
|
end
|
431
427
|
end
|
432
428
|
|
433
|
-
it "
|
434
|
-
|
429
|
+
it "resolves {Name}" do
|
430
|
+
expect(self).to receive(:link_file).with('TEST', nil, nil).and_return('')
|
435
431
|
resolve_links("{file:TEST}")
|
436
432
|
end
|
437
433
|
|
438
|
-
it "
|
439
|
-
|
434
|
+
it "resolves ({Name})" do
|
435
|
+
expect(self).to receive(:link_file).with('TEST', nil, nil).and_return('')
|
440
436
|
resolve_links("({file:TEST})")
|
441
437
|
end
|
442
438
|
|
443
|
-
it "
|
444
|
-
parse_link(resolve_links("{http://example.com foo\nbar}")).
|
439
|
+
it "resolves link with newline in title-part" do
|
440
|
+
expect(parse_link(resolve_links("{http://example.com foo\nbar}"))).to eq({
|
445
441
|
:inner_text => "foo bar",
|
446
442
|
:target => "_parent",
|
447
443
|
:href => "http://example.com",
|
448
444
|
:title => "foo bar"
|
449
|
-
}
|
445
|
+
})
|
450
446
|
end
|
451
447
|
|
452
|
-
it "
|
453
|
-
|
448
|
+
it "resolves links to methods whose names have been escaped" do
|
449
|
+
expect(self).to receive(:linkify).with('Object#<<', nil).and_return('')
|
454
450
|
resolve_links("{Object#<<}")
|
455
451
|
end
|
456
452
|
|
457
|
-
it "
|
453
|
+
it "warns about missing reference at right file location for object" do
|
458
454
|
YARD.parse_string <<-eof
|
459
455
|
# Comments here
|
460
456
|
# And a reference to {InvalidObject}
|
461
457
|
class MyObject; end
|
462
458
|
eof
|
463
|
-
logger =
|
464
|
-
logger.
|
465
|
-
logger.
|
466
|
-
|
467
|
-
|
459
|
+
logger = double(:log)
|
460
|
+
expect(logger).to receive(:warn).ordered.with("In file `(stdin)':2: Cannot resolve link to InvalidObject from text:")
|
461
|
+
expect(logger).to receive(:warn).ordered.with("...{InvalidObject}")
|
462
|
+
allow(self).to receive(:log).and_return(logger)
|
463
|
+
allow(self).to receive(:object).and_return(Registry.at('MyObject'))
|
468
464
|
resolve_links(object.docstring)
|
469
465
|
end
|
470
466
|
|
471
|
-
it "
|
467
|
+
it "shows ellipsis on either side if there is more on the line in a reference warning" do
|
472
468
|
YARD.parse_string <<-eof
|
473
469
|
# {InvalidObject1} beginning of line
|
474
470
|
# end of line {InvalidObject2}
|
@@ -476,27 +472,27 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
476
472
|
# {InvalidObject4}
|
477
473
|
class MyObject; end
|
478
474
|
eof
|
479
|
-
logger =
|
480
|
-
logger.
|
481
|
-
logger.
|
482
|
-
logger.
|
483
|
-
logger.
|
484
|
-
logger.
|
485
|
-
logger.
|
486
|
-
logger.
|
487
|
-
logger.
|
488
|
-
|
489
|
-
|
475
|
+
logger = double(:log)
|
476
|
+
expect(logger).to receive(:warn).ordered.with("In file `(stdin)':1: Cannot resolve link to InvalidObject1 from text:")
|
477
|
+
expect(logger).to receive(:warn).ordered.with("{InvalidObject1}...")
|
478
|
+
expect(logger).to receive(:warn).ordered.with("In file `(stdin)':2: Cannot resolve link to InvalidObject2 from text:")
|
479
|
+
expect(logger).to receive(:warn).ordered.with("...{InvalidObject2}")
|
480
|
+
expect(logger).to receive(:warn).ordered.with("In file `(stdin)':3: Cannot resolve link to InvalidObject3 from text:")
|
481
|
+
expect(logger).to receive(:warn).ordered.with("...{InvalidObject3}...")
|
482
|
+
expect(logger).to receive(:warn).ordered.with("In file `(stdin)':4: Cannot resolve link to InvalidObject4 from text:")
|
483
|
+
expect(logger).to receive(:warn).ordered.with("{InvalidObject4}")
|
484
|
+
allow(self).to receive(:log).and_return(logger)
|
485
|
+
allow(self).to receive(:object).and_return(Registry.at('MyObject'))
|
490
486
|
resolve_links(object.docstring)
|
491
487
|
end
|
492
488
|
|
493
|
-
it "
|
489
|
+
it "warns about missing reference for file template (no object)" do
|
494
490
|
@file = CodeObjects::ExtraFileObject.new('myfile.txt', '')
|
495
|
-
logger =
|
496
|
-
logger.
|
497
|
-
logger.
|
498
|
-
|
499
|
-
|
491
|
+
logger = double(:log)
|
492
|
+
expect(logger).to receive(:warn).ordered.with("In file `myfile.txt':3: Cannot resolve link to InvalidObject from text:")
|
493
|
+
expect(logger).to receive(:warn).ordered.with("...{InvalidObject Some Title}")
|
494
|
+
allow(self).to receive(:log).and_return(logger)
|
495
|
+
allow(self).to receive(:object).and_return(Registry.root)
|
500
496
|
resolve_links(<<-eof)
|
501
497
|
Hello world
|
502
498
|
This is a line
|
@@ -506,23 +502,24 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
506
502
|
end
|
507
503
|
end
|
508
504
|
|
509
|
-
describe
|
505
|
+
describe "#signature" do
|
510
506
|
before do
|
507
|
+
arrow = "⇒"
|
511
508
|
@results = {
|
512
|
-
:regular => "
|
513
|
-
:default_return => "
|
514
|
-
:no_default_return => "
|
515
|
-
:private_class => "
|
516
|
-
:single => "
|
517
|
-
:two_types => "
|
518
|
-
:two_types_multitag => "
|
519
|
-
:type_nil => "
|
520
|
-
:type_array => "
|
521
|
-
:multitype => "
|
522
|
-
:void => "
|
523
|
-
:hide_void => "
|
524
|
-
:block => "
|
525
|
-
:empty_overload =>
|
509
|
+
:regular => "#<strong>foo</strong> #{arrow} Object",
|
510
|
+
:default_return => "#<strong>foo</strong> #{arrow} Hello",
|
511
|
+
:no_default_return => "#<strong>foo</strong>",
|
512
|
+
:private_class => ".<strong>foo</strong> #{arrow} Object <span class=\"extras\">(private)</span>",
|
513
|
+
:single => "#<strong>foo</strong> #{arrow} String",
|
514
|
+
:two_types => "#<strong>foo</strong> #{arrow} String, Symbol",
|
515
|
+
:two_types_multitag => "#<strong>foo</strong> #{arrow} String, Symbol",
|
516
|
+
:type_nil => "#<strong>foo</strong> #{arrow} Type<sup>?</sup>",
|
517
|
+
:type_array => "#<strong>foo</strong> #{arrow} Type<sup>+</sup>",
|
518
|
+
:multitype => "#<strong>foo</strong> #{arrow} Type, ...",
|
519
|
+
:void => "#<strong>foo</strong> #{arrow} void",
|
520
|
+
:hide_void => "#<strong>foo</strong>",
|
521
|
+
:block => "#<strong>foo</strong> {|a, b, c| ... } #{arrow} Object",
|
522
|
+
:empty_overload => "#<strong>foobar</strong> #{arrow} String"
|
526
523
|
}
|
527
524
|
end
|
528
525
|
|
@@ -531,23 +528,23 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
531
528
|
|
532
529
|
it_should_behave_like "signature"
|
533
530
|
|
534
|
-
it "
|
531
|
+
it "links to regular method if overload name does not have the same method name" do
|
535
532
|
YARD.parse_string <<-eof
|
536
533
|
class Foo
|
537
534
|
# @overload bar(a, b, c)
|
538
535
|
def foo; end
|
539
536
|
end
|
540
537
|
eof
|
541
|
-
serializer =
|
542
|
-
serializer.
|
543
|
-
|
544
|
-
|
545
|
-
signature(Registry.at('Foo#foo').tag(:overload), true).
|
546
|
-
"<a href=\"#foo-instance_method\" title=\"#bar (instance method)\"
|
538
|
+
serializer = double(:serializer)
|
539
|
+
allow(serializer).to receive(:serialized_path).with(Registry.at('Foo')).and_return('')
|
540
|
+
allow(self).to receive(:serializer).and_return(serializer)
|
541
|
+
allow(self).to receive(:object).and_return(Registry.at('Foo'))
|
542
|
+
expect(signature(Registry.at('Foo#foo').tag(:overload), true)).to eq(
|
543
|
+
"<a href=\"#foo-instance_method\" title=\"#bar (instance method)\">#<strong>bar</strong>(a, b, c) </a>")
|
547
544
|
end
|
548
545
|
end
|
549
546
|
|
550
|
-
describe
|
547
|
+
describe "#html_syntax_highlight" do
|
551
548
|
subject do
|
552
549
|
obj = OpenStruct.new
|
553
550
|
obj.options = options
|
@@ -556,89 +553,89 @@ describe YARD::Templates::Helpers::HtmlHelper do
|
|
556
553
|
obj
|
557
554
|
end
|
558
555
|
|
559
|
-
it "
|
560
|
-
subject.html_syntax_highlight(nil).
|
556
|
+
it "returns empty string on nil input" do
|
557
|
+
expect(subject.html_syntax_highlight(nil)).to eq ''
|
561
558
|
end
|
562
559
|
|
563
|
-
it "
|
560
|
+
it "calls #html_syntax_highlight_ruby by default" do
|
564
561
|
Registry.root.source_type = nil
|
565
|
-
subject.
|
562
|
+
expect(subject).to receive(:html_syntax_highlight_ruby).with('def x; end')
|
566
563
|
subject.html_syntax_highlight('def x; end')
|
567
564
|
end
|
568
565
|
|
569
|
-
it "
|
566
|
+
it "calls #html_syntax_highlight_NAME if there's an object with a #source_type" do
|
570
567
|
subject.object = OpenStruct.new(:source_type => :NAME)
|
571
|
-
subject.
|
572
|
-
subject.
|
573
|
-
subject.
|
574
|
-
|
575
|
-
'<pre class="code NAME"><code class="NAME">foobar</code></pre>'
|
568
|
+
expect(subject).to receive(:html_markup_html) { |text| text }
|
569
|
+
expect(subject).to receive(:html_syntax_highlight_NAME).and_return("foobar")
|
570
|
+
expect(subject.htmlify('<pre><code>def x; end</code></pre>', :html)).to eq(
|
571
|
+
'<pre class="code NAME"><code class="NAME">foobar</code></pre>')
|
576
572
|
end
|
577
573
|
|
578
|
-
it "
|
574
|
+
it "adds !!!LANG to className in outputted pre tag" do
|
579
575
|
subject.object = OpenStruct.new(:source_type => :LANG)
|
580
|
-
subject.
|
581
|
-
subject.
|
582
|
-
subject.
|
583
|
-
|
584
|
-
'<pre class="code LANG"><code class="LANG">foobar</code></pre>'
|
576
|
+
expect(subject).to receive(:html_markup_html) { |text| text }
|
577
|
+
expect(subject).to receive(:html_syntax_highlight_LANG).and_return("foobar")
|
578
|
+
expect(subject.htmlify("<pre><code>!!!LANG\ndef x; end</code></pre>", :html)).to eq(
|
579
|
+
'<pre class="code LANG"><code class="LANG">foobar</code></pre>')
|
585
580
|
end
|
586
581
|
|
587
|
-
it "
|
588
|
-
subject.
|
589
|
-
subject.
|
590
|
-
subject.html_syntax_highlight(<<-eof
|
582
|
+
it "calls html_syntax_highlight_NAME if source starts with !!!NAME" do
|
583
|
+
expect(subject).to receive(:html_syntax_highlight_NAME).and_return("foobar")
|
584
|
+
expect(subject.html_syntax_highlight(<<-eof
|
591
585
|
!!!NAME
|
592
586
|
def x; end
|
593
587
|
eof
|
594
|
-
).
|
588
|
+
)).to eq "foobar"
|
595
589
|
end
|
596
590
|
|
597
|
-
it "
|
591
|
+
it "does not highlight if highlight option is false" do
|
598
592
|
subject.options.highlight = false
|
599
|
-
subject.
|
600
|
-
subject.html_syntax_highlight('def x; end').
|
593
|
+
expect(subject).not_to receive(:html_syntax_highlight_ruby)
|
594
|
+
expect(subject.html_syntax_highlight('def x; end')).to eq 'def x; end'
|
601
595
|
end
|
602
596
|
|
603
|
-
it "
|
604
|
-
subject.
|
605
|
-
|
606
|
-
|
597
|
+
it "does not highlight if there is no highlight method specified by !!!NAME" do
|
598
|
+
def subject.respond_to?(method, include_all=false)
|
599
|
+
return false if method == 'html_syntax_highlight_NAME'
|
600
|
+
super
|
601
|
+
end
|
602
|
+
expect(subject).not_to receive(:html_syntax_highlight_NAME)
|
603
|
+
expect(subject.html_syntax_highlight("!!!NAME\ndef x; end")).to eq "def x; end"
|
607
604
|
end
|
608
605
|
|
609
|
-
it "
|
610
|
-
subject.
|
611
|
-
subject.htmlify('def x; end', :ruby).
|
606
|
+
it "highlights as ruby if htmlify(text, :ruby) is called" do
|
607
|
+
expect(subject).to receive(:html_syntax_highlight_ruby).with('def x; end').and_return('x')
|
608
|
+
expect(subject.htmlify('def x; end', :ruby)).to eq '<pre class="code ruby">x</pre>'
|
612
609
|
end
|
613
610
|
|
614
|
-
it "
|
615
|
-
subject.
|
611
|
+
it "does not prioritize object source type when called directly" do
|
612
|
+
expect(subject).to receive(:html_syntax_highlight_ruby).with('def x; end').and_return('x')
|
616
613
|
subject.object = OpenStruct.new(:source_type => :c)
|
617
|
-
subject.html_syntax_highlight("def x; end").
|
614
|
+
expect(subject.html_syntax_highlight("def x; end")).to eq "x"
|
618
615
|
end
|
619
616
|
|
620
|
-
it "
|
621
|
-
subject.htmlify('<pre lang="foo"><code>{"foo" => 1}</code></pre>', :html).
|
622
|
-
'<pre class="code foo"><code class="foo">{"foo" => 1}</code></pre>'
|
617
|
+
it "doesn't escape code snippets twice" do
|
618
|
+
expect(subject.htmlify('<pre lang="foo"><code>{"foo" => 1}</code></pre>', :html)).to eq(
|
619
|
+
'<pre class="code foo"><code class="foo">{"foo" => 1}</code></pre>')
|
623
620
|
end
|
624
621
|
|
625
|
-
it "
|
626
|
-
subject.htmlify('<pre lang="foo"><code>x = 1</code></pre>', :html).
|
627
|
-
'<pre class="code foo"><code class="foo">x = 1</code></pre>'
|
622
|
+
it "highlights source when matching a pre lang= tag" do
|
623
|
+
expect(subject.htmlify('<pre lang="foo"><code>x = 1</code></pre>', :html)).to eq(
|
624
|
+
'<pre class="code foo"><code class="foo">x = 1</code></pre>')
|
628
625
|
end
|
629
626
|
|
630
|
-
it "
|
631
|
-
subject.htmlify('<pre><code class="foo">x = 1</code></pre>', :html).
|
632
|
-
'<pre class="code foo"><code class="foo">x = 1</code></pre>'
|
627
|
+
it "highlights source when matching a code class= tag" do
|
628
|
+
expect(subject.htmlify('<pre><code class="foo">x = 1</code></pre>', :html)).to eq(
|
629
|
+
'<pre class="code foo"><code class="foo">x = 1</code></pre>')
|
633
630
|
end
|
634
631
|
end
|
635
632
|
|
636
|
-
describe
|
637
|
-
it "
|
638
|
-
link_url("http://url.com").
|
639
|
-
link_url("https://url.com").
|
640
|
-
link_url("irc://url.com").
|
641
|
-
link_url("../not/scheme").
|
633
|
+
describe "#link_url" do
|
634
|
+
it "adds target if scheme is provided" do
|
635
|
+
expect(link_url("http://url.com")).to include(" target=\"_parent\"")
|
636
|
+
expect(link_url("https://url.com")).to include(" target=\"_parent\"")
|
637
|
+
expect(link_url("irc://url.com")).to include(" target=\"_parent\"")
|
638
|
+
expect(link_url("../not/scheme")).not_to include("target")
|
642
639
|
end
|
643
640
|
end
|
644
641
|
end
|