rdoc 3.1 → 6.3.3

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rdoc might be problematic. Click here for more details.

Files changed (247) hide show
  1. checksums.yaml +7 -0
  2. data/CONTRIBUTING.rdoc +220 -0
  3. data/CVE-2013-0256.rdoc +49 -0
  4. data/ExampleMarkdown.md +37 -0
  5. data/ExampleRDoc.rdoc +208 -0
  6. data/Gemfile +12 -0
  7. data/History.rdoc +1666 -0
  8. data/LEGAL.rdoc +50 -0
  9. data/LICENSE.rdoc +57 -0
  10. data/README.rdoc +129 -0
  11. data/RI.rdoc +57 -0
  12. data/Rakefile +84 -81
  13. data/TODO.rdoc +59 -0
  14. data/bin/console +7 -0
  15. data/bin/setup +6 -0
  16. data/{bin → exe}/rdoc +11 -2
  17. data/exe/ri +12 -0
  18. data/lib/rdoc/alias.rb +1 -2
  19. data/lib/rdoc/anon_class.rb +3 -2
  20. data/lib/rdoc/any_method.rb +234 -40
  21. data/lib/rdoc/attr.rb +79 -11
  22. data/lib/rdoc/class_module.rb +443 -71
  23. data/lib/rdoc/code_object.rb +216 -20
  24. data/lib/rdoc/code_objects.rb +4 -21
  25. data/lib/rdoc/comment.rb +250 -0
  26. data/lib/rdoc/constant.rb +110 -9
  27. data/lib/rdoc/context/section.rb +232 -0
  28. data/lib/rdoc/context.rb +392 -172
  29. data/lib/rdoc/cross_reference.rb +202 -0
  30. data/lib/rdoc/encoding.rb +83 -28
  31. data/lib/rdoc/erb_partial.rb +19 -0
  32. data/lib/rdoc/erbio.rb +8 -3
  33. data/lib/rdoc/extend.rb +10 -0
  34. data/lib/rdoc/generator/darkfish.rb +507 -84
  35. data/lib/rdoc/generator/json_index.rb +300 -0
  36. data/lib/rdoc/generator/markup.rb +27 -74
  37. data/lib/rdoc/generator/pot/message_extractor.rb +68 -0
  38. data/lib/rdoc/generator/pot/po.rb +84 -0
  39. data/lib/rdoc/generator/pot/po_entry.rb +141 -0
  40. data/lib/rdoc/generator/pot.rb +98 -0
  41. data/lib/rdoc/generator/ri.rb +8 -62
  42. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +5 -0
  43. data/lib/rdoc/generator/template/darkfish/_head.rhtml +22 -0
  44. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +19 -0
  45. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +9 -0
  46. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +15 -0
  47. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +9 -0
  48. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +15 -0
  49. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +15 -0
  50. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +12 -0
  51. data/lib/rdoc/generator/template/darkfish/_sidebar_navigation.rhtml +11 -0
  52. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +12 -0
  53. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +11 -0
  54. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +14 -0
  55. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +11 -0
  56. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +18 -0
  57. data/lib/rdoc/generator/template/darkfish/class.rhtml +172 -0
  58. data/lib/rdoc/generator/template/darkfish/css/fonts.css +167 -0
  59. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +639 -0
  60. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Light.ttf +0 -0
  61. data/lib/rdoc/generator/template/darkfish/fonts/Lato-LightItalic.ttf +0 -0
  62. data/lib/rdoc/generator/template/darkfish/fonts/Lato-Regular.ttf +0 -0
  63. data/lib/rdoc/generator/template/darkfish/fonts/Lato-RegularItalic.ttf +0 -0
  64. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  65. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  66. data/lib/rdoc/generator/template/darkfish/images/add.png +0 -0
  67. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  68. data/lib/rdoc/generator/template/darkfish/images/delete.png +0 -0
  69. data/lib/rdoc/generator/template/darkfish/images/tag_blue.png +0 -0
  70. data/lib/rdoc/generator/template/darkfish/images/transparent.png +0 -0
  71. data/lib/rdoc/generator/template/darkfish/index.rhtml +18 -60
  72. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +51 -83
  73. data/lib/rdoc/generator/template/darkfish/js/search.js +110 -0
  74. data/lib/rdoc/generator/template/darkfish/page.rhtml +18 -0
  75. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  76. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +62 -0
  77. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +58 -0
  78. data/lib/rdoc/generator/template/json_index/.document +1 -0
  79. data/lib/rdoc/generator/template/json_index/js/navigation.js +105 -0
  80. data/lib/rdoc/generator/template/json_index/js/searcher.js +229 -0
  81. data/lib/rdoc/generator.rb +24 -13
  82. data/lib/rdoc/ghost_method.rb +1 -2
  83. data/lib/rdoc/i18n/locale.rb +102 -0
  84. data/lib/rdoc/i18n/text.rb +126 -0
  85. data/lib/rdoc/i18n.rb +10 -0
  86. data/lib/rdoc/include.rb +5 -95
  87. data/lib/rdoc/known_classes.rb +5 -2
  88. data/lib/rdoc/markdown/entities.rb +2132 -0
  89. data/lib/rdoc/markdown/literals.kpeg +23 -0
  90. data/lib/rdoc/markdown/literals.rb +416 -0
  91. data/lib/rdoc/markdown.kpeg +1237 -0
  92. data/lib/rdoc/markdown.rb +16684 -0
  93. data/lib/rdoc/markup/attr_changer.rb +23 -0
  94. data/lib/rdoc/markup/attr_span.rb +36 -0
  95. data/lib/rdoc/markup/attribute_manager.rb +135 -62
  96. data/lib/rdoc/markup/attributes.rb +71 -0
  97. data/lib/rdoc/markup/blank_line.rb +1 -0
  98. data/lib/rdoc/markup/block_quote.rb +15 -0
  99. data/lib/rdoc/markup/document.rb +96 -9
  100. data/lib/rdoc/markup/formatter.rb +138 -25
  101. data/lib/rdoc/markup/hard_break.rb +32 -0
  102. data/lib/rdoc/markup/heading.rb +61 -2
  103. data/lib/rdoc/markup/include.rb +43 -0
  104. data/lib/rdoc/markup/indented_paragraph.rb +48 -0
  105. data/lib/rdoc/markup/list.rb +25 -4
  106. data/lib/rdoc/markup/list_item.rb +18 -4
  107. data/lib/rdoc/markup/paragraph.rb +15 -0
  108. data/lib/rdoc/markup/parser.rb +180 -88
  109. data/lib/rdoc/markup/pre_process.rb +183 -38
  110. data/lib/rdoc/markup/raw.rb +6 -5
  111. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  112. data/lib/rdoc/markup/rule.rb +1 -0
  113. data/lib/rdoc/markup/table.rb +47 -0
  114. data/lib/rdoc/markup/to_ansi.rb +17 -7
  115. data/lib/rdoc/markup/to_bs.rb +5 -8
  116. data/lib/rdoc/markup/to_html.rb +238 -137
  117. data/lib/rdoc/markup/to_html_crossref.rb +125 -152
  118. data/lib/rdoc/markup/to_html_snippet.rb +285 -0
  119. data/lib/rdoc/markup/to_joined_paragraph.rb +47 -0
  120. data/lib/rdoc/markup/to_label.rb +75 -0
  121. data/lib/rdoc/markup/to_markdown.rb +192 -0
  122. data/lib/rdoc/markup/to_rdoc.rb +85 -15
  123. data/lib/rdoc/markup/to_table_of_contents.rb +89 -0
  124. data/lib/rdoc/markup/to_test.rb +2 -4
  125. data/lib/rdoc/markup/to_tt_only.rb +121 -0
  126. data/lib/rdoc/markup/verbatim.rb +39 -0
  127. data/lib/rdoc/markup.rb +388 -110
  128. data/lib/rdoc/meta_method.rb +1 -2
  129. data/lib/rdoc/method_attr.rb +87 -21
  130. data/lib/rdoc/mixin.rb +121 -0
  131. data/lib/rdoc/normal_class.rb +39 -10
  132. data/lib/rdoc/normal_module.rb +22 -7
  133. data/lib/rdoc/options.rb +613 -73
  134. data/lib/rdoc/parser/c.rb +621 -287
  135. data/lib/rdoc/parser/changelog.rb +335 -0
  136. data/lib/rdoc/parser/markdown.rb +24 -0
  137. data/lib/rdoc/parser/rd.rb +23 -0
  138. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  139. data/lib/rdoc/parser/ruby.rb +1368 -762
  140. data/lib/rdoc/parser/ruby_tools.rb +42 -35
  141. data/lib/rdoc/parser/simple.rb +23 -11
  142. data/lib/rdoc/parser/text.rb +12 -0
  143. data/lib/rdoc/parser.rb +162 -89
  144. data/lib/rdoc/rd/block_parser.rb +1056 -0
  145. data/lib/rdoc/rd/block_parser.ry +639 -0
  146. data/lib/rdoc/rd/inline.rb +72 -0
  147. data/lib/rdoc/rd/inline_parser.rb +1208 -0
  148. data/lib/rdoc/rd/inline_parser.ry +593 -0
  149. data/lib/rdoc/rd.rb +100 -0
  150. data/lib/rdoc/rdoc.rb +208 -115
  151. data/lib/rdoc/require.rb +1 -2
  152. data/lib/rdoc/ri/driver.rb +734 -239
  153. data/lib/rdoc/ri/formatter.rb +1 -0
  154. data/lib/rdoc/ri/paths.rb +91 -48
  155. data/lib/rdoc/ri/store.rb +3 -261
  156. data/lib/rdoc/ri/task.rb +71 -0
  157. data/lib/rdoc/ri.rb +5 -2
  158. data/lib/rdoc/rubygems_hook.rb +246 -0
  159. data/lib/rdoc/servlet.rb +451 -0
  160. data/lib/rdoc/single_class.rb +14 -2
  161. data/lib/rdoc/stats/normal.rb +19 -12
  162. data/lib/rdoc/stats/quiet.rb +1 -0
  163. data/lib/rdoc/stats/verbose.rb +1 -0
  164. data/lib/rdoc/stats.rb +262 -104
  165. data/lib/rdoc/store.rb +979 -0
  166. data/lib/rdoc/task.rb +84 -44
  167. data/lib/rdoc/text.rb +117 -72
  168. data/lib/rdoc/token_stream.rb +73 -4
  169. data/lib/rdoc/tom_doc.rb +263 -0
  170. data/lib/rdoc/top_level.rb +111 -261
  171. data/lib/rdoc/version.rb +8 -0
  172. data/lib/rdoc.rb +127 -64
  173. data/man/ri.1 +247 -0
  174. data/rdoc.gemspec +249 -0
  175. metadata +171 -291
  176. data/.autotest +0 -16
  177. data/.document +0 -5
  178. data/History.txt +0 -594
  179. data/LICENSE.txt +0 -57
  180. data/Manifest.txt +0 -158
  181. data/README.txt +0 -45
  182. data/RI.txt +0 -58
  183. data/bin/ri +0 -5
  184. data/lib/rdoc/gauntlet.rb +0 -52
  185. data/lib/rdoc/generator/template/darkfish/classpage.rhtml +0 -296
  186. data/lib/rdoc/generator/template/darkfish/filepage.rhtml +0 -124
  187. data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -32
  188. data/lib/rdoc/generator/template/darkfish/js/quicksearch.js +0 -114
  189. data/lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js +0 -10
  190. data/lib/rdoc/generator/template/darkfish/rdoc.css +0 -706
  191. data/lib/rdoc/markup/formatter_test_case.rb +0 -689
  192. data/lib/rdoc/markup/inline.rb +0 -137
  193. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -116
  194. data/lib/rdoc/ruby_lex.rb +0 -1291
  195. data/lib/rdoc/ruby_token.rb +0 -416
  196. data/test/README +0 -1
  197. data/test/binary.dat +0 -0
  198. data/test/hidden.zip.txt +0 -1
  199. data/test/test.ja.rdoc +0 -10
  200. data/test/test.ja.txt +0 -8
  201. data/test/test.txt +0 -1
  202. data/test/test_attribute_manager.rb +0 -120
  203. data/test/test_rdoc_alias.rb +0 -13
  204. data/test/test_rdoc_any_method.rb +0 -126
  205. data/test/test_rdoc_attr.rb +0 -61
  206. data/test/test_rdoc_class_module.rb +0 -233
  207. data/test/test_rdoc_code_object.rb +0 -165
  208. data/test/test_rdoc_constant.rb +0 -15
  209. data/test/test_rdoc_context.rb +0 -370
  210. data/test/test_rdoc_encoding.rb +0 -166
  211. data/test/test_rdoc_generator_darkfish.rb +0 -119
  212. data/test/test_rdoc_generator_ri.rb +0 -76
  213. data/test/test_rdoc_include.rb +0 -96
  214. data/test/test_rdoc_markup.rb +0 -37
  215. data/test/test_rdoc_markup_attribute_manager.rb +0 -240
  216. data/test/test_rdoc_markup_document.rb +0 -51
  217. data/test/test_rdoc_markup_paragraph.rb +0 -9
  218. data/test/test_rdoc_markup_parser.rb +0 -1395
  219. data/test/test_rdoc_markup_pre_process.rb +0 -185
  220. data/test/test_rdoc_markup_raw.rb +0 -27
  221. data/test/test_rdoc_markup_to_ansi.rb +0 -328
  222. data/test/test_rdoc_markup_to_bs.rb +0 -341
  223. data/test/test_rdoc_markup_to_html.rb +0 -335
  224. data/test/test_rdoc_markup_to_html_crossref.rb +0 -169
  225. data/test/test_rdoc_markup_to_rdoc.rb +0 -327
  226. data/test/test_rdoc_method_attr.rb +0 -122
  227. data/test/test_rdoc_normal_class.rb +0 -17
  228. data/test/test_rdoc_normal_module.rb +0 -31
  229. data/test/test_rdoc_options.rb +0 -342
  230. data/test/test_rdoc_parser.rb +0 -83
  231. data/test/test_rdoc_parser_c.rb +0 -912
  232. data/test/test_rdoc_parser_ruby.rb +0 -1754
  233. data/test/test_rdoc_parser_simple.rb +0 -99
  234. data/test/test_rdoc_rdoc.rb +0 -164
  235. data/test/test_rdoc_require.rb +0 -25
  236. data/test/test_rdoc_ri_driver.rb +0 -846
  237. data/test/test_rdoc_ri_paths.rb +0 -43
  238. data/test/test_rdoc_ri_store.rb +0 -352
  239. data/test/test_rdoc_ruby_lex.rb +0 -23
  240. data/test/test_rdoc_stats.rb +0 -38
  241. data/test/test_rdoc_task.rb +0 -92
  242. data/test/test_rdoc_text.rb +0 -251
  243. data/test/test_rdoc_top_level.rb +0 -120
  244. data/test/xref_data.rb +0 -62
  245. data/test/xref_test_case.rb +0 -61
  246. data.tar.gz.sig +0 -3
  247. metadata.gz.sig +0 -0
@@ -1,5 +1,4 @@
1
- require 'rdoc/code_object'
2
-
1
+ # frozen_string_literal: true
3
2
  ##
4
3
  # Abstract class representing either a method or an attribute.
5
4
 
@@ -96,11 +95,31 @@ class RDoc::MethodAttr < RDoc::CodeObject
96
95
  @params = nil
97
96
  end
98
97
 
98
+ ##
99
+ # Resets cached data for the object so it can be rebuilt by accessor methods
100
+
101
+ def initialize_copy other # :nodoc:
102
+ @full_name = nil
103
+ end
104
+
105
+ def initialize_visibility # :nodoc:
106
+ super
107
+ @see = nil
108
+ end
109
+
99
110
  ##
100
111
  # Order by #singleton then #name
101
112
 
102
113
  def <=>(other)
103
- [@singleton ? 0 : 1, name] <=> [other.singleton ? 0 : 1, other.name]
114
+ return unless other.respond_to?(:singleton) &&
115
+ other.respond_to?(:name)
116
+
117
+ [ @singleton ? 0 : 1, name] <=>
118
+ [other.singleton ? 0 : 1, other.name]
119
+ end
120
+
121
+ def == other # :nodoc:
122
+ equal?(other) or self.class == other.class and full_name == other.full_name
104
123
  end
105
124
 
106
125
  ##
@@ -135,6 +154,15 @@ class RDoc::MethodAttr < RDoc::CodeObject
135
154
  @see
136
155
  end
137
156
 
157
+ ##
158
+ # Sets the store for this class or module and its contained code objects.
159
+
160
+ def store= store
161
+ super
162
+
163
+ @file = @store.add_file @file.full_name if @file
164
+ end
165
+
138
166
  def find_see # :nodoc:
139
167
  return nil if singleton || is_alias_for
140
168
 
@@ -151,16 +179,16 @@ class RDoc::MethodAttr < RDoc::CodeObject
151
179
  return nil unless parent.respond_to? :ancestors
152
180
 
153
181
  searched = parent.ancestors
154
- kernel = RDoc::TopLevel.all_modules_hash['Kernel']
182
+ kernel = @store.modules_hash['Kernel']
155
183
 
156
184
  searched << kernel if kernel &&
157
185
  parent != kernel && !searched.include?(kernel)
158
186
 
159
187
  searched.each do |ancestor|
160
- next if parent == ancestor
161
188
  next if String === ancestor
189
+ next if parent == ancestor
162
190
 
163
- other = ancestor.find_method_named('#' << name) ||
191
+ other = ancestor.find_method_named('#' + name) ||
164
192
  ancestor.find_attribute_named(name)
165
193
 
166
194
  return other if other
@@ -173,10 +201,10 @@ class RDoc::MethodAttr < RDoc::CodeObject
173
201
  # Abstract method. Contexts in their building phase call this
174
202
  # to register a new alias for this known method/attribute.
175
203
  #
176
- # - creates a new AnyMethod/Attribute +newa+ named an_alias.new_name;
177
- # - adds +self+ as +newa.is_alias_for+;
178
- # - adds +newa+ to #aliases
179
- # - adds +newa+ to the methods/attributes of +context+.
204
+ # - creates a new AnyMethod/Attribute named <tt>an_alias.new_name</tt>;
205
+ # - adds +self+ as an alias for the new method or attribute
206
+ # - adds the method or attribute to #aliases
207
+ # - adds the method or attribute to +context+.
180
208
 
181
209
  def add_alias(an_alias, context)
182
210
  raise NotImplementedError
@@ -199,7 +227,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
199
227
  end
200
228
 
201
229
  ##
202
- # Attempts to sanitize the content passed by the ruby parser:
230
+ # Attempts to sanitize the content passed by the Ruby parser:
203
231
  # remove outer parentheses, etc.
204
232
 
205
233
  def block_params=(value)
@@ -261,6 +289,8 @@ class RDoc::MethodAttr < RDoc::CodeObject
261
289
  # HTML id-friendly method/attribute name
262
290
 
263
291
  def html_name
292
+ require 'cgi'
293
+
264
294
  CGI.escape(@name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
265
295
  end
266
296
 
@@ -268,14 +298,39 @@ class RDoc::MethodAttr < RDoc::CodeObject
268
298
  # Full method/attribute name including namespace
269
299
 
270
300
  def full_name
271
- @full_name || "#{parent_name}#{pretty_name}"
301
+ @full_name ||= "#{parent_name}#{pretty_name}"
302
+ end
303
+
304
+ def inspect # :nodoc:
305
+ alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil
306
+ visibility = self.visibility
307
+ visibility = "forced #{visibility}" if force_documentation
308
+ "#<%s:0x%x %s (%s)%s>" % [
309
+ self.class, object_id,
310
+ full_name,
311
+ visibility,
312
+ alias_for,
313
+ ]
272
314
  end
273
315
 
274
316
  ##
275
317
  # '::' for a class method/attribute, '#' for an instance method.
276
318
 
277
319
  def name_prefix
278
- singleton ? '::' : '#'
320
+ @singleton ? '::' : '#'
321
+ end
322
+
323
+ ##
324
+ # Name for output to HTML. For class methods the full name with a "." is
325
+ # used like +SomeClass.method_name+. For instance methods the class name is
326
+ # used if +context+ does not match the parent.
327
+ #
328
+ # This is to help prevent people from using :: to call class methods.
329
+
330
+ def output_name context
331
+ return "#{name_prefix}#{@name}" if context == parent
332
+
333
+ "#{parent_name}#{@singleton ? '.' : '#'}#{@name}"
279
334
  end
280
335
 
281
336
  ##
@@ -293,7 +348,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
293
348
  end
294
349
 
295
350
  ##
296
- # Path to this method
351
+ # Path to this method for use with HTML generator output.
297
352
 
298
353
  def path
299
354
  "#{@parent.path}##{aref}"
@@ -307,7 +362,12 @@ class RDoc::MethodAttr < RDoc::CodeObject
307
362
  end
308
363
 
309
364
  def pretty_print q # :nodoc:
310
- alias_for = @is_alias_for ? "alias for #{@is_alias_for.name}" : nil
365
+ alias_for =
366
+ if @is_alias_for.respond_to? :name then
367
+ "alias for #{@is_alias_for.name}"
368
+ elsif Array === @is_alias_for then
369
+ "alias for #{@is_alias_for.last}"
370
+ end
311
371
 
312
372
  q.group 2, "[#{self.class.name} #{full_name} #{visibility}", "]" do
313
373
  if alias_for then
@@ -331,13 +391,19 @@ class RDoc::MethodAttr < RDoc::CodeObject
331
391
  end
332
392
  end
333
393
 
334
- def inspect # :nodoc:
335
- alias_for = @is_alias_for ? " (alias for #{@is_alias_for.name})" : nil
336
- "#<%s:0x%x %s (%s)%s>" % [
337
- self.class, object_id,
394
+ ##
395
+ # Used by RDoc::Generator::JsonIndex to create a record for the search
396
+ # engine.
397
+
398
+ def search_record
399
+ [
400
+ @name,
338
401
  full_name,
339
- visibility,
340
- alias_for,
402
+ @name,
403
+ @parent.full_name,
404
+ path,
405
+ params,
406
+ snippet(@comment),
341
407
  ]
342
408
  end
343
409
 
data/lib/rdoc/mixin.rb ADDED
@@ -0,0 +1,121 @@
1
+ # frozen_string_literal: true
2
+ ##
3
+ # A Mixin adds features from a module into another context. RDoc::Include and
4
+ # RDoc::Extend are both mixins.
5
+
6
+ class RDoc::Mixin < RDoc::CodeObject
7
+
8
+ ##
9
+ # Name of included module
10
+
11
+ attr_accessor :name
12
+
13
+ ##
14
+ # Creates a new Mixin for +name+ with +comment+
15
+
16
+ def initialize(name, comment)
17
+ super()
18
+ @name = name
19
+ self.comment = comment
20
+ @module = nil # cache for module if found
21
+ end
22
+
23
+ ##
24
+ # Mixins are sorted by name
25
+
26
+ def <=> other
27
+ return unless self.class === other
28
+
29
+ name <=> other.name
30
+ end
31
+
32
+ def == other # :nodoc:
33
+ self.class === other and @name == other.name
34
+ end
35
+
36
+ alias eql? == # :nodoc:
37
+
38
+ ##
39
+ # Full name based on #module
40
+
41
+ def full_name
42
+ m = self.module
43
+ RDoc::ClassModule === m ? m.full_name : @name
44
+ end
45
+
46
+ def hash # :nodoc:
47
+ [@name, self.module].hash
48
+ end
49
+
50
+ def inspect # :nodoc:
51
+ "#<%s:0x%x %s.%s %s>" % [
52
+ self.class,
53
+ object_id,
54
+ parent_name, self.class.name.downcase, @name,
55
+ ]
56
+ end
57
+
58
+ ##
59
+ # Attempts to locate the included module object. Returns the name if not
60
+ # known.
61
+ #
62
+ # The scoping rules of Ruby to resolve the name of an included module are:
63
+ # - first look into the children of the current context;
64
+ # - if not found, look into the children of included modules,
65
+ # in reverse inclusion order;
66
+ # - if still not found, go up the hierarchy of names.
67
+ #
68
+ # This method has <code>O(n!)</code> behavior when the module calling
69
+ # include is referencing nonexistent modules. Avoid calling #module until
70
+ # after all the files are parsed. This behavior is due to ruby's constant
71
+ # lookup behavior.
72
+ #
73
+ # As of the beginning of October, 2011, no gem includes nonexistent modules.
74
+
75
+ def module
76
+ return @module if @module
77
+
78
+ # search the current context
79
+ return @name unless parent
80
+ full_name = parent.child_name(@name)
81
+ @module = @store.modules_hash[full_name]
82
+ return @module if @module
83
+ return @name if @name =~ /^::/
84
+
85
+ # search the includes before this one, in reverse order
86
+ searched = parent.includes.take_while { |i| i != self }.reverse
87
+ searched.each do |i|
88
+ inc = i.module
89
+ next if String === inc
90
+ full_name = inc.child_name(@name)
91
+ @module = @store.modules_hash[full_name]
92
+ return @module if @module
93
+ end
94
+
95
+ # go up the hierarchy of names
96
+ up = parent.parent
97
+ while up
98
+ full_name = up.child_name(@name)
99
+ @module = @store.modules_hash[full_name]
100
+ return @module if @module
101
+ up = up.parent
102
+ end
103
+
104
+ @name
105
+ end
106
+
107
+ ##
108
+ # Sets the store for this class or module and its contained code objects.
109
+
110
+ def store= store
111
+ super
112
+
113
+ @file = @store.add_file @file.full_name if @file
114
+ end
115
+
116
+ def to_s # :nodoc:
117
+ "#{self.class.name.downcase} #@name in: #{parent}"
118
+ end
119
+
120
+ end
121
+
@@ -1,31 +1,55 @@
1
- require 'rdoc/class_module'
2
-
1
+ # frozen_string_literal: true
3
2
  ##
4
3
  # A normal class, neither singleton nor anonymous
5
4
 
6
5
  class RDoc::NormalClass < RDoc::ClassModule
7
6
 
8
7
  ##
9
- # Appends the superclass, if any, to the included modules.
8
+ # The ancestors of this class including modules. Unlike Module#ancestors,
9
+ # this class is not included in the result. The result will contain both
10
+ # RDoc::ClassModules and Strings.
10
11
 
11
12
  def ancestors
13
+ if String === superclass then
14
+ super << superclass
15
+ elsif superclass then
16
+ ancestors = super
17
+ ancestors << superclass
18
+ ancestors.concat superclass.ancestors
19
+ else
20
+ super
21
+ end
22
+ end
23
+
24
+ def aref_prefix # :nodoc:
25
+ 'class'
26
+ end
27
+
28
+ ##
29
+ # The definition of this class, <tt>class MyClassName</tt>
30
+
31
+ def definition
32
+ "class #{full_name}"
33
+ end
34
+
35
+ def direct_ancestors
12
36
  superclass ? super + [superclass] : super
13
37
  end
14
38
 
15
39
  def inspect # :nodoc:
16
40
  superclass = @superclass ? " < #{@superclass}" : nil
17
- "<%s:0x%x class %s%s includes: %p attributes: %p methods: %p aliases: %p>" % [
41
+ "<%s:0x%x class %s%s includes: %p extends: %p attributes: %p methods: %p aliases: %p>" % [
18
42
  self.class, object_id,
19
- full_name, superclass, @includes, @attributes, @method_list, @aliases
43
+ full_name, superclass, @includes, @extends, @attributes, @method_list, @aliases
20
44
  ]
21
45
  end
22
46
 
23
47
  def to_s # :nodoc:
24
48
  display = "#{self.class.name} #{self.full_name}"
25
49
  if superclass
26
- display << ' < ' << (superclass.is_a?(String) ? superclass : superclass.full_name)
50
+ display += ' < ' + (superclass.is_a?(String) ? superclass : superclass.full_name)
27
51
  end
28
- display << ' -> ' << is_alias_for.to_s if is_alias_for
52
+ display += ' -> ' + is_alias_for.to_s if is_alias_for
29
53
  display
30
54
  end
31
55
 
@@ -38,20 +62,25 @@ class RDoc::NormalClass < RDoc::ClassModule
38
62
  q.breakable
39
63
  q.seplist @includes do |inc| q.pp inc end
40
64
 
65
+ q.breakable
66
+ q.text "constants:"
67
+ q.breakable
68
+ q.seplist @constants do |const| q.pp const end
69
+
41
70
  q.breakable
42
71
  q.text "attributes:"
43
72
  q.breakable
44
- q.seplist @attributes do |inc| q.pp inc end
73
+ q.seplist @attributes do |attr| q.pp attr end
45
74
 
46
75
  q.breakable
47
76
  q.text "methods:"
48
77
  q.breakable
49
- q.seplist @method_list do |inc| q.pp inc end
78
+ q.seplist @method_list do |meth| q.pp meth end
50
79
 
51
80
  q.breakable
52
81
  q.text "aliases:"
53
82
  q.breakable
54
- q.seplist @aliases do |inc| q.pp inc end
83
+ q.seplist @aliases do |aliaz| q.pp aliaz end
55
84
 
56
85
  q.breakable
57
86
  q.text "comment:"
@@ -1,17 +1,27 @@
1
- require 'rdoc/class_module'
2
-
1
+ # frozen_string_literal: true
3
2
  ##
4
3
  # A normal module, like NormalClass
5
4
 
6
5
  class RDoc::NormalModule < RDoc::ClassModule
7
6
 
7
+ def aref_prefix # :nodoc:
8
+ 'module'
9
+ end
10
+
8
11
  def inspect # :nodoc:
9
- "#<%s:0x%x module %s includes: %p attributes: %p methods: %p aliases: %p>" % [
12
+ "#<%s:0x%x module %s includes: %p extends: %p attributes: %p methods: %p aliases: %p>" % [
10
13
  self.class, object_id,
11
- full_name, @includes, @attributes, @method_list, @aliases
14
+ full_name, @includes, @extends, @attributes, @method_list, @aliases
12
15
  ]
13
16
  end
14
17
 
18
+ ##
19
+ # The definition of this module, <tt>module MyModuleName</tt>
20
+
21
+ def definition
22
+ "module #{full_name}"
23
+ end
24
+
15
25
  ##
16
26
  # This is a module, returns true
17
27
 
@@ -27,19 +37,24 @@ class RDoc::NormalModule < RDoc::ClassModule
27
37
  q.seplist @includes do |inc| q.pp inc end
28
38
  q.breakable
29
39
 
40
+ q.breakable
41
+ q.text "constants:"
42
+ q.breakable
43
+ q.seplist @constants do |const| q.pp const end
44
+
30
45
  q.text "attributes:"
31
46
  q.breakable
32
- q.seplist @attributes do |inc| q.pp inc end
47
+ q.seplist @attributes do |attr| q.pp attr end
33
48
  q.breakable
34
49
 
35
50
  q.text "methods:"
36
51
  q.breakable
37
- q.seplist @method_list do |inc| q.pp inc end
52
+ q.seplist @method_list do |meth| q.pp meth end
38
53
  q.breakable
39
54
 
40
55
  q.text "aliases:"
41
56
  q.breakable
42
- q.seplist @aliases do |inc| q.pp inc end
57
+ q.seplist @aliases do |aliaz| q.pp aliaz end
43
58
  q.breakable
44
59
 
45
60
  q.text "comment:"