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.

Files changed (257) hide show
  1. checksums.yaml +4 -4
  2. data/.dockerignore +0 -0
  3. data/.gitattributes +4 -0
  4. data/.github/FUNDING.yml +3 -0
  5. data/.github/ISSUE_TEMPLATE.md +6 -6
  6. data/.github/PULL_REQUEST_TEMPLATE.md +5 -5
  7. data/.github/workflows/ci.yml +30 -0
  8. data/.github/workflows/gem.yml +19 -0
  9. data/.gitignore +0 -0
  10. data/.rspec +0 -0
  11. data/.rubocop.yml +37 -24
  12. data/.yardopts +0 -0
  13. data/.yardopts_guide +0 -0
  14. data/.yardopts_i18n +0 -0
  15. data/CHANGELOG.md +50 -4
  16. data/CONTRIBUTING.md +2 -2
  17. data/Gemfile +5 -3
  18. data/README.md +97 -102
  19. data/Rakefile +2 -3
  20. data/lib/yard/cli/diff.rb +4 -1
  21. data/lib/yard/cli/server.rb +22 -13
  22. data/lib/yard/cli/stats.rb +2 -0
  23. data/lib/yard/cli/yardoc.rb +2 -1
  24. data/lib/yard/code_objects/method_object.rb +1 -1
  25. data/lib/yard/code_objects/namespace_mapper.rb +30 -3
  26. data/lib/yard/code_objects/proxy.rb +2 -1
  27. data/lib/yard/globals.rb +1 -1
  28. data/lib/yard/handlers/c/base.rb +35 -0
  29. data/lib/yard/handlers/ruby/method_handler.rb +1 -1
  30. data/lib/yard/handlers/ruby/mixin_handler.rb +7 -2
  31. data/lib/yard/handlers/ruby/module_function_handler.rb +15 -3
  32. data/lib/yard/parser/ruby/ast_node.rb +2 -2
  33. data/lib/yard/parser/ruby/ruby_parser.rb +7 -5
  34. data/lib/yard/parser/ruby/token_resolver.rb +3 -1
  35. data/lib/yard/parser/source_parser.rb +1 -1
  36. data/lib/yard/registry_resolver.rb +10 -24
  37. data/lib/yard/registry_store.rb +1 -1
  38. data/lib/yard/serializers/yardoc_serializer.rb +1 -1
  39. data/lib/yard/server/commands/base.rb +2 -2
  40. data/lib/yard/server/commands/library_command.rb +1 -1
  41. data/lib/yard/tags/directives.rb +10 -1
  42. data/lib/yard/templates/helpers/html_helper.rb +15 -5
  43. data/lib/yard/templates/helpers/markup/rdoc_markup.rb +5 -4
  44. data/lib/yard/templates/helpers/markup_helper.rb +2 -1
  45. data/lib/yard/templates/section.rb +1 -3
  46. data/lib/yard/version.rb +1 -1
  47. data/lib/yard.rb +3 -0
  48. data/samus.json +15 -46
  49. data/tasks/prepare_tag.rake +45 -0
  50. data/tasks/update_error_map.rake +53 -0
  51. data/templates/default/fulldoc/html/css/style.css +1 -0
  52. data/yard.gemspec +3 -2
  53. metadata +23 -207
  54. data/.travis.yml +0 -52
  55. data/spec/cli/command_parser_spec.rb +0 -43
  56. data/spec/cli/command_spec.rb +0 -36
  57. data/spec/cli/config_spec.rb +0 -148
  58. data/spec/cli/diff_spec.rb +0 -254
  59. data/spec/cli/display_spec.rb +0 -30
  60. data/spec/cli/gems_spec.rb +0 -81
  61. data/spec/cli/graph_spec.rb +0 -18
  62. data/spec/cli/help_spec.rb +0 -22
  63. data/spec/cli/i18n_spec.rb +0 -107
  64. data/spec/cli/list_spec.rb +0 -8
  65. data/spec/cli/markup_types_spec.rb +0 -22
  66. data/spec/cli/server_spec.rb +0 -324
  67. data/spec/cli/stats_spec.rb +0 -96
  68. data/spec/cli/yard_on_yard_spec.rb +0 -38
  69. data/spec/cli/yardoc_spec.rb +0 -896
  70. data/spec/cli/yri_spec.rb +0 -101
  71. data/spec/code_objects/base_spec.rb +0 -485
  72. data/spec/code_objects/class_object_spec.rb +0 -226
  73. data/spec/code_objects/code_object_list_spec.rb +0 -36
  74. data/spec/code_objects/constants_spec.rb +0 -116
  75. data/spec/code_objects/extra_file_object_spec.rb +0 -161
  76. data/spec/code_objects/macro_object_spec.rb +0 -150
  77. data/spec/code_objects/method_object_spec.rb +0 -184
  78. data/spec/code_objects/module_object_spec.rb +0 -142
  79. data/spec/code_objects/namespace_object_spec.rb +0 -171
  80. data/spec/code_objects/proxy_spec.rb +0 -147
  81. data/spec/code_objects/spec_helper.rb +0 -3
  82. data/spec/config_spec.rb +0 -171
  83. data/spec/core_ext/array_spec.rb +0 -13
  84. data/spec/core_ext/file_spec.rb +0 -72
  85. data/spec/core_ext/hash_spec.rb +0 -14
  86. data/spec/core_ext/insertion_spec.rb +0 -37
  87. data/spec/core_ext/module_spec.rb +0 -9
  88. data/spec/core_ext/string_spec.rb +0 -42
  89. data/spec/core_ext/symbol_hash_spec.rb +0 -89
  90. data/spec/docstring_parser_spec.rb +0 -280
  91. data/spec/docstring_spec.rb +0 -373
  92. data/spec/handlers/alias_handler_spec.rb +0 -82
  93. data/spec/handlers/attribute_handler_spec.rb +0 -96
  94. data/spec/handlers/base_spec.rb +0 -216
  95. data/spec/handlers/c/alias_handler_spec.rb +0 -34
  96. data/spec/handlers/c/attribute_handler_spec.rb +0 -41
  97. data/spec/handlers/c/class_handler_spec.rb +0 -78
  98. data/spec/handlers/c/constant_handler_spec.rb +0 -71
  99. data/spec/handlers/c/init_handler_spec.rb +0 -48
  100. data/spec/handlers/c/method_handler_spec.rb +0 -327
  101. data/spec/handlers/c/mixin_handler_spec.rb +0 -44
  102. data/spec/handlers/c/module_handler_spec.rb +0 -71
  103. data/spec/handlers/c/override_comment_handler_spec.rb +0 -47
  104. data/spec/handlers/c/path_handler_spec.rb +0 -36
  105. data/spec/handlers/c/spec_helper.rb +0 -23
  106. data/spec/handlers/c/struct_handler_spec.rb +0 -16
  107. data/spec/handlers/class_condition_handler_spec.rb +0 -87
  108. data/spec/handlers/class_handler_spec.rb +0 -247
  109. data/spec/handlers/class_method_handler_shared_examples.rb +0 -133
  110. data/spec/handlers/class_variable_handler_spec.rb +0 -12
  111. data/spec/handlers/constant_handler_spec.rb +0 -112
  112. data/spec/handlers/decorator_handler_methods_spec.rb +0 -393
  113. data/spec/handlers/dsl_handler_spec.rb +0 -226
  114. data/spec/handlers/examples/alias_handler_001.rb.txt +0 -46
  115. data/spec/handlers/examples/attribute_handler_001.rb.txt +0 -32
  116. data/spec/handlers/examples/class_condition_handler_001.rb.txt +0 -69
  117. data/spec/handlers/examples/class_handler_001.rb.txt +0 -120
  118. data/spec/handlers/examples/class_variable_handler_001.rb.txt +0 -10
  119. data/spec/handlers/examples/constant_handler_001.rb.txt +0 -35
  120. data/spec/handlers/examples/dsl_handler_001.rb.txt +0 -156
  121. data/spec/handlers/examples/exception_handler_001.rb.txt +0 -59
  122. data/spec/handlers/examples/extend_handler_001.rb.txt +0 -19
  123. data/spec/handlers/examples/method_condition_handler_001.rb.txt +0 -10
  124. data/spec/handlers/examples/method_handler_001.rb.txt +0 -128
  125. data/spec/handlers/examples/mixin_handler_001.rb.txt +0 -40
  126. data/spec/handlers/examples/module_handler_001.rb.txt +0 -29
  127. data/spec/handlers/examples/private_constant_handler_001.rb.txt +0 -8
  128. data/spec/handlers/examples/process_handler_001.rb.txt +0 -11
  129. data/spec/handlers/examples/visibility_handler_001.rb.txt +0 -36
  130. data/spec/handlers/examples/yield_handler_001.rb.txt +0 -54
  131. data/spec/handlers/exception_handler_spec.rb +0 -49
  132. data/spec/handlers/extend_handler_spec.rb +0 -28
  133. data/spec/handlers/legacy_base_spec.rb +0 -128
  134. data/spec/handlers/method_condition_handler_spec.rb +0 -15
  135. data/spec/handlers/method_handler_spec.rb +0 -214
  136. data/spec/handlers/mixin_handler_spec.rb +0 -60
  137. data/spec/handlers/module_function_handler_spec.rb +0 -106
  138. data/spec/handlers/module_handler_spec.rb +0 -35
  139. data/spec/handlers/private_class_method_handler_spec.rb +0 -11
  140. data/spec/handlers/private_constant_handler_spec.rb +0 -25
  141. data/spec/handlers/processor_spec.rb +0 -35
  142. data/spec/handlers/public_class_method_handler_spec.rb +0 -11
  143. data/spec/handlers/ruby/base_spec.rb +0 -95
  144. data/spec/handlers/ruby/legacy/base_spec.rb +0 -84
  145. data/spec/handlers/spec_helper.rb +0 -33
  146. data/spec/handlers/visibility_handler_spec.rb +0 -44
  147. data/spec/handlers/yield_handler_spec.rb +0 -52
  148. data/spec/i18n/locale_spec.rb +0 -81
  149. data/spec/i18n/message_spec.rb +0 -52
  150. data/spec/i18n/messages_spec.rb +0 -67
  151. data/spec/i18n/pot_generator_spec.rb +0 -295
  152. data/spec/i18n/text_spec.rb +0 -184
  153. data/spec/logging_spec.rb +0 -44
  154. data/spec/options_spec.rb +0 -171
  155. data/spec/parser/base_spec.rb +0 -24
  156. data/spec/parser/c_parser_spec.rb +0 -236
  157. data/spec/parser/examples/array.c.txt +0 -6267
  158. data/spec/parser/examples/example1.rb.txt +0 -8
  159. data/spec/parser/examples/extrafile.c.txt +0 -8
  160. data/spec/parser/examples/file.c.txt +0 -28
  161. data/spec/parser/examples/multifile.c.txt +0 -22
  162. data/spec/parser/examples/namespace.cpp.txt +0 -68
  163. data/spec/parser/examples/override.c.txt +0 -424
  164. data/spec/parser/examples/parse_in_order_001.rb.txt +0 -2
  165. data/spec/parser/examples/parse_in_order_002.rb.txt +0 -2
  166. data/spec/parser/examples/tag_handler_001.rb.txt +0 -8
  167. data/spec/parser/ruby/ast_node_spec.rb +0 -33
  168. data/spec/parser/ruby/legacy/statement_list_spec.rb +0 -299
  169. data/spec/parser/ruby/legacy/token_list_spec.rb +0 -79
  170. data/spec/parser/ruby/ruby_parser_spec.rb +0 -508
  171. data/spec/parser/ruby/token_resolver_spec.rb +0 -165
  172. data/spec/parser/source_parser_spec.rb +0 -727
  173. data/spec/parser/tag_parsing_spec.rb +0 -17
  174. data/spec/rake/yardoc_task_spec.rb +0 -118
  175. data/spec/registry_spec.rb +0 -463
  176. data/spec/registry_store_spec.rb +0 -327
  177. data/spec/rubygems/doc_manager_spec.rb +0 -112
  178. data/spec/serializers/data/serialized_yardoc/checksums +0 -1
  179. data/spec/serializers/data/serialized_yardoc/objects/Foo/bar_i.dat +0 -0
  180. data/spec/serializers/data/serialized_yardoc/objects/Foo/baz_i.dat +0 -0
  181. data/spec/serializers/data/serialized_yardoc/objects/Foo.dat +0 -0
  182. data/spec/serializers/data/serialized_yardoc/objects/root.dat +0 -0
  183. data/spec/serializers/data/serialized_yardoc/proxy_types +0 -2
  184. data/spec/serializers/file_system_serializer_spec.rb +0 -145
  185. data/spec/serializers/spec_helper.rb +0 -2
  186. data/spec/serializers/yardoc_serializer_spec.rb +0 -78
  187. data/spec/server/adapter_spec.rb +0 -39
  188. data/spec/server/commands/base_spec.rb +0 -91
  189. data/spec/server/commands/library_command_spec.rb +0 -39
  190. data/spec/server/doc_server_helper_spec.rb +0 -72
  191. data/spec/server/doc_server_serializer_spec.rb +0 -60
  192. data/spec/server/rack_adapter_spec.rb +0 -21
  193. data/spec/server/router_spec.rb +0 -123
  194. data/spec/server/spec_helper.rb +0 -22
  195. data/spec/server/static_caching_spec.rb +0 -47
  196. data/spec/server/webrick_servlet_spec.rb +0 -20
  197. data/spec/server_spec.rb +0 -19
  198. data/spec/spec_helper.rb +0 -212
  199. data/spec/tags/default_factory_spec.rb +0 -168
  200. data/spec/tags/default_tag_spec.rb +0 -11
  201. data/spec/tags/directives_spec.rb +0 -463
  202. data/spec/tags/library_spec.rb +0 -48
  203. data/spec/tags/overload_tag_spec.rb +0 -53
  204. data/spec/tags/ref_tag_list_spec.rb +0 -53
  205. data/spec/tags/types_explainer_spec.rb +0 -203
  206. data/spec/templates/class_spec.rb +0 -45
  207. data/spec/templates/constant_spec.rb +0 -41
  208. data/spec/templates/engine_spec.rb +0 -131
  209. data/spec/templates/examples/class001.html +0 -308
  210. data/spec/templates/examples/class001.txt +0 -36
  211. data/spec/templates/examples/class002.html +0 -39
  212. data/spec/templates/examples/constant001.txt +0 -25
  213. data/spec/templates/examples/constant002.txt +0 -7
  214. data/spec/templates/examples/constant003.txt +0 -11
  215. data/spec/templates/examples/method001.html +0 -137
  216. data/spec/templates/examples/method001.txt +0 -35
  217. data/spec/templates/examples/method002.html +0 -91
  218. data/spec/templates/examples/method002.txt +0 -20
  219. data/spec/templates/examples/method003.html +0 -165
  220. data/spec/templates/examples/method003.txt +0 -45
  221. data/spec/templates/examples/method004.html +0 -48
  222. data/spec/templates/examples/method004.txt +0 -10
  223. data/spec/templates/examples/method005.html +0 -105
  224. data/spec/templates/examples/method005.txt +0 -33
  225. data/spec/templates/examples/method006.html +0 -108
  226. data/spec/templates/examples/method006.txt +0 -20
  227. data/spec/templates/examples/module001.dot +0 -33
  228. data/spec/templates/examples/module001.html +0 -833
  229. data/spec/templates/examples/module001.txt +0 -33
  230. data/spec/templates/examples/module002.html +0 -341
  231. data/spec/templates/examples/module003.html +0 -202
  232. data/spec/templates/examples/module004.html +0 -394
  233. data/spec/templates/examples/module005.html +0 -82
  234. data/spec/templates/examples/tag001.txt +0 -82
  235. data/spec/templates/helpers/base_helper_spec.rb +0 -171
  236. data/spec/templates/helpers/html_helper_spec.rb +0 -687
  237. data/spec/templates/helpers/html_syntax_highlight_helper_spec.rb +0 -65
  238. data/spec/templates/helpers/markup/rdoc_markup_spec.rb +0 -84
  239. data/spec/templates/helpers/markup_helper_spec.rb +0 -136
  240. data/spec/templates/helpers/method_helper_spec.rb +0 -107
  241. data/spec/templates/helpers/module_helper_spec.rb +0 -35
  242. data/spec/templates/helpers/shared_signature_examples.rb +0 -126
  243. data/spec/templates/helpers/text_helper_spec.rb +0 -65
  244. data/spec/templates/markup_processor_integrations/asciidoctor_spec.rb +0 -60
  245. data/spec/templates/markup_processor_integrations/integration_spec_helper.rb +0 -46
  246. data/spec/templates/markup_processor_integrations/rdoc_markdown_spec.rb +0 -59
  247. data/spec/templates/markup_processor_integrations/rdoc_spec.rb +0 -39
  248. data/spec/templates/markup_processor_integrations/redcarpet_spec.rb +0 -59
  249. data/spec/templates/markup_processor_integrations/redcloth_spec.rb +0 -48
  250. data/spec/templates/method_spec.rb +0 -118
  251. data/spec/templates/module_spec.rb +0 -203
  252. data/spec/templates/onefile_spec.rb +0 -66
  253. data/spec/templates/section_spec.rb +0 -144
  254. data/spec/templates/spec_helper.rb +0 -76
  255. data/spec/templates/tag_spec.rb +0 -52
  256. data/spec/templates/template_spec.rb +0 -410
  257. data/spec/verifier_spec.rb +0 -106
@@ -1,226 +0,0 @@
1
- # frozen_string_literal: true
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- RSpec.describe YARD::CodeObjects::ClassObject do
5
- describe "#inheritance_tree" do
6
- before(:all) do
7
- Registry.clear
8
- @mixin = ModuleObject.new(:root, :SomeMixin)
9
- @mixin2 = ModuleObject.new(:root, :SomeMixin2)
10
- @mixin2.instance_mixins << @mixin
11
- @mixin3 = ModuleObject.new(:root, :SomeMixin3)
12
- @mixin4 = ModuleObject.new(:root, :SomeMixin4)
13
- @mixin2.instance_mixins << @mixin3
14
- @superyard = ClassObject.new(:root, :SuperYard)
15
- @superyard.superclass = P("String")
16
- @superyard.instance_mixins << @mixin2
17
- @superyard.class_mixins << @mixin4
18
- @yard = ClassObject.new(:root, :YARD)
19
- @yard.superclass = @superyard
20
- @yard.instance_mixins << @mixin
21
- end
22
-
23
- it "shows the proper inheritance tree" do
24
- expect(@yard.inheritance_tree).to eq [@yard, @superyard, P(:String)]
25
- end
26
-
27
- it "shows proper inheritance tree when mixins are included" do
28
- expect(@yard.inheritance_tree(true)).to eq [@yard, @mixin, @superyard, @mixin4, @mixin2, @mixin3, P(:String)]
29
- end
30
-
31
- it "does not modify the object's mixin list when mixins are included" do
32
- @class1 = ClassObject.new(:root, :A)
33
- @class2 = ClassObject.new(:root, :B)
34
- @class2.superclass = @class1
35
-
36
- @class2.inheritance_tree(true)
37
- expect(@class2.mixins).to eq []
38
- end
39
-
40
- it "lists class mixins in inheritance tree" do
41
- mod = ModuleObject.new(:root, :ClassMethods)
42
- klass = ClassObject.new(:root, :ReceivingClass)
43
- klass.class_mixins << mod
44
- expect(klass.inheritance_tree(true)).to eq [klass, mod]
45
- end
46
- end
47
-
48
- describe "#meths / #inherited_meths" do
49
- before(:all) do
50
- Registry.clear
51
-
52
- YARD.parse_string <<-eof
53
- class SuperYard < String
54
- def foo; end
55
- def foo2; end
56
- def bar; end
57
- def middle; end
58
- protected :foo2
59
- private
60
- def self.bar; end
61
- end
62
-
63
- class MiddleYard < SuperYard
64
- def middle; end
65
- end
66
-
67
- class YARD < MiddleYard
68
- def mymethod; end
69
- def bar; end
70
- end
71
-
72
- module IncludedYard
73
- def foo; end
74
- end
75
-
76
- class FinalYard < SuperYard
77
- include IncludedYard
78
- end
79
- eof
80
- end
81
-
82
- it "shows inherited methods by default" do
83
- meths = P(:YARD).meths
84
- expect(meths).to include(P("YARD#mymethod"))
85
- expect(meths).to include(P("SuperYard#foo"))
86
- expect(meths).to include(P("SuperYard#foo2"))
87
- expect(meths).to include(P("SuperYard.bar"))
88
- end
89
-
90
- it "allows :inherited to be set to false" do
91
- meths = P(:YARD).meths(:inherited => false)
92
- expect(meths).to include(P("YARD#mymethod"))
93
- expect(meths).not_to include(P("SuperYard#foo"))
94
- expect(meths).not_to include(P("SuperYard#foo2"))
95
- expect(meths).not_to include(P("SuperYard.bar"))
96
- end
97
-
98
- it "does not show overridden methods" do
99
- meths = P(:YARD).meths
100
- expect(meths).to include(P("YARD#bar"))
101
- expect(meths).not_to include(P("SuperYard#bar"))
102
-
103
- meths = P(:YARD).inherited_meths
104
- expect(meths).not_to include(P("YARD#bar"))
105
- expect(meths).not_to include(P("YARD#mymethod"))
106
- expect(meths).to include(P("SuperYard#foo"))
107
- expect(meths).to include(P("SuperYard#foo2"))
108
- expect(meths).to include(P("SuperYard.bar"))
109
- end
110
-
111
- it "does not show inherited methods overridden by other subclasses" do
112
- meths = P(:YARD).inherited_meths
113
- expect(meths).to include(P('MiddleYard#middle'))
114
- expect(meths).not_to include(P('SuperYard#middle'))
115
- end
116
-
117
- it "shows mixed in methods before superclass method" do
118
- meths = P(:FinalYard).meths
119
- expect(meths).to include(P('IncludedYard#foo'))
120
- expect(meths).not_to include(P('SuperYard#foo'))
121
- end
122
- end
123
-
124
- describe "#constants / #inherited_constants" do
125
- before(:all) do
126
- Registry.clear
127
-
128
- Parser::SourceParser.parse_string <<-eof
129
- class YARD
130
- CONST1 = 1
131
- CONST2 = "hello"
132
- CONST4 = 0
133
- end
134
-
135
- class SUPERYARD < YARD
136
- CONST4 = 5
137
- end
138
-
139
- class SubYard < SUPERYARD
140
- CONST2 = "hi"
141
- CONST3 = "foo"
142
- end
143
- eof
144
- end
145
-
146
- it "lists inherited constants by default" do
147
- consts = P(:SubYard).constants
148
- expect(consts).to include(P("YARD::CONST1"))
149
- expect(consts).to include(P("SubYard::CONST3"))
150
-
151
- consts = P(:SubYard).inherited_constants
152
- expect(consts).to include(P("YARD::CONST1"))
153
- expect(consts).not_to include(P("YARD::CONST2"))
154
- expect(consts).not_to include(P("SubYard::CONST2"))
155
- expect(consts).not_to include(P("SubYard::CONST3"))
156
- end
157
-
158
- it "does not list inherited constants if turned off" do
159
- consts = P(:SubYard).constants(:inherited => false)
160
- expect(consts).not_to include(P("YARD::CONST1"))
161
- expect(consts).to include(P("SubYard::CONST3"))
162
- end
163
-
164
- it "does not include an inherited constant if it is overridden by the object" do
165
- consts = P(:SubYard).constants
166
- expect(consts).to include(P("SubYard::CONST2"))
167
- expect(consts).not_to include(P("YARD::CONST2"))
168
- end
169
-
170
- it "does not include an inherited constant if it is overridden by another subclass" do
171
- consts = P(:SubYard).inherited_constants
172
- expect(consts).to include(P("SUPERYARD::CONST4"))
173
- expect(consts).not_to include(P("YARD::CONST4"))
174
- end
175
-
176
- it "does not set a superclass on BasicObject class" do
177
- o = ClassObject.new(:root, :BasicObject)
178
- expect(o.superclass).to be nil
179
- end
180
-
181
- it "sets superclass of Object to BasicObject" do
182
- o = ClassObject.new(:root, :Object)
183
- expect(o.superclass).to eq P(:BasicObject)
184
- end
185
-
186
- it "raises ArgumentError if superclass == self" do
187
- expect do
188
- ClassObject.new(:root, :Object) do |o|
189
- o.superclass = :Object
190
- end
191
- end.to raise_error(ArgumentError)
192
- end
193
-
194
- it "tells the world if it is an exception class" do
195
- o = ClassObject.new(:root, :MyClass)
196
- o2 = ClassObject.new(:root, :OtherClass)
197
- o2.superclass = :SystemCallError
198
- o3 = ClassObject.new(:root, :StandardError)
199
- o3.superclass = :Object
200
- ClassObject.new(:root, :Object)
201
-
202
- o.superclass = :Object
203
- expect(o.is_exception?).to be false
204
-
205
- o.superclass = :Exception
206
- expect(o.is_exception?).to be true
207
-
208
- o.superclass = :NoMethodError
209
- expect(o.is_exception?).to be true
210
-
211
- o.superclass = o2
212
- expect(o.is_exception?).to be true
213
-
214
- o.superclass = o3
215
- expect(o.is_exception?).to be true
216
- end
217
-
218
- it "does not raise ArgumentError if superclass is proxy in different namespace" do
219
- expect do
220
- ClassObject.new(:root, :X) do |o|
221
- o.superclass = P('OTHER::X')
222
- end
223
- end.not_to raise_error
224
- end
225
- end
226
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- RSpec.describe YARD::CodeObjects::CodeObjectList do
5
- before { Registry.clear }
6
-
7
- describe "#push" do
8
- it "only allows CodeObjects::Base, String or Symbol" do
9
- list = CodeObjectList.new(nil)
10
- expect { list.push(:hash => 1) }.to raise_error(ArgumentError)
11
- list << "Test"
12
- list << :Test2
13
- list << ModuleObject.new(nil, :YARD)
14
- expect(list.size).to eq 3
15
- end
16
- end
17
-
18
- it "added value should be a proxy if parameter was String or Symbol" do
19
- list = CodeObjectList.new(nil)
20
- list << "Test"
21
- expect(list.first.class).to eq Proxy
22
- end
23
-
24
- it "contains a unique list of objects" do
25
- obj = ModuleObject.new(nil, :YARD)
26
- list = CodeObjectList.new(nil)
27
-
28
- list << P(:YARD)
29
- list << obj
30
- expect(list.size).to eq 1
31
-
32
- list << :Test
33
- list << "Test"
34
- expect(list.size).to eq 2
35
- end
36
- end
@@ -1,116 +0,0 @@
1
- # frozen_string_literal: true
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- RSpec.describe YARD::CodeObjects do
5
- def silence_warnings
6
- origverb = $VERBOSE
7
- $VERBOSE = nil
8
- yield
9
- $VERBOSE = origverb
10
- end
11
-
12
- describe :CONSTANTMATCH do
13
- it "matches a constant" do
14
- expect("Constant"[CodeObjects::CONSTANTMATCH]).to eq "Constant"
15
- expect("identifier"[CodeObjects::CONSTANTMATCH]).to be nil
16
- expect("File.new"[CodeObjects::CONSTANTMATCH]).to eq "File"
17
- end
18
- end
19
-
20
- describe :CONSTANTSTART do
21
- it "matches a constant" do
22
- expect("Constant"[CodeObjects::CONSTANTSTART]).to eq "C"
23
- expect("identifier"[CodeObjects::CONSTANTSTART]).to be nil
24
- expect("File.new"[CodeObjects::CONSTANTSTART]).to eq "F"
25
- end
26
- end
27
-
28
- describe :NAMESPACEMATCH do
29
- it "matches a namespace (multiple constants with ::)" do
30
- expect("Constant"[CodeObjects::NAMESPACEMATCH]).to eq "Constant"
31
- expect("A::B::C.new"[CodeObjects::NAMESPACEMATCH]).to eq "A::B::C"
32
- end
33
- end
34
-
35
- describe :METHODNAMEMATCH do
36
- it "matches a method name" do
37
- expect("method"[CodeObjects::METHODNAMEMATCH]).to eq "method"
38
- expect("[]()"[CodeObjects::METHODNAMEMATCH]).to eq "[]"
39
- expect("-@"[CodeObjects::METHODNAMEMATCH]).to eq "-@"
40
- expect("method?"[CodeObjects::METHODNAMEMATCH]).to eq "method?"
41
- expect("method!!"[CodeObjects::METHODNAMEMATCH]).to eq "method!"
42
- end
43
- end
44
-
45
- describe :METHODMATCH do
46
- it "matches a full class method path" do
47
- expect("method"[CodeObjects::METHODMATCH]).to eq "method"
48
- expect("A::B::C.method?"[CodeObjects::METHODMATCH]).to eq "A::B::C.method?"
49
- expect("A::B::C :: method"[CodeObjects::METHODMATCH]).to eq "A::B::C :: method"
50
- expect("SomeClass . method"[CodeObjects::METHODMATCH]).to eq "SomeClass . method"
51
- end
52
-
53
- it "matches self.method" do
54
- expect("self :: method!"[CodeObjects::METHODMATCH]).to eq "self :: method!"
55
- expect("self.is_a?"[CodeObjects::METHODMATCH]).to eq "self.is_a?"
56
- end
57
- end
58
-
59
- describe :BUILTIN_EXCEPTIONS do
60
- it "includes all base exceptions" do
61
- bad_names = []
62
- silence_warnings do
63
- YARD::CodeObjects::BUILTIN_EXCEPTIONS.each do |name|
64
- begin
65
- bad_names << name unless eval(name) <= Exception
66
- rescue NameError
67
- nil # noop
68
- end
69
- end
70
- end
71
- expect(bad_names).to be_empty
72
- end
73
- end
74
-
75
- describe :BUILTIN_CLASSES do
76
- it "includes all base classes" do
77
- bad_names = []
78
- silence_warnings do
79
- YARD::CodeObjects::BUILTIN_CLASSES.each do |name|
80
- begin
81
- bad_names << name unless eval(name).is_a?(Class)
82
- rescue NameError
83
- nil # noop
84
- end
85
- end
86
- end
87
- expect(bad_names).to be_empty
88
- end
89
-
90
- it "includes all exceptions" do
91
- YARD::CodeObjects::BUILTIN_EXCEPTIONS.each do |name|
92
- expect(YARD::CodeObjects::BUILTIN_CLASSES).to include(name)
93
- end
94
- end
95
- end
96
-
97
- describe :BUILTIN_ALL do
98
- it "includes classes, modules, and exceptions" do
99
- a = YARD::CodeObjects::BUILTIN_ALL
100
- b = YARD::CodeObjects::BUILTIN_CLASSES
101
- c = YARD::CodeObjects::BUILTIN_MODULES
102
- expect(a).to eq b + c
103
- end
104
- end
105
-
106
- describe :BUILTIN_MODULES do
107
- it "includes all base modules" do
108
- silence_warnings do
109
- YARD::CodeObjects::BUILTIN_MODULES.each do |name|
110
- next if YARD.ruby19? && ["Precision"].include?(name)
111
- expect(eval(name)).to be_instance_of(Module)
112
- end
113
- end
114
- end
115
- end
116
- end
@@ -1,161 +0,0 @@
1
- # frozen_string_literal: true
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- RSpec.describe YARD::CodeObjects::ExtraFileObject do
5
- describe "#initialize" do
6
- it "attempts to read contents from filesystem if contents=nil" do
7
- expect(File).to receive(:read).with('file.txt').and_return('')
8
- ExtraFileObject.new('file.txt')
9
- end
10
-
11
- it "raises Errno::ENOENT if contents=nil and file does not exist" do
12
- expect { ExtraFileObject.new('file.txt') }.to raise_error(Errno::ENOENT)
13
- end
14
-
15
- it "does not attempt to read from disk if contents are provided" do
16
- # TODO: no assertions here!
17
- ExtraFileObject.new('file.txt', 'CONTENTS')
18
- end
19
-
20
- it "sets filename to filename" do
21
- file = ExtraFileObject.new('a/b/c/file.txt', 'CONTENTS')
22
- expect(file.filename).to eq "a/b/c/file.txt"
23
- end
24
-
25
- it "parses out attributes at top of the file" do
26
- file = ExtraFileObject.new('file.txt', "# @title X\n# @some_attribute Y\nFOO BAR")
27
- expect(file.attributes[:title]).to eq "X"
28
- expect(file.attributes[:some_attribute]).to eq "Y"
29
- expect(file.contents).to eq "FOO BAR"
30
- end
31
-
32
- it "allows whitespace prior to '#' marker when parsing attributes" do
33
- file = ExtraFileObject.new('file.txt', " \t # @title X\nFOO BAR")
34
- expect(file.attributes[:title]).to eq "X"
35
- expect(file.contents).to eq "FOO BAR"
36
- end
37
-
38
- it "allows the attributes section to be wrapped in an HTML comment" do
39
- file = ExtraFileObject.new('file.txt', "<!--\n# @title X\n-->\nFOO BAR")
40
- expect(file.attributes[:title]).to eq "X"
41
- expect(file.contents).to eq "FOO BAR"
42
- end
43
-
44
- it "allows whitespace around ignored HTML comment" do
45
- file = ExtraFileObject.new('file.txt', " \t <!-- \n# @title X\n \t --> \nFOO BAR")
46
- expect(file.attributes[:title]).to eq "X"
47
- expect(file.contents).to eq "FOO BAR"
48
- end
49
-
50
- it "parses out old-style #!markup shebang format" do
51
- file = ExtraFileObject.new('file.txt', "#!foobar\nHello")
52
- expect(file.attributes[:markup]).to eq "foobar"
53
- end
54
-
55
- it "does not parse old-style #!markup if any whitespace is found" do
56
- file = ExtraFileObject.new('file.txt', " #!foobar\nHello")
57
- expect(file.attributes[:markup]).to be nil
58
- expect(file.contents).to eq " #!foobar\nHello"
59
- end
60
-
61
- it "does not parse out attributes if there are newlines prior to attributes" do
62
- file = ExtraFileObject.new('file.txt', "\n# @title\nFOO BAR")
63
- expect(file.attributes).to be_empty
64
- expect(file.contents).to eq "\n# @title\nFOO BAR"
65
- end
66
-
67
- it "sets contents to data after attributes" do
68
- file = ExtraFileObject.new('file.txt', "# @title\nFOO BAR")
69
- expect(file.contents).to eq "FOO BAR"
70
- end
71
-
72
- it "preserves newlines" do
73
- file = ExtraFileObject.new('file.txt', "FOO\r\nBAR\nBAZ")
74
- expect(file.contents).to eq "FOO\r\nBAR\nBAZ"
75
- end
76
-
77
- it "does not include newlines in attribute data" do
78
- file = ExtraFileObject.new('file.txt', "# @title FooBar\r\nHello world")
79
- expect(file.attributes[:title]).to eq "FooBar"
80
- end
81
-
82
- it "forces encoding to @encoding attribute if present" do
83
- expect(log).not_to receive(:warn)
84
- data = String.new("# @encoding sjis\nFOO")
85
- data.force_encoding('binary')
86
- file = ExtraFileObject.new('file.txt', data)
87
- expect(['Shift_JIS', 'Windows-31J']).to include(file.contents.encoding.to_s)
88
- end if YARD.ruby19?
89
-
90
- it "warns if @encoding is invalid" do
91
- expect(log).to receive(:warn).with("Invalid encoding `INVALID' in file.txt")
92
- data = String.new("# @encoding INVALID\nFOO")
93
- encoding = data.encoding
94
- file = ExtraFileObject.new('file.txt', data)
95
- expect(file.contents.encoding).to eq encoding
96
- end if YARD.ruby19?
97
-
98
- it "ignores encoding in 1.8.x (or encoding-unaware platforms)" do
99
- expect(log).not_to receive(:warn)
100
- ExtraFileObject.new('file.txt', "# @encoding INVALID\nFOO")
101
- end if YARD.ruby18?
102
-
103
- it "attempts to re-parse data as 8-bit ascii if parsing fails" do
104
- expect(log).not_to receive(:warn)
105
- str, out = *([String.new("\xB0")] * 2)
106
- if str.respond_to?(:force_encoding!)
107
- str.force_encoding!('utf-8')
108
- out.force_encoding!('binary')
109
- end
110
- expect(str.valid_encoding?).to be(false)
111
- file = ExtraFileObject.new('file.txt', str)
112
- expect(file.contents).to eq out
113
- end
114
- end
115
-
116
- describe "#name" do
117
- it "returns basename (not extension) of filename" do
118
- file = ExtraFileObject.new('file.txt', '')
119
- expect(file.name).to eq 'file'
120
- end
121
- end
122
-
123
- describe "#title" do
124
- it "returns @title attribute if present" do
125
- file = ExtraFileObject.new('file.txt', '# @title FOO')
126
- expect(file.title).to eq 'FOO'
127
- end
128
-
129
- it "returns #name if no @title attribute exists" do
130
- file = ExtraFileObject.new('file.txt', '')
131
- expect(file.title).to eq 'file'
132
- end
133
- end
134
-
135
- describe "#locale=" do
136
- it "translates contents" do
137
- file = ExtraFileObject.new('file.txt', 'Hello')
138
- file.locale = 'fr'
139
- fr_locale = I18n::Locale.new('fr')
140
- fr_messages = fr_locale.instance_variable_get(:@messages)
141
- fr_messages["Hello"] = 'Bonjour'
142
- expect(Registry).to receive(:locale).with('fr').and_return(fr_locale)
143
- expect(file.contents).to eq 'Bonjour'
144
- end
145
- end
146
-
147
- describe "#==" do
148
- it "defines equality based on filename alone" do
149
- file1 = ExtraFileObject.new('file.txt', 'A')
150
- file2 = ExtraFileObject.new('file.txt', 'B')
151
- expect(file1).to eq file2
152
- expect(file1).to eql file2
153
- expect(file1).to equal file2
154
-
155
- # Another way to test the equality interface
156
- a = [file1]
157
- a |= [file2]
158
- expect(a.size).to eq 1
159
- end
160
- end
161
- end
@@ -1,150 +0,0 @@
1
- # frozen_string_literal: true
2
- require File.dirname(__FILE__) + '/spec_helper'
3
-
4
- RSpec.describe YARD::CodeObjects::MacroObject do
5
- before do
6
- Registry.clear
7
- end
8
-
9
- describe ".create" do
10
- def create(*args) MacroObject.create(*args) end
11
-
12
- it "creates an object" do
13
- create('foo', '')
14
- obj = Registry.at('.macro.foo')
15
- expect(obj).not_to be nil
16
- end
17
-
18
- it "uses identity map" do
19
- obj1 = create('foo', '')
20
- obj2 = create('foo', '')
21
- expect(obj1.object_id).to eq obj2.object_id
22
- end
23
-
24
- it "allows specifying of macro data" do
25
- obj = create('foo', 'MACRODATA')
26
- expect(obj.macro_data).to eq 'MACRODATA'
27
- end
28
-
29
- context "if a method object is provided" do
30
- it "attaches it" do
31
- obj = create('foo', 'MACRODATA', P('Foo.property'))
32
- expect(obj.method_object).to eq P('Foo.property')
33
- expect(obj).to be_attached
34
- end
35
- end
36
- end
37
-
38
- describe ".find" do
39
- before { MacroObject.create('foo', 'DATA') }
40
-
41
- it "searches for an object by name" do
42
- expect(MacroObject.find('foo').macro_data).to eq 'DATA'
43
- end
44
-
45
- it "accepts Symbol" do
46
- expect(MacroObject.find(:foo).macro_data).to eq 'DATA'
47
- end
48
- end
49
-
50
- describe ".find_or_create" do
51
- it "looks up name if @!macro is present and find object" do
52
- macro1 = MacroObject.create('foo', 'FOO')
53
- macro2 = MacroObject.find_or_create('foo', "a b c")
54
- expect(macro1).to eq macro2
55
- end
56
-
57
- it "creates new macro if macro by that name does not exist" do
58
- MacroObject.find_or_create('foo', "@!method $1")
59
- expect(MacroObject.find('foo').macro_data).to eq "@!method $1"
60
- end
61
- end
62
-
63
- describe ".apply" do
64
- let(:args) { %w(foo a b c) }
65
-
66
- def apply(comments)
67
- MacroObject.apply(comments, args)
68
- end
69
-
70
- it "only expands macros if @macro is present" do
71
- expect(apply("$1$2$3")).to eq "$1$2$3"
72
- end
73
-
74
- it "handles macro text inside block" do
75
- expect(apply("@!macro\n foo$1$2$3\nfoobaz")).to eq "fooabc\nfoobaz"
76
- end
77
-
78
- it "appends docstring to existing macro" do
79
- MacroObject.create('name', '$3$2$1')
80
- result = MacroObject.apply("@!macro name\nfoobar", args)
81
- expect(result).to eq "cba\nfoobar"
82
- end
83
-
84
- it "uses only non-macro data if docstring is an existing macro" do
85
- data = "@!macro name\n $3$2$1\nEXTRA"
86
- result = MacroObject.apply(data, args, 'SOURCE')
87
- expect(result).to eq "cba\nEXTRA"
88
- expect(MacroObject.apply("@!macro name\nFOO", args)).to eq "cba\nFOO"
89
- end
90
-
91
- it "creates macros if they don't exist" do
92
- result = MacroObject.apply("@!macro name\n foo!$1", args, 'SOURCE')
93
- expect(result).to eq "foo!a"
94
- expect(MacroObject.find('name').macro_data).to eq 'foo!$1'
95
- end
96
-
97
- it "keeps other tags" do
98
- expect(apply("@!macro\n foo$1$2$3\n@param name foo\nfoo")).to eq(
99
- "fooabc\nfoo\n@param name\n foo"
100
- )
101
- end
102
- end
103
-
104
- describe ".expand" do
105
- def expand(comments)
106
- args = %w(foo a b c)
107
- full_line = 'foo :bar, :baz'
108
- MacroObject.expand(comments, args, full_line)
109
- end
110
-
111
- it "allows escaping of macro syntax" do
112
- expect(expand("$1\\$2$3")).to eq "a$2c"
113
- end
114
-
115
- it "replaces $* with the whole statement" do
116
- expect(expand("$* ${*}")).to eq "foo :bar, :baz foo :bar, :baz"
117
- end
118
-
119
- it "replaces $0 with method name" do
120
- expect(expand("$0 ${0}")).to eq "foo foo"
121
- end
122
-
123
- it "replaces all $N values with the Nth argument in the method call" do
124
- expect(expand("$1$2$3${3}\nfoobar")).to eq "abcc\nfoobar"
125
- end
126
-
127
- it "replaces ${N-M} ranges with N-M arguments (incl. commas)" do
128
- expect(expand("${1-2}x")).to eq "a, bx"
129
- end
130
-
131
- it "handles open ended ranges (${N-})" do
132
- expect(expand("${2-}")).to eq "b, c"
133
- end
134
-
135
- it "handles negative indexes ($-N)" do
136
- expect(expand("$-1 ${-2-} ${-2--2}")).to eq "c b, c b"
137
- end
138
-
139
- it "accepts Docstring objects" do
140
- expect(expand(Docstring.new("$1\n@param name foo"))).to eq "a\n@param name foo"
141
- end
142
- end
143
-
144
- describe "#expand" do
145
- it "expands a macro given its data" do
146
- macro = MacroObject.create_docstring('foo', '$1 $2 THREE!')
147
- expect(macro.expand(['NAME', 'ONE', 'TWO'])).to eq "ONE TWO THREE!"
148
- end
149
- end
150
- end