yard 0.9.24 → 0.9.25

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.

Files changed (223) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +37 -24
  3. data/CHANGELOG.md +18 -3
  4. data/README.md +96 -101
  5. data/Rakefile +2 -0
  6. data/lib/yard/cli/diff.rb +4 -1
  7. data/lib/yard/cli/server.rb +22 -13
  8. data/lib/yard/code_objects/proxy.rb +2 -1
  9. data/lib/yard/globals.rb +1 -1
  10. data/lib/yard/handlers/c/base.rb +164 -129
  11. data/lib/yard/parser/ruby/ruby_parser.rb +6 -4
  12. data/lib/yard/registry_store.rb +1 -1
  13. data/lib/yard/templates/helpers/html_helper.rb +10 -3
  14. data/lib/yard/templates/helpers/markup/rdoc_markup.rb +5 -4
  15. data/lib/yard/version.rb +1 -1
  16. data/tasks/update_error_map.rake +53 -0
  17. data/yard.gemspec +1 -1
  18. metadata +3 -207
  19. data/spec/cli/command_parser_spec.rb +0 -43
  20. data/spec/cli/command_spec.rb +0 -36
  21. data/spec/cli/config_spec.rb +0 -148
  22. data/spec/cli/diff_spec.rb +0 -254
  23. data/spec/cli/display_spec.rb +0 -30
  24. data/spec/cli/gems_spec.rb +0 -81
  25. data/spec/cli/graph_spec.rb +0 -18
  26. data/spec/cli/help_spec.rb +0 -22
  27. data/spec/cli/i18n_spec.rb +0 -107
  28. data/spec/cli/list_spec.rb +0 -8
  29. data/spec/cli/markup_types_spec.rb +0 -22
  30. data/spec/cli/server_spec.rb +0 -324
  31. data/spec/cli/stats_spec.rb +0 -96
  32. data/spec/cli/yard_on_yard_spec.rb +0 -38
  33. data/spec/cli/yardoc_spec.rb +0 -896
  34. data/spec/cli/yri_spec.rb +0 -101
  35. data/spec/code_objects/base_spec.rb +0 -485
  36. data/spec/code_objects/class_object_spec.rb +0 -226
  37. data/spec/code_objects/code_object_list_spec.rb +0 -36
  38. data/spec/code_objects/constants_spec.rb +0 -116
  39. data/spec/code_objects/extra_file_object_spec.rb +0 -161
  40. data/spec/code_objects/macro_object_spec.rb +0 -150
  41. data/spec/code_objects/method_object_spec.rb +0 -184
  42. data/spec/code_objects/module_object_spec.rb +0 -142
  43. data/spec/code_objects/namespace_mapper_spec.rb +0 -32
  44. data/spec/code_objects/namespace_object_spec.rb +0 -171
  45. data/spec/code_objects/proxy_spec.rb +0 -147
  46. data/spec/code_objects/spec_helper.rb +0 -3
  47. data/spec/config_spec.rb +0 -171
  48. data/spec/core_ext/array_spec.rb +0 -13
  49. data/spec/core_ext/file_spec.rb +0 -72
  50. data/spec/core_ext/hash_spec.rb +0 -14
  51. data/spec/core_ext/insertion_spec.rb +0 -37
  52. data/spec/core_ext/module_spec.rb +0 -9
  53. data/spec/core_ext/string_spec.rb +0 -42
  54. data/spec/core_ext/symbol_hash_spec.rb +0 -89
  55. data/spec/docstring_parser_spec.rb +0 -280
  56. data/spec/docstring_spec.rb +0 -373
  57. data/spec/handlers/alias_handler_spec.rb +0 -82
  58. data/spec/handlers/attribute_handler_spec.rb +0 -96
  59. data/spec/handlers/base_spec.rb +0 -216
  60. data/spec/handlers/c/alias_handler_spec.rb +0 -34
  61. data/spec/handlers/c/attribute_handler_spec.rb +0 -41
  62. data/spec/handlers/c/class_handler_spec.rb +0 -78
  63. data/spec/handlers/c/constant_handler_spec.rb +0 -71
  64. data/spec/handlers/c/init_handler_spec.rb +0 -48
  65. data/spec/handlers/c/method_handler_spec.rb +0 -327
  66. data/spec/handlers/c/mixin_handler_spec.rb +0 -44
  67. data/spec/handlers/c/module_handler_spec.rb +0 -71
  68. data/spec/handlers/c/override_comment_handler_spec.rb +0 -47
  69. data/spec/handlers/c/path_handler_spec.rb +0 -36
  70. data/spec/handlers/c/spec_helper.rb +0 -23
  71. data/spec/handlers/c/struct_handler_spec.rb +0 -16
  72. data/spec/handlers/class_condition_handler_spec.rb +0 -87
  73. data/spec/handlers/class_handler_spec.rb +0 -247
  74. data/spec/handlers/class_method_handler_shared_examples.rb +0 -133
  75. data/spec/handlers/class_variable_handler_spec.rb +0 -12
  76. data/spec/handlers/constant_handler_spec.rb +0 -112
  77. data/spec/handlers/decorator_handler_methods_spec.rb +0 -393
  78. data/spec/handlers/dsl_handler_spec.rb +0 -226
  79. data/spec/handlers/examples/alias_handler_001.rb.txt +0 -46
  80. data/spec/handlers/examples/attribute_handler_001.rb.txt +0 -32
  81. data/spec/handlers/examples/class_condition_handler_001.rb.txt +0 -69
  82. data/spec/handlers/examples/class_handler_001.rb.txt +0 -120
  83. data/spec/handlers/examples/class_variable_handler_001.rb.txt +0 -10
  84. data/spec/handlers/examples/constant_handler_001.rb.txt +0 -35
  85. data/spec/handlers/examples/dsl_handler_001.rb.txt +0 -156
  86. data/spec/handlers/examples/exception_handler_001.rb.txt +0 -59
  87. data/spec/handlers/examples/extend_handler_001.rb.txt +0 -19
  88. data/spec/handlers/examples/method_condition_handler_001.rb.txt +0 -10
  89. data/spec/handlers/examples/method_handler_001.rb.txt +0 -128
  90. data/spec/handlers/examples/mixin_handler_001.rb.txt +0 -40
  91. data/spec/handlers/examples/module_handler_001.rb.txt +0 -29
  92. data/spec/handlers/examples/private_constant_handler_001.rb.txt +0 -8
  93. data/spec/handlers/examples/process_handler_001.rb.txt +0 -11
  94. data/spec/handlers/examples/visibility_handler_001.rb.txt +0 -36
  95. data/spec/handlers/examples/yield_handler_001.rb.txt +0 -54
  96. data/spec/handlers/exception_handler_spec.rb +0 -49
  97. data/spec/handlers/extend_handler_spec.rb +0 -28
  98. data/spec/handlers/legacy_base_spec.rb +0 -128
  99. data/spec/handlers/method_condition_handler_spec.rb +0 -15
  100. data/spec/handlers/method_handler_spec.rb +0 -214
  101. data/spec/handlers/mixin_handler_spec.rb +0 -60
  102. data/spec/handlers/module_function_handler_spec.rb +0 -106
  103. data/spec/handlers/module_handler_spec.rb +0 -35
  104. data/spec/handlers/private_class_method_handler_spec.rb +0 -11
  105. data/spec/handlers/private_constant_handler_spec.rb +0 -25
  106. data/spec/handlers/processor_spec.rb +0 -35
  107. data/spec/handlers/public_class_method_handler_spec.rb +0 -11
  108. data/spec/handlers/ruby/base_spec.rb +0 -95
  109. data/spec/handlers/ruby/legacy/base_spec.rb +0 -84
  110. data/spec/handlers/spec_helper.rb +0 -33
  111. data/spec/handlers/visibility_handler_spec.rb +0 -44
  112. data/spec/handlers/yield_handler_spec.rb +0 -52
  113. data/spec/i18n/locale_spec.rb +0 -81
  114. data/spec/i18n/message_spec.rb +0 -52
  115. data/spec/i18n/messages_spec.rb +0 -67
  116. data/spec/i18n/pot_generator_spec.rb +0 -295
  117. data/spec/i18n/text_spec.rb +0 -184
  118. data/spec/logging_spec.rb +0 -44
  119. data/spec/options_spec.rb +0 -171
  120. data/spec/parser/base_spec.rb +0 -24
  121. data/spec/parser/c_parser_spec.rb +0 -236
  122. data/spec/parser/examples/array.c.txt +0 -6267
  123. data/spec/parser/examples/example1.rb.txt +0 -8
  124. data/spec/parser/examples/extrafile.c.txt +0 -8
  125. data/spec/parser/examples/file.c.txt +0 -28
  126. data/spec/parser/examples/multifile.c.txt +0 -22
  127. data/spec/parser/examples/namespace.cpp.txt +0 -68
  128. data/spec/parser/examples/override.c.txt +0 -424
  129. data/spec/parser/examples/parse_in_order_001.rb.txt +0 -2
  130. data/spec/parser/examples/parse_in_order_002.rb.txt +0 -2
  131. data/spec/parser/examples/tag_handler_001.rb.txt +0 -8
  132. data/spec/parser/ruby/ast_node_spec.rb +0 -33
  133. data/spec/parser/ruby/legacy/statement_list_spec.rb +0 -299
  134. data/spec/parser/ruby/legacy/token_list_spec.rb +0 -79
  135. data/spec/parser/ruby/ruby_parser_spec.rb +0 -520
  136. data/spec/parser/ruby/token_resolver_spec.rb +0 -165
  137. data/spec/parser/source_parser_spec.rb +0 -727
  138. data/spec/parser/tag_parsing_spec.rb +0 -17
  139. data/spec/rake/yardoc_task_spec.rb +0 -118
  140. data/spec/registry_resolver_spec.rb +0 -15
  141. data/spec/registry_spec.rb +0 -463
  142. data/spec/registry_store_spec.rb +0 -327
  143. data/spec/rubygems/doc_manager_spec.rb +0 -112
  144. data/spec/serializers/data/serialized_yardoc/checksums +0 -1
  145. data/spec/serializers/data/serialized_yardoc/objects/Foo.dat +0 -0
  146. data/spec/serializers/data/serialized_yardoc/objects/Foo/bar_i.dat +0 -0
  147. data/spec/serializers/data/serialized_yardoc/objects/Foo/baz_i.dat +0 -0
  148. data/spec/serializers/data/serialized_yardoc/objects/root.dat +0 -0
  149. data/spec/serializers/data/serialized_yardoc/proxy_types +0 -2
  150. data/spec/serializers/file_system_serializer_spec.rb +0 -145
  151. data/spec/serializers/spec_helper.rb +0 -2
  152. data/spec/serializers/yardoc_serializer_spec.rb +0 -90
  153. data/spec/server/adapter_spec.rb +0 -39
  154. data/spec/server/commands/base_spec.rb +0 -91
  155. data/spec/server/commands/library_command_spec.rb +0 -39
  156. data/spec/server/doc_server_helper_spec.rb +0 -72
  157. data/spec/server/doc_server_serializer_spec.rb +0 -60
  158. data/spec/server/rack_adapter_spec.rb +0 -21
  159. data/spec/server/router_spec.rb +0 -123
  160. data/spec/server/spec_helper.rb +0 -22
  161. data/spec/server/static_caching_spec.rb +0 -47
  162. data/spec/server/webrick_servlet_spec.rb +0 -20
  163. data/spec/server_spec.rb +0 -19
  164. data/spec/spec_helper.rb +0 -212
  165. data/spec/tags/default_factory_spec.rb +0 -168
  166. data/spec/tags/default_tag_spec.rb +0 -11
  167. data/spec/tags/directives_spec.rb +0 -463
  168. data/spec/tags/library_spec.rb +0 -48
  169. data/spec/tags/overload_tag_spec.rb +0 -53
  170. data/spec/tags/ref_tag_list_spec.rb +0 -53
  171. data/spec/tags/types_explainer_spec.rb +0 -203
  172. data/spec/templates/class_spec.rb +0 -45
  173. data/spec/templates/constant_spec.rb +0 -41
  174. data/spec/templates/engine_spec.rb +0 -131
  175. data/spec/templates/examples/class001.html +0 -308
  176. data/spec/templates/examples/class001.txt +0 -36
  177. data/spec/templates/examples/class002.html +0 -39
  178. data/spec/templates/examples/constant001.txt +0 -25
  179. data/spec/templates/examples/constant002.txt +0 -7
  180. data/spec/templates/examples/constant003.txt +0 -11
  181. data/spec/templates/examples/method001.html +0 -137
  182. data/spec/templates/examples/method001.txt +0 -35
  183. data/spec/templates/examples/method002.html +0 -91
  184. data/spec/templates/examples/method002.txt +0 -20
  185. data/spec/templates/examples/method003.html +0 -165
  186. data/spec/templates/examples/method003.txt +0 -45
  187. data/spec/templates/examples/method004.html +0 -48
  188. data/spec/templates/examples/method004.txt +0 -10
  189. data/spec/templates/examples/method005.html +0 -105
  190. data/spec/templates/examples/method005.txt +0 -33
  191. data/spec/templates/examples/method006.html +0 -108
  192. data/spec/templates/examples/method006.txt +0 -20
  193. data/spec/templates/examples/module001.dot +0 -33
  194. data/spec/templates/examples/module001.html +0 -833
  195. data/spec/templates/examples/module001.txt +0 -33
  196. data/spec/templates/examples/module002.html +0 -341
  197. data/spec/templates/examples/module003.html +0 -202
  198. data/spec/templates/examples/module004.html +0 -394
  199. data/spec/templates/examples/module005.html +0 -82
  200. data/spec/templates/examples/tag001.txt +0 -82
  201. data/spec/templates/helpers/base_helper_spec.rb +0 -171
  202. data/spec/templates/helpers/html_helper_spec.rb +0 -666
  203. data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +0 -65
  204. data/spec/templates/helpers/markup/rdoc_markup_spec.rb +0 -84
  205. data/spec/templates/helpers/markup_helper_spec.rb +0 -136
  206. data/spec/templates/helpers/method_helper_spec.rb +0 -107
  207. data/spec/templates/helpers/module_helper_spec.rb +0 -35
  208. data/spec/templates/helpers/shared_signature_examples.rb +0 -126
  209. data/spec/templates/helpers/text_helper_spec.rb +0 -65
  210. data/spec/templates/markup_processor_integrations/asciidoctor_spec.rb +0 -60
  211. data/spec/templates/markup_processor_integrations/integration_spec_helper.rb +0 -50
  212. data/spec/templates/markup_processor_integrations/rdoc_markdown_spec.rb +0 -48
  213. data/spec/templates/markup_processor_integrations/rdoc_spec.rb +0 -39
  214. data/spec/templates/markup_processor_integrations/redcarpet_spec.rb +0 -64
  215. data/spec/templates/markup_processor_integrations/redcloth_spec.rb +0 -64
  216. data/spec/templates/method_spec.rb +0 -118
  217. data/spec/templates/module_spec.rb +0 -203
  218. data/spec/templates/onefile_spec.rb +0 -66
  219. data/spec/templates/section_spec.rb +0 -144
  220. data/spec/templates/spec_helper.rb +0 -76
  221. data/spec/templates/tag_spec.rb +0 -52
  222. data/spec/templates/template_spec.rb +0 -410
  223. 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 &amp;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>&lt;code&gt;</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 &lt;+.")).to eq "Some <tt>typewriter text &lt;</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 ":&#39;&#39;"
103
- expect(format_constant(bar)).to eq ':BAR'
104
- expect(format_constant(baz)).to eq ":&#39;B+z&#39;"
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