yard 0.9.23 → 0.9.27
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/.dockerignore +0 -0
- data/.gitattributes +4 -0
- data/.github/FUNDING.yml +3 -0
- data/.github/ISSUE_TEMPLATE.md +6 -6
- data/.github/PULL_REQUEST_TEMPLATE.md +5 -5
- data/.github/workflows/ci.yml +30 -0
- data/.github/workflows/gem.yml +19 -0
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/.rubocop.yml +37 -24
- data/.yardopts +0 -0
- data/.yardopts_guide +0 -0
- data/.yardopts_i18n +0 -0
- data/CHANGELOG.md +50 -4
- data/CONTRIBUTING.md +2 -2
- data/Gemfile +5 -3
- data/README.md +97 -102
- data/Rakefile +2 -3
- data/lib/yard/cli/diff.rb +4 -1
- data/lib/yard/cli/server.rb +22 -13
- data/lib/yard/cli/stats.rb +2 -0
- data/lib/yard/cli/yardoc.rb +2 -1
- data/lib/yard/code_objects/method_object.rb +1 -1
- data/lib/yard/code_objects/namespace_mapper.rb +30 -3
- data/lib/yard/code_objects/proxy.rb +2 -1
- data/lib/yard/globals.rb +1 -1
- data/lib/yard/handlers/c/base.rb +35 -0
- data/lib/yard/handlers/ruby/method_handler.rb +1 -1
- data/lib/yard/handlers/ruby/mixin_handler.rb +7 -2
- data/lib/yard/handlers/ruby/module_function_handler.rb +15 -3
- data/lib/yard/parser/ruby/ast_node.rb +2 -2
- data/lib/yard/parser/ruby/ruby_parser.rb +7 -5
- data/lib/yard/parser/ruby/token_resolver.rb +3 -1
- data/lib/yard/parser/source_parser.rb +1 -1
- data/lib/yard/registry_resolver.rb +10 -24
- data/lib/yard/registry_store.rb +1 -1
- data/lib/yard/serializers/yardoc_serializer.rb +1 -1
- data/lib/yard/server/commands/base.rb +2 -2
- data/lib/yard/server/commands/library_command.rb +1 -1
- data/lib/yard/tags/directives.rb +10 -1
- data/lib/yard/templates/helpers/html_helper.rb +15 -5
- data/lib/yard/templates/helpers/markup/rdoc_markup.rb +5 -4
- data/lib/yard/templates/helpers/markup_helper.rb +2 -1
- data/lib/yard/templates/section.rb +1 -3
- data/lib/yard/version.rb +1 -1
- data/lib/yard.rb +3 -0
- data/samus.json +15 -46
- data/tasks/prepare_tag.rake +45 -0
- data/tasks/update_error_map.rake +53 -0
- data/templates/default/fulldoc/html/css/style.css +1 -0
- data/yard.gemspec +3 -2
- metadata +23 -207
- data/.travis.yml +0 -52
- data/spec/cli/command_parser_spec.rb +0 -43
- data/spec/cli/command_spec.rb +0 -36
- data/spec/cli/config_spec.rb +0 -148
- data/spec/cli/diff_spec.rb +0 -254
- data/spec/cli/display_spec.rb +0 -30
- data/spec/cli/gems_spec.rb +0 -81
- data/spec/cli/graph_spec.rb +0 -18
- data/spec/cli/help_spec.rb +0 -22
- data/spec/cli/i18n_spec.rb +0 -107
- data/spec/cli/list_spec.rb +0 -8
- data/spec/cli/markup_types_spec.rb +0 -22
- data/spec/cli/server_spec.rb +0 -324
- data/spec/cli/stats_spec.rb +0 -96
- data/spec/cli/yard_on_yard_spec.rb +0 -38
- data/spec/cli/yardoc_spec.rb +0 -896
- data/spec/cli/yri_spec.rb +0 -101
- data/spec/code_objects/base_spec.rb +0 -485
- data/spec/code_objects/class_object_spec.rb +0 -226
- data/spec/code_objects/code_object_list_spec.rb +0 -36
- data/spec/code_objects/constants_spec.rb +0 -116
- data/spec/code_objects/extra_file_object_spec.rb +0 -161
- data/spec/code_objects/macro_object_spec.rb +0 -150
- data/spec/code_objects/method_object_spec.rb +0 -184
- data/spec/code_objects/module_object_spec.rb +0 -142
- data/spec/code_objects/namespace_object_spec.rb +0 -171
- data/spec/code_objects/proxy_spec.rb +0 -147
- data/spec/code_objects/spec_helper.rb +0 -3
- data/spec/config_spec.rb +0 -171
- data/spec/core_ext/array_spec.rb +0 -13
- data/spec/core_ext/file_spec.rb +0 -72
- data/spec/core_ext/hash_spec.rb +0 -14
- data/spec/core_ext/insertion_spec.rb +0 -37
- data/spec/core_ext/module_spec.rb +0 -9
- data/spec/core_ext/string_spec.rb +0 -42
- data/spec/core_ext/symbol_hash_spec.rb +0 -89
- data/spec/docstring_parser_spec.rb +0 -280
- data/spec/docstring_spec.rb +0 -373
- data/spec/handlers/alias_handler_spec.rb +0 -82
- data/spec/handlers/attribute_handler_spec.rb +0 -96
- data/spec/handlers/base_spec.rb +0 -216
- data/spec/handlers/c/alias_handler_spec.rb +0 -34
- data/spec/handlers/c/attribute_handler_spec.rb +0 -41
- data/spec/handlers/c/class_handler_spec.rb +0 -78
- data/spec/handlers/c/constant_handler_spec.rb +0 -71
- data/spec/handlers/c/init_handler_spec.rb +0 -48
- data/spec/handlers/c/method_handler_spec.rb +0 -327
- data/spec/handlers/c/mixin_handler_spec.rb +0 -44
- data/spec/handlers/c/module_handler_spec.rb +0 -71
- data/spec/handlers/c/override_comment_handler_spec.rb +0 -47
- data/spec/handlers/c/path_handler_spec.rb +0 -36
- data/spec/handlers/c/spec_helper.rb +0 -23
- data/spec/handlers/c/struct_handler_spec.rb +0 -16
- data/spec/handlers/class_condition_handler_spec.rb +0 -87
- data/spec/handlers/class_handler_spec.rb +0 -247
- data/spec/handlers/class_method_handler_shared_examples.rb +0 -133
- data/spec/handlers/class_variable_handler_spec.rb +0 -12
- data/spec/handlers/constant_handler_spec.rb +0 -112
- data/spec/handlers/decorator_handler_methods_spec.rb +0 -393
- data/spec/handlers/dsl_handler_spec.rb +0 -226
- data/spec/handlers/examples/alias_handler_001.rb.txt +0 -46
- data/spec/handlers/examples/attribute_handler_001.rb.txt +0 -32
- data/spec/handlers/examples/class_condition_handler_001.rb.txt +0 -69
- data/spec/handlers/examples/class_handler_001.rb.txt +0 -120
- data/spec/handlers/examples/class_variable_handler_001.rb.txt +0 -10
- data/spec/handlers/examples/constant_handler_001.rb.txt +0 -35
- data/spec/handlers/examples/dsl_handler_001.rb.txt +0 -156
- data/spec/handlers/examples/exception_handler_001.rb.txt +0 -59
- data/spec/handlers/examples/extend_handler_001.rb.txt +0 -19
- data/spec/handlers/examples/method_condition_handler_001.rb.txt +0 -10
- data/spec/handlers/examples/method_handler_001.rb.txt +0 -128
- data/spec/handlers/examples/mixin_handler_001.rb.txt +0 -40
- data/spec/handlers/examples/module_handler_001.rb.txt +0 -29
- data/spec/handlers/examples/private_constant_handler_001.rb.txt +0 -8
- data/spec/handlers/examples/process_handler_001.rb.txt +0 -11
- data/spec/handlers/examples/visibility_handler_001.rb.txt +0 -36
- data/spec/handlers/examples/yield_handler_001.rb.txt +0 -54
- data/spec/handlers/exception_handler_spec.rb +0 -49
- data/spec/handlers/extend_handler_spec.rb +0 -28
- data/spec/handlers/legacy_base_spec.rb +0 -128
- data/spec/handlers/method_condition_handler_spec.rb +0 -15
- data/spec/handlers/method_handler_spec.rb +0 -214
- data/spec/handlers/mixin_handler_spec.rb +0 -60
- data/spec/handlers/module_function_handler_spec.rb +0 -106
- data/spec/handlers/module_handler_spec.rb +0 -35
- data/spec/handlers/private_class_method_handler_spec.rb +0 -11
- data/spec/handlers/private_constant_handler_spec.rb +0 -25
- data/spec/handlers/processor_spec.rb +0 -35
- data/spec/handlers/public_class_method_handler_spec.rb +0 -11
- data/spec/handlers/ruby/base_spec.rb +0 -95
- data/spec/handlers/ruby/legacy/base_spec.rb +0 -84
- data/spec/handlers/spec_helper.rb +0 -33
- data/spec/handlers/visibility_handler_spec.rb +0 -44
- data/spec/handlers/yield_handler_spec.rb +0 -52
- data/spec/i18n/locale_spec.rb +0 -81
- data/spec/i18n/message_spec.rb +0 -52
- data/spec/i18n/messages_spec.rb +0 -67
- data/spec/i18n/pot_generator_spec.rb +0 -295
- data/spec/i18n/text_spec.rb +0 -184
- data/spec/logging_spec.rb +0 -44
- data/spec/options_spec.rb +0 -171
- data/spec/parser/base_spec.rb +0 -24
- data/spec/parser/c_parser_spec.rb +0 -236
- data/spec/parser/examples/array.c.txt +0 -6267
- data/spec/parser/examples/example1.rb.txt +0 -8
- data/spec/parser/examples/extrafile.c.txt +0 -8
- data/spec/parser/examples/file.c.txt +0 -28
- data/spec/parser/examples/multifile.c.txt +0 -22
- data/spec/parser/examples/namespace.cpp.txt +0 -68
- data/spec/parser/examples/override.c.txt +0 -424
- data/spec/parser/examples/parse_in_order_001.rb.txt +0 -2
- data/spec/parser/examples/parse_in_order_002.rb.txt +0 -2
- data/spec/parser/examples/tag_handler_001.rb.txt +0 -8
- data/spec/parser/ruby/ast_node_spec.rb +0 -33
- data/spec/parser/ruby/legacy/statement_list_spec.rb +0 -299
- data/spec/parser/ruby/legacy/token_list_spec.rb +0 -79
- data/spec/parser/ruby/ruby_parser_spec.rb +0 -508
- data/spec/parser/ruby/token_resolver_spec.rb +0 -165
- data/spec/parser/source_parser_spec.rb +0 -727
- data/spec/parser/tag_parsing_spec.rb +0 -17
- data/spec/rake/yardoc_task_spec.rb +0 -118
- data/spec/registry_spec.rb +0 -463
- data/spec/registry_store_spec.rb +0 -327
- data/spec/rubygems/doc_manager_spec.rb +0 -112
- data/spec/serializers/data/serialized_yardoc/checksums +0 -1
- data/spec/serializers/data/serialized_yardoc/objects/Foo/bar_i.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/Foo/baz_i.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/Foo.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/objects/root.dat +0 -0
- data/spec/serializers/data/serialized_yardoc/proxy_types +0 -2
- data/spec/serializers/file_system_serializer_spec.rb +0 -145
- data/spec/serializers/spec_helper.rb +0 -2
- data/spec/serializers/yardoc_serializer_spec.rb +0 -78
- data/spec/server/adapter_spec.rb +0 -39
- data/spec/server/commands/base_spec.rb +0 -91
- data/spec/server/commands/library_command_spec.rb +0 -39
- data/spec/server/doc_server_helper_spec.rb +0 -72
- data/spec/server/doc_server_serializer_spec.rb +0 -60
- data/spec/server/rack_adapter_spec.rb +0 -21
- data/spec/server/router_spec.rb +0 -123
- data/spec/server/spec_helper.rb +0 -22
- data/spec/server/static_caching_spec.rb +0 -47
- data/spec/server/webrick_servlet_spec.rb +0 -20
- data/spec/server_spec.rb +0 -19
- data/spec/spec_helper.rb +0 -212
- data/spec/tags/default_factory_spec.rb +0 -168
- data/spec/tags/default_tag_spec.rb +0 -11
- data/spec/tags/directives_spec.rb +0 -463
- data/spec/tags/library_spec.rb +0 -48
- data/spec/tags/overload_tag_spec.rb +0 -53
- data/spec/tags/ref_tag_list_spec.rb +0 -53
- data/spec/tags/types_explainer_spec.rb +0 -203
- data/spec/templates/class_spec.rb +0 -45
- data/spec/templates/constant_spec.rb +0 -41
- data/spec/templates/engine_spec.rb +0 -131
- data/spec/templates/examples/class001.html +0 -308
- data/spec/templates/examples/class001.txt +0 -36
- data/spec/templates/examples/class002.html +0 -39
- data/spec/templates/examples/constant001.txt +0 -25
- data/spec/templates/examples/constant002.txt +0 -7
- data/spec/templates/examples/constant003.txt +0 -11
- data/spec/templates/examples/method001.html +0 -137
- data/spec/templates/examples/method001.txt +0 -35
- data/spec/templates/examples/method002.html +0 -91
- data/spec/templates/examples/method002.txt +0 -20
- data/spec/templates/examples/method003.html +0 -165
- data/spec/templates/examples/method003.txt +0 -45
- data/spec/templates/examples/method004.html +0 -48
- data/spec/templates/examples/method004.txt +0 -10
- data/spec/templates/examples/method005.html +0 -105
- data/spec/templates/examples/method005.txt +0 -33
- data/spec/templates/examples/method006.html +0 -108
- data/spec/templates/examples/method006.txt +0 -20
- data/spec/templates/examples/module001.dot +0 -33
- data/spec/templates/examples/module001.html +0 -833
- data/spec/templates/examples/module001.txt +0 -33
- data/spec/templates/examples/module002.html +0 -341
- data/spec/templates/examples/module003.html +0 -202
- data/spec/templates/examples/module004.html +0 -394
- data/spec/templates/examples/module005.html +0 -82
- data/spec/templates/examples/tag001.txt +0 -82
- data/spec/templates/helpers/base_helper_spec.rb +0 -171
- data/spec/templates/helpers/html_helper_spec.rb +0 -687
- data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +0 -65
- data/spec/templates/helpers/markup/rdoc_markup_spec.rb +0 -84
- data/spec/templates/helpers/markup_helper_spec.rb +0 -136
- data/spec/templates/helpers/method_helper_spec.rb +0 -107
- data/spec/templates/helpers/module_helper_spec.rb +0 -35
- data/spec/templates/helpers/shared_signature_examples.rb +0 -126
- data/spec/templates/helpers/text_helper_spec.rb +0 -65
- data/spec/templates/markup_processor_integrations/asciidoctor_spec.rb +0 -60
- data/spec/templates/markup_processor_integrations/integration_spec_helper.rb +0 -46
- data/spec/templates/markup_processor_integrations/rdoc_markdown_spec.rb +0 -59
- data/spec/templates/markup_processor_integrations/rdoc_spec.rb +0 -39
- data/spec/templates/markup_processor_integrations/redcarpet_spec.rb +0 -59
- data/spec/templates/markup_processor_integrations/redcloth_spec.rb +0 -48
- data/spec/templates/method_spec.rb +0 -118
- data/spec/templates/module_spec.rb +0 -203
- data/spec/templates/onefile_spec.rb +0 -66
- data/spec/templates/section_spec.rb +0 -144
- data/spec/templates/spec_helper.rb +0 -76
- data/spec/templates/tag_spec.rb +0 -52
- data/spec/templates/template_spec.rb +0 -410
- data/spec/verifier_spec.rb +0 -106
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe YARD::Templates::Helpers::HtmlSyntaxHighlightHelper do
|
4
|
-
include YARD::Templates::Helpers::HtmlHelper
|
5
|
-
include YARD::Templates::Helpers::HtmlSyntaxHighlightHelper
|
6
|
-
|
7
|
-
describe "#html_syntax_highlight" do
|
8
|
-
let(:object) { CodeObjects::NamespaceObject.new(:root, :YARD) }
|
9
|
-
|
10
|
-
before do
|
11
|
-
Registry.root.source_type = :ruby
|
12
|
-
end
|
13
|
-
|
14
|
-
it "does not highlight source if options.highlight is false" do
|
15
|
-
expect(self).to receive(:options).and_return(Options.new.update(:highlight => false))
|
16
|
-
expect(html_syntax_highlight("def x\nend")).to eq "def x\nend"
|
17
|
-
end
|
18
|
-
|
19
|
-
it "highlights source (legacy)" do
|
20
|
-
type = Parser::SourceParser.parser_type
|
21
|
-
Parser::SourceParser.parser_type = :ruby18
|
22
|
-
expect(self).to receive(:options).and_return(Options.new.update(:highlight => true))
|
23
|
-
expect = "<span class='rubyid_def def kw'>def</span><span class='rubyid_x identifier id'>x</span>
|
24
|
-
<span class='string val'>'x'</span><span class='plus op'>+</span>
|
25
|
-
<span class='regexp val'>/x/i</span><span class='rubyid_end end kw'>end</span>"
|
26
|
-
result = html_syntax_highlight("def x\n 'x' + /x/i\nend")
|
27
|
-
html_equals_string(result, expect)
|
28
|
-
Parser::SourceParser.parser_type = type
|
29
|
-
end
|
30
|
-
|
31
|
-
it "highlights source (ripper)" do
|
32
|
-
expect(self).to receive(:options).and_return(Options.new.update(:highlight => true))
|
33
|
-
Parser::SourceParser.parser_type = :ruby
|
34
|
-
expect = "<span class='kw'>def</span> <span class='id identifier rubyid_x'>x</span>
|
35
|
-
<span class='tstring'><span class='tstring_beg'>'</span>
|
36
|
-
<span class='tstring_content'>x</span><span class='tstring_end'>'</span>
|
37
|
-
</span> <span class='op'>+</span> <span class='tstring'>
|
38
|
-
<span class='regexp_beg'>/</span><span class='tstring_content'>x</span>
|
39
|
-
<span class='regexp_end'>/i</span></span>\n<span class='kw'>end</span>"
|
40
|
-
result = html_syntax_highlight("def x\n 'x' + /x/i\nend")
|
41
|
-
html_equals_string(result, expect)
|
42
|
-
end if HAVE_RIPPER
|
43
|
-
|
44
|
-
it "returns escaped unhighlighted source if a syntax error is found (ripper)" do
|
45
|
-
allow(self).to receive(:options).and_return(Options.new.update(:highlight => true))
|
46
|
-
expect(html_syntax_highlight("def &x; ... end")).to eq "def &x; ... end"
|
47
|
-
end if HAVE_RIPPER
|
48
|
-
|
49
|
-
it "returns escaped unhighlighted source if a syntax error is found (ripper)" do
|
50
|
-
allow(self).to receive(:options).and_return(Options.new.update(:highlight => true))
|
51
|
-
expect(html_syntax_highlight("$ git clone http://url")).to eq "$ git clone http://url"
|
52
|
-
end if HAVE_RIPPER
|
53
|
-
|
54
|
-
it "links constants/methods" do
|
55
|
-
other = CodeObjects::NamespaceObject.new(:root, :Other)
|
56
|
-
allow(self).to receive(:options).and_return(Options.new.update(:highlight => true))
|
57
|
-
allow(self).to receive(:run_verifier).with([other]).and_return([other])
|
58
|
-
allow(self).to receive(:link_object).with(other, "Other").and_return("LINK!")
|
59
|
-
result = html_syntax_highlight("def x; Other end")
|
60
|
-
html_equals_string(result, "<span class='kw'>def</span>
|
61
|
-
<span class='id identifier rubyid_x'>x</span><span class='semicolon'>;</span>
|
62
|
-
<span class='const'>LINK!</span> <span class='kw'>end</span>")
|
63
|
-
end if HAVE_RIPPER
|
64
|
-
end
|
65
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe YARD::Templates::Helpers::Markup::RDocMarkup do
|
4
|
-
describe "loading mechanism" do
|
5
|
-
before { @good_libs = [] }
|
6
|
-
|
7
|
-
def require(lib)
|
8
|
-
return true if @good_libs.include?(lib)
|
9
|
-
raise LoadError
|
10
|
-
end
|
11
|
-
|
12
|
-
def load_markup
|
13
|
-
require 'rdoc/markup'
|
14
|
-
require 'rdoc/markup/to_html'
|
15
|
-
return :RDoc2
|
16
|
-
rescue LoadError
|
17
|
-
begin
|
18
|
-
require 'rdoc/markup/simple_markup'
|
19
|
-
require 'rdoc/markup/simple_markup/to_html'
|
20
|
-
return :RDoc1
|
21
|
-
rescue LoadError
|
22
|
-
raise NameError, "could not load RDocMarkup (rdoc is not installed)"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
it "loads RDoc2.x if rdoc/markup is present" do
|
27
|
-
@good_libs += ['rdoc/markup', 'rdoc/markup/to_html']
|
28
|
-
expect(load_markup).to eq :RDoc2
|
29
|
-
end
|
30
|
-
|
31
|
-
it "fails on RDoc2.x if rdoc/markup/to_html is not present" do
|
32
|
-
@good_libs += ['rdoc/markup']
|
33
|
-
expect { load_markup }.to raise_error(NameError)
|
34
|
-
end
|
35
|
-
|
36
|
-
it "loads RDoc1.x if RDoc2 fails and rdoc/markup/simple_markup is present" do
|
37
|
-
@good_libs += ['rdoc/markup/simple_markup', 'rdoc/markup/simple_markup/to_html']
|
38
|
-
expect(load_markup).to eq :RDoc1
|
39
|
-
end
|
40
|
-
|
41
|
-
it "raises an error on loading if neither lib is present" do
|
42
|
-
expect { load_markup }.to raise_error(NameError)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "#to_html" do
|
47
|
-
def to_html(text)
|
48
|
-
html = YARD::Templates::Helpers::Markup::RDocMarkup.new(text).to_html
|
49
|
-
html.strip.gsub(/\r?\n/, '')
|
50
|
-
end
|
51
|
-
|
52
|
-
it "handles typewriter text" do
|
53
|
-
expect(to_html('Hello +<code>+')).to eq '<p>Hello <tt><code></tt></p>'
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "#fix_typewriter" do
|
58
|
-
def fix_typewriter(text)
|
59
|
-
YARD::Templates::Helpers::Markup::RDocMarkup.new('').send(:fix_typewriter, text)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "converts +text+ to <tt>text</tt>" do
|
63
|
-
expect(fix_typewriter("Some +typewriter text <+.")).to eq "Some <tt>typewriter text <</tt>."
|
64
|
-
expect(fix_typewriter("Not +typewriter text.")).to eq "Not +typewriter text."
|
65
|
-
expect(fix_typewriter("Alternating +type writer+ text +here+.")).to eq "Alternating <tt>type writer</tt> text <tt>here</tt>."
|
66
|
-
expect(fix_typewriter("No ++problem.")).to eq "No ++problem."
|
67
|
-
expect(fix_typewriter("Math + stuff +is ok+")).to eq "Math + stuff <tt>is ok</tt>"
|
68
|
-
expect(fix_typewriter("Hello +{Foo}+ World")).to eq "Hello <tt>{Foo}</tt> World"
|
69
|
-
end
|
70
|
-
|
71
|
-
it "does not apply to code blocks" do
|
72
|
-
expect(fix_typewriter("<code>Hello +hello+</code>")).to eq "<code>Hello +hello+</code>"
|
73
|
-
end
|
74
|
-
|
75
|
-
it "does not apply to HTML tag attributes" do
|
76
|
-
expect(fix_typewriter("<a href='http://foo.com/A+b+c'>A+b+c</a>")).to eq "<a href='http://foo.com/A+b+c'>A+b+c</a>"
|
77
|
-
expect(fix_typewriter("<foo class='foo+bar+baz'/>")).to eq "<foo class='foo+bar+baz'/>"
|
78
|
-
end
|
79
|
-
|
80
|
-
it "still applies inside of other tags" do
|
81
|
-
expect(fix_typewriter("<p>+foo+</p>")).to eq "<p><tt>foo</tt></p>"
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
@@ -1,136 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module YARD::Templates::Helpers::MarkupHelper
|
4
|
-
public :load_markup_provider, :markup_class, :markup_provider
|
5
|
-
end
|
6
|
-
|
7
|
-
class GeneratorMock
|
8
|
-
attr_accessor :options
|
9
|
-
include YARD::Templates::Helpers::MarkupHelper
|
10
|
-
def initialize(options = Templates::TemplateOptions.new)
|
11
|
-
self.options = options
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
RSpec.describe YARD::Templates::Helpers::MarkupHelper do
|
16
|
-
before do
|
17
|
-
YARD::Templates::Helpers::MarkupHelper.clear_markup_cache
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "#load_markup_provider" do
|
21
|
-
before do
|
22
|
-
allow(log).to receive(:error)
|
23
|
-
@gen = GeneratorMock.new
|
24
|
-
@gen.options.reset_defaults
|
25
|
-
end
|
26
|
-
|
27
|
-
it "exits on an invalid markup type" do
|
28
|
-
@gen.options.markup = :invalid
|
29
|
-
expect(@gen.load_markup_provider).to be false
|
30
|
-
end
|
31
|
-
|
32
|
-
it "fails when an invalid markup provider is specified" do
|
33
|
-
@gen.options.update(:markup => :markdown, :markup_provider => :invalid)
|
34
|
-
expect(@gen.load_markup_provider).to be false
|
35
|
-
expect(@gen.markup_class).to eq nil
|
36
|
-
end
|
37
|
-
|
38
|
-
it "loads RDocMarkup if rdoc is specified and it is installed" do
|
39
|
-
@gen.options.markup = :rdoc
|
40
|
-
expect(@gen.load_markup_provider).to be true
|
41
|
-
expect(@gen.markup_class).to eq YARD::Templates::Helpers::Markup::RDocMarkup
|
42
|
-
end
|
43
|
-
|
44
|
-
it "fails if RDoc cannot be loaded" do
|
45
|
-
@gen.options.markup = :rdoc
|
46
|
-
expect(@gen).to receive(:eval).with('::YARD::Templates::Helpers::Markup::RDocMarkup').and_raise(NameError)
|
47
|
-
expect(@gen.load_markup_provider).to be false
|
48
|
-
expect(@gen.markup_provider).to eq nil
|
49
|
-
end
|
50
|
-
|
51
|
-
it "searches through available markup providers for the markup type if none is set" do
|
52
|
-
expect(@gen).to receive(:eval).with('::RedcarpetCompat').and_return(double(:bluecloth))
|
53
|
-
expect(@gen).to receive(:require).with('redcarpet').and_return(true)
|
54
|
-
expect(@gen).not_to receive(:require).with('maruku')
|
55
|
-
@gen.options.markup = :markdown
|
56
|
-
# this only raises an exception because we mock out require to avoid
|
57
|
-
# loading any libraries but our implementation tries to return the library
|
58
|
-
# name as a constant
|
59
|
-
expect(@gen.load_markup_provider).to be true
|
60
|
-
expect(@gen.markup_provider).to eq :redcarpet
|
61
|
-
end
|
62
|
-
|
63
|
-
it "continues searching if some of the providers are unavailable" do
|
64
|
-
expect(@gen).to receive(:require).with('redcarpet').and_raise(LoadError)
|
65
|
-
expect(@gen).to receive(:require).with('rdiscount').and_raise(LoadError)
|
66
|
-
expect(@gen).to receive(:require).with('kramdown').and_raise(LoadError)
|
67
|
-
expect(@gen).to receive(:require).with('bluecloth').and_raise(LoadError)
|
68
|
-
expect(@gen).to receive(:require).with('maruku').and_raise(LoadError)
|
69
|
-
expect(@gen).to receive(:require).with('rpeg-markdown').and_return(true)
|
70
|
-
expect(@gen).to receive(:eval).with('::PEGMarkdown').and_return(true)
|
71
|
-
@gen.options.markup = :markdown
|
72
|
-
# this only raises an exception because we mock out require to avoid
|
73
|
-
# loading any libraries but our implementation tries to return the library
|
74
|
-
# name as a constant
|
75
|
-
@gen.load_markup_provider
|
76
|
-
expect(@gen.markup_provider).to eq :"rpeg-markdown"
|
77
|
-
end
|
78
|
-
|
79
|
-
it "overrides the search if `:markup_provider` is set in options" do
|
80
|
-
expect(@gen).to receive(:require).with('rdiscount').and_return(true)
|
81
|
-
expect(@gen).to receive(:eval).with('::RDiscount').and_return(true)
|
82
|
-
@gen.options.update(:markup => :markdown, :markup_provider => :rdiscount)
|
83
|
-
@gen.load_markup_provider
|
84
|
-
expect(@gen.markup_provider).to eq :rdiscount
|
85
|
-
end
|
86
|
-
|
87
|
-
it "fails if no provider is found" do
|
88
|
-
YARD::Templates::Helpers::MarkupHelper::MARKUP_PROVIDERS[:markdown].each do |p|
|
89
|
-
expect(@gen).to receive(:require).with(p[:lib].to_s).and_raise(LoadError)
|
90
|
-
end
|
91
|
-
@gen.options.markup = :markdown
|
92
|
-
expect(@gen.load_markup_provider).to be false
|
93
|
-
expect(@gen.markup_provider).to eq nil
|
94
|
-
end
|
95
|
-
|
96
|
-
it "fails if overridden provider is not found" do
|
97
|
-
expect(@gen).to receive(:require).with('rdiscount').and_raise(LoadError)
|
98
|
-
@gen.options.update(:markup => :markdown, :markup_provider => :rdiscount)
|
99
|
-
expect(@gen.load_markup_provider).to be false
|
100
|
-
expect(@gen.markup_provider).to eq nil
|
101
|
-
end
|
102
|
-
|
103
|
-
it "fails if the markup type is not found" do
|
104
|
-
expect(log).to receive(:error).with(/Invalid markup/)
|
105
|
-
@gen.options.markup = :xxx
|
106
|
-
expect(@gen.load_markup_provider).to be false
|
107
|
-
expect(@gen.markup_provider).to eq nil
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
describe "#markup_for_file" do
|
112
|
-
include YARD::Templates::Helpers::MarkupHelper
|
113
|
-
|
114
|
-
it "looks for a shebang line" do
|
115
|
-
expect(markup_for_file("#!text\ntext here", 'file.rdoc')).to eq :text
|
116
|
-
end
|
117
|
-
|
118
|
-
it "returns the default markup type if no shebang is found or no valid ext is found" do
|
119
|
-
allow(self).to receive(:options).and_return(Options.new.update(:markup => :default_type))
|
120
|
-
expect(markup_for_file('', 'filename')).to eq :default_type
|
121
|
-
end
|
122
|
-
|
123
|
-
it "looks for a file extension if no shebang is found" do
|
124
|
-
expect(markup_for_file('', 'filename.MD')).to eq :markdown
|
125
|
-
expect(markup_for_file('', 'filename.ORG')).to eq :org
|
126
|
-
end
|
127
|
-
|
128
|
-
Templates::Helpers::MarkupHelper::MARKUP_EXTENSIONS.each do |type, exts|
|
129
|
-
exts.each do |ext|
|
130
|
-
it "recognizes .#{ext} as #{type} markup type" do
|
131
|
-
expect(markup_for_file('', "filename.#{ext}")).to eq type
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
@@ -1,107 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe YARD::Templates::Helpers::MethodHelper do
|
4
|
-
include YARD::Templates::Helpers::BaseHelper
|
5
|
-
include YARD::Templates::Helpers::MethodHelper
|
6
|
-
|
7
|
-
describe "#format_args" do
|
8
|
-
it "displays keyword arguments" do
|
9
|
-
params = [['a:', '1'], ['b:', '2'], ['**kwargs', nil]]
|
10
|
-
YARD.parse_string 'def foo; end'
|
11
|
-
allow(Registry.at('#foo')).to receive(:parameters) { params }
|
12
|
-
expect(format_args(Registry.at('#foo'))).to eq '(a: 1, b: 2, **kwargs)'
|
13
|
-
end
|
14
|
-
|
15
|
-
it "does not show &blockarg if no @param tag and has @yield" do
|
16
|
-
YARD.parse_string <<-'eof'
|
17
|
-
# @yield blah
|
18
|
-
def foo(&block); end
|
19
|
-
eof
|
20
|
-
expect(format_args(Registry.at('#foo'))).to eq ''
|
21
|
-
end
|
22
|
-
|
23
|
-
it "does not show &blockarg if no @param tag and has @yieldparam" do
|
24
|
-
YARD.parse_string <<-'eof'
|
25
|
-
# @yieldparam blah test
|
26
|
-
def foo(&block); end
|
27
|
-
eof
|
28
|
-
expect(format_args(Registry.at('#foo'))).to eq ''
|
29
|
-
end
|
30
|
-
|
31
|
-
it "shows &blockarg if @param block is documented (even with @yield)" do
|
32
|
-
YARD.parse_string <<-'eof'
|
33
|
-
# @yield [a,b]
|
34
|
-
# @yieldparam a test
|
35
|
-
# @param block test
|
36
|
-
def foo(&block) end
|
37
|
-
eof
|
38
|
-
expect(format_args(Registry.at('#foo'))).to eq '(&block)'
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
describe "#format_block" do
|
43
|
-
before { YARD::Registry.clear }
|
44
|
-
|
45
|
-
it "shows block for method with yield" do
|
46
|
-
YARD.parse_string <<-'eof'
|
47
|
-
def foo; yield(a, b, c) end
|
48
|
-
eof
|
49
|
-
expect(format_block(Registry.at('#foo'))).to eq "{|a, b, c| ... }"
|
50
|
-
end
|
51
|
-
|
52
|
-
it "shows block for method with @yieldparam tags" do
|
53
|
-
YARD.parse_string <<-'eof'
|
54
|
-
# @yieldparam _self me!
|
55
|
-
def foo; end
|
56
|
-
eof
|
57
|
-
expect(format_block(Registry.at('#foo'))).to eq "{|_self| ... }"
|
58
|
-
end
|
59
|
-
|
60
|
-
it "shows block for method with @yield but no types" do
|
61
|
-
YARD.parse_string <<-'eof'
|
62
|
-
# @yield blah
|
63
|
-
# @yieldparam a
|
64
|
-
def foo; end
|
65
|
-
|
66
|
-
# @yield blah
|
67
|
-
def foo2; end
|
68
|
-
eof
|
69
|
-
expect(format_block(Registry.at('#foo'))).to eq "{|a| ... }"
|
70
|
-
expect(format_block(Registry.at('#foo2'))).to eq "{ ... }"
|
71
|
-
end
|
72
|
-
|
73
|
-
it "shows block for method with @yield and types" do
|
74
|
-
YARD.parse_string <<-'eof'
|
75
|
-
# @yield [a, b, c] blah
|
76
|
-
# @yieldparam a
|
77
|
-
def foo; end
|
78
|
-
eof
|
79
|
-
expect(format_block(Registry.at('#foo'))).to eq "{|a, b, c| ... }"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe "#format_constant" do
|
84
|
-
include YARD::Templates::Helpers::HtmlHelper
|
85
|
-
|
86
|
-
it "displays correctly constant values which are quoted symbols" do
|
87
|
-
YARD.parse_string %(
|
88
|
-
class TestFmtConst
|
89
|
-
Foo = :''
|
90
|
-
Bar = :BAR
|
91
|
-
Baz = :'B+z'
|
92
|
-
end
|
93
|
-
)
|
94
|
-
# html_syntax_highlight will be called by format_constant for
|
95
|
-
# Foo, Bar and Baz and in turn will enquire for options.highlight
|
96
|
-
expect(self).to receive(:options).exactly(3).times.and_return(
|
97
|
-
Options.new.update(:highlight => false)
|
98
|
-
)
|
99
|
-
foo, bar, baz = %w(Foo Bar Baz).map do |c|
|
100
|
-
Registry.at("TestFmtConst::#{c}").value
|
101
|
-
end
|
102
|
-
expect(format_constant(foo)).to eq ":''"
|
103
|
-
expect(format_constant(bar)).to eq ':BAR'
|
104
|
-
expect(format_constant(baz)).to eq ":'B+z'"
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
RSpec.describe YARD::Templates::Helpers::ModuleHelper do
|
4
|
-
include YARD::Templates::Helpers::BaseHelper
|
5
|
-
include YARD::Templates::Helpers::ModuleHelper
|
6
|
-
|
7
|
-
describe "#prune_method_listing" do
|
8
|
-
before { YARD::Registry.clear }
|
9
|
-
let(:options) { OpenStruct.new }
|
10
|
-
let(:object) { YARD::Registry.at("Foo#bar") }
|
11
|
-
let(:objects) { [object] }
|
12
|
-
|
13
|
-
it "filters aliases" do
|
14
|
-
YARD.parse_string "class Foo; def orig; end; alias bar orig end"
|
15
|
-
expect(prune_method_listing(objects)).to eq []
|
16
|
-
end
|
17
|
-
|
18
|
-
it "filters attributes" do
|
19
|
-
YARD.parse_string "class Foo; attr_accessor :bar end"
|
20
|
-
expect(prune_method_listing(objects)).to eq []
|
21
|
-
end
|
22
|
-
|
23
|
-
it "ignores methods if namespace object is filtered" do
|
24
|
-
YARD.parse_string <<-eof
|
25
|
-
# @author test
|
26
|
-
class Foo
|
27
|
-
def bar; end
|
28
|
-
end
|
29
|
-
eof
|
30
|
-
|
31
|
-
options.verifier = YARD::Verifier.new('@author.text != "test"')
|
32
|
-
expect(prune_method_listing(objects)).to eq []
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,126 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
RSpec.shared_examples_for "signature" do
|
3
|
-
before do
|
4
|
-
YARD::Registry.clear
|
5
|
-
@options = Templates::TemplateOptions.new
|
6
|
-
@options.reset_defaults
|
7
|
-
allow(self).to receive(:options).and_return(@options)
|
8
|
-
end
|
9
|
-
|
10
|
-
def trim(sig) sig.gsub(/\s+/, ' ') end
|
11
|
-
|
12
|
-
it "shows signature for regular instance method" do
|
13
|
-
YARD.parse_string "def foo; end"
|
14
|
-
expect(trim(signature(Registry.at('#foo')))).to eq @results[:regular]
|
15
|
-
end
|
16
|
-
|
17
|
-
it "allows default return type to be changed" do
|
18
|
-
@options.default_return = "Hello"
|
19
|
-
YARD.parse_string "def foo; end"
|
20
|
-
expect(trim(signature(Registry.at('#foo')))).to eq @results[:default_return]
|
21
|
-
end
|
22
|
-
|
23
|
-
it "allows default return type to be omitted" do
|
24
|
-
@options.default_return = ""
|
25
|
-
YARD.parse_string "def foo; end"
|
26
|
-
expect(trim(signature(Registry.at('#foo')))).to eq @results[:no_default_return]
|
27
|
-
end
|
28
|
-
|
29
|
-
it "shows signature for private class method" do
|
30
|
-
YARD.parse_string "class A; private; def self.foo; end end"
|
31
|
-
expect(trim(signature(Registry.at('A.foo')))).to eq @results[:private_class]
|
32
|
-
end
|
33
|
-
|
34
|
-
it "shows return type for single type" do
|
35
|
-
YARD.parse_string <<-'eof'
|
36
|
-
# @return [String]
|
37
|
-
def foo; end
|
38
|
-
eof
|
39
|
-
expect(trim(signature(Registry.at('#foo')))).to eq @results[:single]
|
40
|
-
end
|
41
|
-
|
42
|
-
it "shows return type for 2 types" do
|
43
|
-
YARD.parse_string <<-'eof'
|
44
|
-
# @return [String, Symbol]
|
45
|
-
def foo; end
|
46
|
-
eof
|
47
|
-
expect(trim(signature(Registry.at('#foo')))).to eq @results[:two_types]
|
48
|
-
end
|
49
|
-
|
50
|
-
it "shows return type for 2 types over multiple tags" do
|
51
|
-
YARD.parse_string <<-'eof'
|
52
|
-
# @return [String]
|
53
|
-
# @return [Symbol]
|
54
|
-
def foo; end
|
55
|
-
eof
|
56
|
-
expect(trim(signature(Registry.at('#foo')))).to eq @results[:two_types_multitag]
|
57
|
-
end
|
58
|
-
|
59
|
-
it "shows 'Type?' if return types are [Type, nil]" do
|
60
|
-
YARD.parse_string <<-'eof'
|
61
|
-
# @return [Type, nil]
|
62
|
-
def foo; end
|
63
|
-
eof
|
64
|
-
expect(trim(signature(Registry.at('#foo')))).to eq @results[:type_nil]
|
65
|
-
end
|
66
|
-
|
67
|
-
it "shows 'Type?' if return types are [Type, nil, nil] (extra nil)" do
|
68
|
-
YARD.parse_string <<-'eof'
|
69
|
-
# @return [Type, nil]
|
70
|
-
# @return [nil]
|
71
|
-
def foo; end
|
72
|
-
eof
|
73
|
-
expect(trim(signature(Registry.at('#foo')))).to eq @results[:type_nil]
|
74
|
-
end
|
75
|
-
|
76
|
-
it "shows 'Type+' if return types are [Type, Array<Type>]" do
|
77
|
-
YARD.parse_string <<-'eof'
|
78
|
-
# @return [Type, <Type>]
|
79
|
-
def foo; end
|
80
|
-
eof
|
81
|
-
expect(trim(signature(Registry.at('#foo')))).to eq @results[:type_array]
|
82
|
-
end
|
83
|
-
|
84
|
-
it "shows (Type, ...) for more than 2 return types" do
|
85
|
-
YARD.parse_string <<-'eof'
|
86
|
-
# @return [Type, <Type>]
|
87
|
-
# @return [AnotherType]
|
88
|
-
def foo; end
|
89
|
-
eof
|
90
|
-
expect(trim(signature(Registry.at('#foo')))).to eq @results[:multitype]
|
91
|
-
end
|
92
|
-
|
93
|
-
it "shows (void) for @return [void] by default" do
|
94
|
-
YARD.parse_string <<-'eof'
|
95
|
-
# @return [void]
|
96
|
-
def foo; end
|
97
|
-
eof
|
98
|
-
expect(trim(signature(Registry.at('#foo')))).to eq @results[:void]
|
99
|
-
end
|
100
|
-
|
101
|
-
it "does not show return for @return [void] if :hide_void_return is true" do
|
102
|
-
@options.hide_void_return = true
|
103
|
-
YARD.parse_string <<-'eof'
|
104
|
-
# @return [void]
|
105
|
-
def foo; end
|
106
|
-
eof
|
107
|
-
expect(trim(signature(Registry.at('#foo')))).to eq @results[:hide_void]
|
108
|
-
end
|
109
|
-
|
110
|
-
it "shows block for method with yield" do
|
111
|
-
YARD.parse_string <<-'eof'
|
112
|
-
def foo; yield(a, b, c) end
|
113
|
-
eof
|
114
|
-
expect(trim(signature(Registry.at('#foo')))).to eq @results[:block]
|
115
|
-
end
|
116
|
-
|
117
|
-
it "uses regular return tag if the @overload is empty" do
|
118
|
-
YARD.parse_string <<-'eof'
|
119
|
-
# @overload foobar
|
120
|
-
# Hello world
|
121
|
-
# @return [String]
|
122
|
-
def foo; end
|
123
|
-
eof
|
124
|
-
expect(trim(signature(Registry.at('#foo').tag(:overload)))).to eq @results[:empty_overload]
|
125
|
-
end
|
126
|
-
end
|
@@ -1,65 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
require File.dirname(__FILE__) + "/shared_signature_examples"
|
3
|
-
|
4
|
-
RSpec.describe YARD::Templates::Helpers::TextHelper do
|
5
|
-
include YARD::Templates::Helpers::BaseHelper
|
6
|
-
include YARD::Templates::Helpers::TextHelper
|
7
|
-
include YARD::Templates::Helpers::MethodHelper
|
8
|
-
|
9
|
-
describe "#signature" do
|
10
|
-
before do
|
11
|
-
@results = {
|
12
|
-
:regular => "root.foo -> Object",
|
13
|
-
:default_return => "root.foo -> Hello",
|
14
|
-
:no_default_return => "root.foo",
|
15
|
-
:private_class => "A.foo -> Object (private)",
|
16
|
-
:single => "root.foo -> String",
|
17
|
-
:two_types => "root.foo -> (String, Symbol)",
|
18
|
-
:two_types_multitag => "root.foo -> (String, Symbol)",
|
19
|
-
:type_nil => "root.foo -> Type?",
|
20
|
-
:type_array => "root.foo -> Type+",
|
21
|
-
:multitype => "root.foo -> (Type, ...)",
|
22
|
-
:void => "root.foo -> void",
|
23
|
-
:hide_void => "root.foo",
|
24
|
-
:block => "root.foo {|a, b, c| ... } -> Object",
|
25
|
-
:empty_overload => 'root.foobar -> String'
|
26
|
-
}
|
27
|
-
end
|
28
|
-
|
29
|
-
def signature(obj) super(obj).strip end
|
30
|
-
|
31
|
-
it_should_behave_like "signature"
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "#align_right" do
|
35
|
-
it "aligns text right" do
|
36
|
-
text = "Method: #some_method (SomeClass)"
|
37
|
-
expect(align_right(text)).to eq ' ' * 40 + text
|
38
|
-
end
|
39
|
-
|
40
|
-
it "truncates text that is longer than allowed width" do
|
41
|
-
text = "(Defined in: /home/user/.rip/.packages/some_gem-2460672e333ac07b9190ade88ec9a91c/long/path.rb)"
|
42
|
-
expect(align_right(text)).to eq ' ' + text[0, 68] + '...'
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "#h" do
|
47
|
-
let(:object) do
|
48
|
-
YARD::CodeObjects::MethodObject.new(:root, :foo, :instance).tap do |o|
|
49
|
-
o.docstring = "test"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
it "resolves links" do
|
54
|
-
expect(h("{include:#foo} 1 2 3").strip).to eq "test 1 2 3"
|
55
|
-
end
|
56
|
-
|
57
|
-
it "uses title when present" do
|
58
|
-
expect(h("{A b}").strip).to eq "b"
|
59
|
-
end
|
60
|
-
|
61
|
-
it "uses object name when no title is present" do
|
62
|
-
expect(h("{A}").strip).to eq "A"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
end
|
@@ -1,60 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require File.dirname(__FILE__) + '/integration_spec_helper'
|
4
|
-
|
5
|
-
RSpec.describe 'Asciidoctor integration' do
|
6
|
-
include_context 'shared helpers for markup processor integration specs'
|
7
|
-
let(:markup) { :asciidoc }
|
8
|
-
let(:markup_provider) { :asciidoctor }
|
9
|
-
|
10
|
-
let(:document) do
|
11
|
-
<<-ASCIIDOC
|
12
|
-
== Example code listings
|
13
|
-
|
14
|
-
Indented block of Ruby code:
|
15
|
-
|
16
|
-
x = 1
|
17
|
-
|
18
|
-
Fenced block of Ruby code:
|
19
|
-
|
20
|
-
-----
|
21
|
-
x = 2
|
22
|
-
-----
|
23
|
-
|
24
|
-
Fenced and annotated block of Ruby code:
|
25
|
-
|
26
|
-
[source,ruby]
|
27
|
-
-----
|
28
|
-
x = 3
|
29
|
-
-----
|
30
|
-
|
31
|
-
Fenced and annotated block of non-Ruby code:
|
32
|
-
|
33
|
-
[source,bash]
|
34
|
-
-----
|
35
|
-
x = 4
|
36
|
-
-----
|
37
|
-
|
38
|
-
ASCIIDOC
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'renders level 2 header' do
|
42
|
-
expect(rendered_document).to match(header_regexp(2, 'Example code listings'))
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'renders indented block of code, and applies Ruby syntax highlight' do
|
46
|
-
expect(rendered_document).to match(highlighted_ruby_regexp('x', '=', '1'))
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'renders fenced block of code, and applies Ruby syntax highlight' do
|
50
|
-
expect(rendered_document).to match(highlighted_ruby_regexp('x', '=', '2'))
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'renders fenced and annotated block of Ruby code, and applies syntax highlight' do
|
54
|
-
expect(rendered_document).to match(highlighted_ruby_regexp('x', '=', '3'))
|
55
|
-
end
|
56
|
-
|
57
|
-
it 'renders fenced and annotated block of non-Ruby code, and does not apply syntax highlight' do
|
58
|
-
expect(rendered_document).to match('x = 4')
|
59
|
-
end
|
60
|
-
end
|