rdoc 3.12.2 → 4.0.0.preview2

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 (200) hide show
  1. checksums.yaml +6 -6
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/.autotest +3 -2
  5. data/DEVELOPERS.rdoc +53 -0
  6. data/History.rdoc +159 -25
  7. data/LEGAL.rdoc +12 -0
  8. data/Manifest.txt +56 -3
  9. data/README.rdoc +87 -19
  10. data/Rakefile +11 -2
  11. data/TODO.rdoc +20 -13
  12. data/bin/rdoc +4 -0
  13. data/lib/gauntlet_rdoc.rb +1 -1
  14. data/lib/rdoc.rb +32 -71
  15. data/lib/rdoc/any_method.rb +75 -21
  16. data/lib/rdoc/attr.rb +49 -10
  17. data/lib/rdoc/class_module.rb +182 -32
  18. data/lib/rdoc/code_object.rb +54 -12
  19. data/lib/rdoc/comment.rb +8 -1
  20. data/lib/rdoc/constant.rb +100 -6
  21. data/lib/rdoc/context.rb +93 -41
  22. data/lib/rdoc/context/section.rb +143 -28
  23. data/lib/rdoc/cross_reference.rb +58 -50
  24. data/lib/rdoc/encoding.rb +34 -29
  25. data/lib/rdoc/erb_partial.rb +18 -0
  26. data/lib/rdoc/extend.rb +117 -0
  27. data/lib/rdoc/generator.rb +11 -6
  28. data/lib/rdoc/generator/darkfish.rb +250 -62
  29. data/lib/rdoc/generator/json_index.rb +20 -12
  30. data/lib/rdoc/generator/markup.rb +10 -12
  31. data/lib/rdoc/generator/ri.rb +7 -60
  32. data/lib/rdoc/generator/template/darkfish/_head.rhtml +7 -7
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +16 -0
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +1 -1
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +14 -0
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +1 -1
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +13 -0
  38. data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -1
  39. data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
  40. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -3
  41. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -9
  42. data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -0
  43. data/lib/rdoc/generator/template/darkfish/rdoc.css +31 -0
  44. data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
  45. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +37 -0
  46. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
  47. data/lib/rdoc/include.rb +12 -3
  48. data/lib/rdoc/markdown.kpeg +1186 -0
  49. data/lib/rdoc/markdown.rb +16336 -0
  50. data/lib/rdoc/markdown/entities.rb +2128 -0
  51. data/lib/rdoc/markdown/literals_1_8.kpeg +18 -0
  52. data/lib/rdoc/markdown/literals_1_8.rb +454 -0
  53. data/lib/rdoc/markdown/literals_1_9.kpeg +22 -0
  54. data/lib/rdoc/markdown/literals_1_9.rb +417 -0
  55. data/lib/rdoc/markup.rb +69 -10
  56. data/lib/rdoc/markup/attr_changer.rb +2 -5
  57. data/lib/rdoc/markup/attribute_manager.rb +23 -14
  58. data/lib/rdoc/markup/attributes.rb +70 -0
  59. data/lib/rdoc/markup/block_quote.rb +14 -0
  60. data/lib/rdoc/markup/document.rb +20 -4
  61. data/lib/rdoc/markup/formatter.rb +17 -6
  62. data/lib/rdoc/markup/formatter_test_case.rb +93 -24
  63. data/lib/rdoc/markup/hard_break.rb +31 -0
  64. data/lib/rdoc/markup/heading.rb +1 -1
  65. data/lib/rdoc/markup/indented_paragraph.rb +14 -0
  66. data/lib/rdoc/markup/list.rb +23 -4
  67. data/lib/rdoc/markup/list_item.rb +17 -4
  68. data/lib/rdoc/markup/paragraph.rb +14 -0
  69. data/lib/rdoc/markup/parser.rb +107 -60
  70. data/lib/rdoc/markup/raw.rb +4 -4
  71. data/lib/rdoc/markup/special.rb +3 -3
  72. data/lib/rdoc/markup/to_ansi.rb +7 -1
  73. data/lib/rdoc/markup/to_html.rb +42 -14
  74. data/lib/rdoc/markup/to_html_crossref.rb +10 -9
  75. data/lib/rdoc/markup/to_html_snippet.rb +20 -4
  76. data/lib/rdoc/markup/to_joined_paragraph.rb +68 -0
  77. data/lib/rdoc/markup/to_label.rb +20 -1
  78. data/lib/rdoc/markup/to_markdown.rb +134 -0
  79. data/lib/rdoc/markup/to_rdoc.rb +36 -5
  80. data/lib/rdoc/markup/to_table_of_contents.rb +6 -1
  81. data/lib/rdoc/markup/to_tt_only.rb +11 -2
  82. data/lib/rdoc/markup/verbatim.rb +19 -0
  83. data/lib/rdoc/method_attr.rb +33 -19
  84. data/lib/rdoc/normal_class.rb +26 -7
  85. data/lib/rdoc/normal_module.rb +10 -5
  86. data/lib/rdoc/options.rb +95 -21
  87. data/lib/rdoc/parser.rb +6 -2
  88. data/lib/rdoc/parser/c.rb +212 -97
  89. data/lib/rdoc/parser/markdown.rb +23 -0
  90. data/lib/rdoc/parser/ruby.rb +115 -35
  91. data/lib/rdoc/parser/ruby_tools.rb +8 -3
  92. data/lib/rdoc/rd.rb +8 -4
  93. data/lib/rdoc/rd/block_parser.rb +1 -1
  94. data/lib/rdoc/rd/block_parser.ry +1 -1
  95. data/lib/rdoc/rdoc.rb +45 -21
  96. data/lib/rdoc/ri/driver.rb +322 -76
  97. data/lib/rdoc/ri/paths.rb +90 -31
  98. data/lib/rdoc/ri/store.rb +2 -353
  99. data/lib/rdoc/ruby_lex.rb +5 -21
  100. data/lib/rdoc/ruby_token.rb +2 -3
  101. data/lib/rdoc/rubygems_hook.rb +21 -9
  102. data/lib/rdoc/servlet.rb +302 -0
  103. data/lib/rdoc/stats.rb +28 -20
  104. data/lib/rdoc/store.rb +881 -0
  105. data/lib/rdoc/task.rb +2 -1
  106. data/lib/rdoc/test_case.rb +103 -1
  107. data/lib/rdoc/text.rb +5 -4
  108. data/lib/rdoc/tom_doc.rb +17 -16
  109. data/lib/rdoc/top_level.rb +43 -285
  110. data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +21 -0
  111. data/test/MarkdownTest_1.0.3/Auto links.text +13 -0
  112. data/test/MarkdownTest_1.0.3/Backslash escapes.text +120 -0
  113. data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +11 -0
  114. data/test/MarkdownTest_1.0.3/Code Blocks.text +14 -0
  115. data/test/MarkdownTest_1.0.3/Code Spans.text +6 -0
  116. data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +8 -0
  117. data/test/MarkdownTest_1.0.3/Horizontal rules.text +67 -0
  118. data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +15 -0
  119. data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +69 -0
  120. data/test/MarkdownTest_1.0.3/Inline HTML comments.text +13 -0
  121. data/test/MarkdownTest_1.0.3/Links, inline style.text +12 -0
  122. data/test/MarkdownTest_1.0.3/Links, reference style.text +71 -0
  123. data/test/MarkdownTest_1.0.3/Links, shortcut references.text +20 -0
  124. data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +7 -0
  125. data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +306 -0
  126. data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +888 -0
  127. data/test/MarkdownTest_1.0.3/Nested blockquotes.text +5 -0
  128. data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +131 -0
  129. data/test/MarkdownTest_1.0.3/Strong and em together.text +7 -0
  130. data/test/MarkdownTest_1.0.3/Tabs.text +21 -0
  131. data/test/MarkdownTest_1.0.3/Tidyness.text +5 -0
  132. data/test/test_attribute_manager.rb +7 -4
  133. data/test/test_rdoc_any_method.rb +84 -13
  134. data/test/test_rdoc_attr.rb +59 -9
  135. data/test/test_rdoc_class_module.rb +670 -73
  136. data/test/test_rdoc_code_object.rb +21 -1
  137. data/test/test_rdoc_comment.rb +1 -1
  138. data/test/test_rdoc_constant.rb +132 -0
  139. data/test/test_rdoc_context.rb +84 -18
  140. data/test/test_rdoc_context_section.rb +99 -15
  141. data/test/test_rdoc_cross_reference.rb +1 -1
  142. data/test/test_rdoc_encoding.rb +17 -1
  143. data/test/test_rdoc_extend.rb +94 -0
  144. data/test/test_rdoc_generator_darkfish.rb +45 -19
  145. data/test/test_rdoc_generator_json_index.rb +27 -7
  146. data/test/test_rdoc_generator_markup.rb +3 -3
  147. data/test/test_rdoc_generator_ri.rb +11 -9
  148. data/test/test_rdoc_include.rb +12 -0
  149. data/test/test_rdoc_markdown.rb +977 -0
  150. data/test/test_rdoc_markdown_test.rb +1891 -0
  151. data/test/test_rdoc_markup.rb +1 -1
  152. data/test/test_rdoc_markup_attribute_manager.rb +2 -2
  153. data/test/test_rdoc_markup_attributes.rb +39 -0
  154. data/test/test_rdoc_markup_document.rb +16 -1
  155. data/test/test_rdoc_markup_formatter.rb +7 -4
  156. data/test/test_rdoc_markup_hard_break.rb +31 -0
  157. data/test/test_rdoc_markup_indented_paragraph.rb +14 -0
  158. data/test/test_rdoc_markup_paragraph.rb +15 -1
  159. data/test/test_rdoc_markup_parser.rb +152 -89
  160. data/test/test_rdoc_markup_to_ansi.rb +23 -2
  161. data/test/test_rdoc_markup_to_bs.rb +24 -0
  162. data/test/test_rdoc_markup_to_html.rb +50 -19
  163. data/test/test_rdoc_markup_to_html_crossref.rb +23 -5
  164. data/test/test_rdoc_markup_to_html_snippet.rb +49 -8
  165. data/test/test_rdoc_markup_to_joined_paragraph.rb +32 -0
  166. data/test/test_rdoc_markup_to_label.rb +63 -1
  167. data/test/test_rdoc_markup_to_markdown.rb +352 -0
  168. data/test/test_rdoc_markup_to_rdoc.rb +22 -2
  169. data/test/test_rdoc_markup_to_table_of_contents.rb +44 -39
  170. data/test/test_rdoc_markup_to_tt_only.rb +20 -0
  171. data/test/test_rdoc_markup_verbatim.rb +13 -0
  172. data/test/test_rdoc_method_attr.rb +5 -0
  173. data/test/test_rdoc_normal_class.rb +24 -5
  174. data/test/test_rdoc_normal_module.rb +1 -1
  175. data/test/test_rdoc_options.rb +21 -6
  176. data/test/test_rdoc_parser.rb +24 -0
  177. data/test/test_rdoc_parser_c.rb +151 -26
  178. data/test/test_rdoc_parser_markdown.rb +55 -0
  179. data/test/test_rdoc_parser_rd.rb +2 -2
  180. data/test/test_rdoc_parser_ruby.rb +468 -109
  181. data/test/test_rdoc_parser_simple.rb +2 -2
  182. data/test/test_rdoc_rd_block_parser.rb +0 -4
  183. data/test/test_rdoc_rdoc.rb +110 -22
  184. data/test/test_rdoc_ri_driver.rb +415 -80
  185. data/test/test_rdoc_ri_paths.rb +122 -13
  186. data/test/test_rdoc_ruby_lex.rb +5 -61
  187. data/test/test_rdoc_ruby_token.rb +19 -0
  188. data/test/test_rdoc_rubygems_hook.rb +64 -43
  189. data/test/test_rdoc_servlet.rb +429 -0
  190. data/test/test_rdoc_stats.rb +83 -24
  191. data/test/{test_rdoc_ri_store.rb → test_rdoc_store.rb} +395 -22
  192. data/test/test_rdoc_task.rb +2 -2
  193. data/test/test_rdoc_text.rb +37 -11
  194. data/test/test_rdoc_tom_doc.rb +59 -62
  195. data/test/test_rdoc_top_level.rb +71 -113
  196. data/test/xref_test_case.rb +7 -9
  197. metadata +122 -39
  198. metadata.gz.sig +0 -0
  199. data/CVE-2013-0256.rdoc +0 -49
  200. data/lib/rdoc/markup/attribute.rb +0 -51
@@ -4,7 +4,13 @@
4
4
 
5
5
  class RDoc::Attr < RDoc::MethodAttr
6
6
 
7
- MARSHAL_VERSION = 2 # :nodoc:
7
+ ##
8
+ # 3::
9
+ # RDoc 4
10
+ # Added parent name and class
11
+ # Added section title
12
+
13
+ MARSHAL_VERSION = 3 # :nodoc:
8
14
 
9
15
  ##
10
16
  # Is the attribute readable ('R'), writable ('W') or both ('RW')?
@@ -55,6 +61,16 @@ class RDoc::Attr < RDoc::MethodAttr
55
61
  'attribute'
56
62
  end
57
63
 
64
+ ##
65
+ # Attributes never call super. See RDoc::AnyMethod#calls_super
66
+ #
67
+ # An RDoc::Attr can show up in the method list in some situations (see
68
+ # Gem::ConfigFile)
69
+
70
+ def calls_super # :nodoc:
71
+ false
72
+ end
73
+
58
74
  ##
59
75
  # Returns attr_reader, attr_writer or attr_accessor as appropriate.
60
76
 
@@ -90,7 +106,10 @@ class RDoc::Attr < RDoc::MethodAttr
90
106
  @visibility,
91
107
  parse(@comment),
92
108
  singleton,
93
- @file.absolute_name,
109
+ @file.relative_name,
110
+ @parent.full_name,
111
+ @parent.class,
112
+ @section.title
94
113
  ]
95
114
  end
96
115
 
@@ -102,17 +121,28 @@ class RDoc::Attr < RDoc::MethodAttr
102
121
  # * #parent_name
103
122
 
104
123
  def marshal_load array
105
- version = array[0]
106
- @name = array[1]
107
- @full_name = array[2]
108
- @rw = array[3]
109
- @visibility = array[4]
110
- @comment = array[5]
111
- @singleton = array[6] || false # MARSHAL_VERSION == 0
124
+ @aliases = []
125
+ @parent = nil
126
+ @parent_name = nil
127
+ @parent_class = nil
128
+ @section = nil
129
+ @file = nil
130
+
131
+ version = array[0]
132
+ @name = array[1]
133
+ @full_name = array[2]
134
+ @rw = array[3]
135
+ @visibility = array[4]
136
+ @comment = array[5]
137
+ @singleton = array[6] || false # MARSHAL_VERSION == 0
138
+ # 7 handled below
139
+ @parent_name = array[8]
140
+ @parent_class = array[9]
141
+ @section_title = array[10]
112
142
 
113
143
  @file = RDoc::TopLevel.new array[7] if version > 1
114
144
 
115
- @parent_name = @full_name
145
+ @parent_name ||= @full_name.split('#', 2).first
116
146
  end
117
147
 
118
148
  def pretty_print q # :nodoc:
@@ -130,5 +160,14 @@ class RDoc::Attr < RDoc::MethodAttr
130
160
  "#{definition} #{name} in: #{parent}"
131
161
  end
132
162
 
163
+ ##
164
+ # Attributes do not have token streams.
165
+ #
166
+ # An RDoc::Attr can show up in the method list in some situations (see
167
+ # Gem::ConfigFile)
168
+
169
+ def token_stream # :nodoc:
170
+ end
171
+
133
172
  end
134
173
 
@@ -11,8 +11,17 @@ class RDoc::ClassModule < RDoc::Context
11
11
  # * Added file to constants
12
12
  # * Added file to includes
13
13
  # * Added file to methods
14
+ # 2::
15
+ # RDoc 3.13
16
+ # * Added extends
17
+ # 3::
18
+ # RDoc 4.0
19
+ # * Added sections
20
+ # * Added in_files
21
+ # * Added parent name
22
+ # * Complete Constant dump
14
23
 
15
- MARSHAL_VERSION = 1 # :nodoc:
24
+ MARSHAL_VERSION = 3 # :nodoc:
16
25
 
17
26
  ##
18
27
  # Constants that are aliases for this class or module
@@ -54,6 +63,7 @@ class RDoc::ClassModule < RDoc::Context
54
63
  klass.external_aliases.concat mod.external_aliases
55
64
  klass.constants.concat mod.constants
56
65
  klass.includes.concat mod.includes
66
+ klass.extends.concat mod.extends
57
67
 
58
68
  klass.methods_hash.update mod.methods_hash
59
69
  klass.constants_hash.update mod.constants_hash
@@ -82,6 +92,7 @@ class RDoc::ClassModule < RDoc::Context
82
92
  klass.external_aliases +
83
93
  klass.constants +
84
94
  klass.includes +
95
+ klass.extends +
85
96
  klass.classes +
86
97
  klass.modules).each do |obj|
87
98
  obj.parent = klass
@@ -128,6 +139,17 @@ class RDoc::ClassModule < RDoc::Context
128
139
  self.comment = original
129
140
  end
130
141
 
142
+ def add_things my_things, other_things # :nodoc:
143
+ other_things.each do |group, things|
144
+ my_things[group].each { |thing| yield false, thing } if
145
+ my_things.include? group
146
+
147
+ things.each do |thing|
148
+ yield true, thing
149
+ end
150
+ end
151
+ end
152
+
131
153
  ##
132
154
  # Ancestors list for this ClassModule: the list of included modules
133
155
  # (classes will add their superclass if any).
@@ -144,6 +166,11 @@ class RDoc::ClassModule < RDoc::Context
144
166
  includes.map { |i| i.module }.reverse
145
167
  end
146
168
 
169
+ ##
170
+ # Ancestors of this class or module only
171
+
172
+ alias direct_ancestors ancestors
173
+
147
174
  ##
148
175
  # Clears the comment. Used by the ruby parser.
149
176
 
@@ -173,7 +200,7 @@ class RDoc::ClassModule < RDoc::Context
173
200
  ##
174
201
  # Prepares this ClassModule for use by a generator.
175
202
  #
176
- # See RDoc::TopLevel::complete
203
+ # See RDoc::Store#complete
177
204
 
178
205
  def complete min_visibility
179
206
  update_aliases
@@ -194,8 +221,11 @@ class RDoc::ClassModule < RDoc::Context
194
221
  # RDoc::ClassModule exists.
195
222
 
196
223
  def each_ancestor # :yields: module
224
+ return enum_for __method__ unless block_given?
225
+
197
226
  ancestors.each do |mod|
198
227
  next if String === mod
228
+ next if self == mod
199
229
  yield mod
200
230
  end
201
231
  end
@@ -229,8 +259,8 @@ class RDoc::ClassModule < RDoc::Context
229
259
  # Return the fully qualified name of this class or module
230
260
 
231
261
  def full_name
232
- @full_name ||= if RDoc::ClassModule === @parent then
233
- "#{@parent.full_name}::#{@name}"
262
+ @full_name ||= if RDoc::ClassModule === parent then
263
+ "#{parent.full_name}::#{@name}"
234
264
  else
235
265
  @name
236
266
  end
@@ -264,13 +294,20 @@ class RDoc::ClassModule < RDoc::Context
264
294
  @superclass,
265
295
  parse(@comment_location),
266
296
  attrs,
267
- constants.map do |const|
268
- [const.name, parse(const.comment), const.file_name]
269
- end,
297
+ constants,
270
298
  includes.map do |incl|
271
299
  [incl.name, parse(incl.comment), incl.file_name]
272
300
  end,
273
301
  method_types,
302
+ extends.map do |ext|
303
+ [ext.name, parse(ext.comment), ext.file_name]
304
+ end,
305
+ @sections.values,
306
+ @in_files.map do |tl|
307
+ tl.relative_name
308
+ end,
309
+ parent.full_name,
310
+ parent.class,
274
311
  ]
275
312
  end
276
313
 
@@ -282,6 +319,8 @@ class RDoc::ClassModule < RDoc::Context
282
319
  @parent = nil
283
320
  @temporary_section = nil
284
321
  @visibility = nil
322
+ @classes = {}
323
+ @modules = {}
285
324
 
286
325
  @name = array[1]
287
326
  @full_name = array[2]
@@ -305,9 +344,14 @@ class RDoc::ClassModule < RDoc::Context
305
344
  attr.record_location RDoc::TopLevel.new file
306
345
  end
307
346
 
308
- array[6].each do |name, comment, file|
309
- const = add_constant RDoc::Constant.new(name, nil, comment)
310
- const.record_location RDoc::TopLevel.new file
347
+ array[6].each do |constant, comment, file|
348
+ case constant
349
+ when RDoc::Constant then
350
+ add_constant constant
351
+ else
352
+ constant = add_constant RDoc::Constant.new(constant, nil, comment)
353
+ constant.record_location RDoc::TopLevel.new file
354
+ end
311
355
  end
312
356
 
313
357
  array[7].each do |name, comment, file|
@@ -327,6 +371,27 @@ class RDoc::ClassModule < RDoc::Context
327
371
  end
328
372
  end
329
373
  end
374
+
375
+ array[9].each do |name, comment, file|
376
+ ext = add_extend RDoc::Extend.new(name, comment)
377
+ ext.record_location RDoc::TopLevel.new file
378
+ end if array[9] # Support Marshal version 1
379
+
380
+ sections = (array[10] || []).map do |section|
381
+ [section.title, section]
382
+ end
383
+
384
+ @sections = Hash[*sections.flatten]
385
+ @current_section = add_section nil
386
+
387
+ @in_files = []
388
+
389
+ (array[11] || []).each do |filename|
390
+ record_location RDoc::TopLevel.new filename
391
+ end
392
+
393
+ @parent_name = array[12]
394
+ @parent_class = array[13]
330
395
  end
331
396
 
332
397
  ##
@@ -335,6 +400,9 @@ class RDoc::ClassModule < RDoc::Context
335
400
  # The data in +class_module+ is preferred over the receiver.
336
401
 
337
402
  def merge class_module
403
+ @parent = class_module.parent
404
+ @parent_name = class_module.parent_name
405
+
338
406
  other_document = parse class_module.comment_location
339
407
 
340
408
  if other_document then
@@ -376,6 +444,16 @@ class RDoc::ClassModule < RDoc::Context
376
444
 
377
445
  @includes.uniq! # clean up
378
446
 
447
+ merge_collections extends, cm.extends, other_files do |add, ext|
448
+ if add then
449
+ add_extend ext
450
+ else
451
+ @extends.delete ext
452
+ end
453
+ end
454
+
455
+ @extends.uniq! # clean up
456
+
379
457
  merge_collections method_list, cm.method_list, other_files do |add, meth|
380
458
  if add then
381
459
  add_method meth
@@ -385,6 +463,8 @@ class RDoc::ClassModule < RDoc::Context
385
463
  end
386
464
  end
387
465
 
466
+ merge_sections cm
467
+
388
468
  self
389
469
  end
390
470
 
@@ -407,22 +487,46 @@ class RDoc::ClassModule < RDoc::Context
407
487
  my_things = mine. group_by { |thing| thing.file }
408
488
  other_things = other.group_by { |thing| thing.file }
409
489
 
410
- my_things.delete_if do |file, things|
411
- next false unless other_files.include? file
490
+ remove_things my_things, other_files, &block
491
+ add_things my_things, other_things, &block
492
+ end
412
493
 
413
- things.each do |thing|
414
- yield false, thing
415
- end
494
+ ##
495
+ # Merges the comments in this ClassModule with the comments in the other
496
+ # ClassModule +cm+.
416
497
 
417
- true
498
+ def merge_sections cm # :nodoc:
499
+ my_sections = sections.group_by { |section| section.title }
500
+ other_sections = cm.sections.group_by { |section| section.title }
501
+
502
+ other_files = cm.in_files
503
+
504
+ remove_things my_sections, other_files do |_, section|
505
+ @sections.delete section.title
418
506
  end
419
507
 
420
- other_things.each do |file, things|
421
- my_things[file].each { |thing| yield false, thing } if
422
- my_things.include?(file)
508
+ other_sections.each do |group, sections|
509
+ if my_sections.include? group
510
+ my_sections[group].each do |my_section|
511
+ other_section = cm.sections_hash[group]
423
512
 
424
- things.each do |thing|
425
- yield true, thing
513
+ my_comments = my_section.comments
514
+ other_comments = other_section.comments
515
+
516
+ other_files = other_section.in_files
517
+
518
+ merge_collections my_comments, other_comments, other_files do |add, comment|
519
+ if add then
520
+ my_section.add_comment comment
521
+ else
522
+ my_section.remove_comment comment
523
+ end
524
+ end
525
+ end
526
+ else
527
+ sections.each do |section|
528
+ add_section group, section.comments
529
+ end
426
530
  end
427
531
  end
428
532
  end
@@ -471,10 +575,10 @@ class RDoc::ClassModule < RDoc::Context
471
575
  end
472
576
 
473
577
  ##
474
- # Path to this class or module
578
+ # Path to this class or module for use with HTML generator output.
475
579
 
476
580
  def path
477
- http_url RDoc::RDoc.current.generator.class_dir
581
+ http_url @store.rdoc.generator.class_dir
478
582
  end
479
583
 
480
584
  ##
@@ -508,12 +612,24 @@ class RDoc::ClassModule < RDoc::Context
508
612
 
509
613
  modules_hash.each_key do |name|
510
614
  full_name = prefix + name
511
- modules_hash.delete name unless RDoc::TopLevel.all_modules_hash[full_name]
615
+ modules_hash.delete name unless @store.modules_hash[full_name]
512
616
  end
513
617
 
514
618
  classes_hash.each_key do |name|
515
619
  full_name = prefix + name
516
- classes_hash.delete name unless RDoc::TopLevel.all_classes_hash[full_name]
620
+ classes_hash.delete name unless @store.classes_hash[full_name]
621
+ end
622
+ end
623
+
624
+ def remove_things my_things, other_files # :nodoc:
625
+ my_things.delete_if do |file, things|
626
+ next false unless other_files.include? file
627
+
628
+ things.each do |thing|
629
+ yield false, thing
630
+ end
631
+
632
+ true
517
633
  end
518
634
  end
519
635
 
@@ -532,12 +648,25 @@ class RDoc::ClassModule < RDoc::Context
532
648
  ]
533
649
  end
534
650
 
651
+ ##
652
+ # Sets the store for this class or module and its contained code objects.
653
+
654
+ def store= store
655
+ super
656
+
657
+ @attributes .each do |attr| attr.store = store end
658
+ @constants .each do |const| const.store = store end
659
+ @includes .each do |incl| incl.store = store end
660
+ @extends .each do |ext| ext.store = store end
661
+ @method_list.each do |meth| meth.store = store end
662
+ end
663
+
535
664
  ##
536
665
  # Get the superclass of this class. Attempts to retrieve the superclass
537
666
  # object, returns the name if it is not known.
538
667
 
539
668
  def superclass
540
- RDoc::TopLevel.find_class_named(@superclass) || @superclass
669
+ @store.find_class_named(@superclass) || @superclass
541
670
  end
542
671
 
543
672
  ##
@@ -568,7 +697,7 @@ class RDoc::ClassModule < RDoc::Context
568
697
  # aliases through a constant.
569
698
  #
570
699
  # The aliased module/class is replaced in the children and in
571
- # RDoc::TopLevel::all_modules_hash or RDoc::TopLevel::all_classes_hash
700
+ # RDoc::Store#modules_hash or RDoc::Store#classes_hash
572
701
  # by a copy that has <tt>RDoc::ClassModule#is_alias_for</tt> set to
573
702
  # the aliased module/class, and this copy is added to <tt>#aliases</tt>
574
703
  # of the aliased module/class.
@@ -583,16 +712,21 @@ class RDoc::ClassModule < RDoc::Context
583
712
  next unless cm = const.is_alias_for
584
713
  cm_alias = cm.dup
585
714
  cm_alias.name = const.name
586
- cm_alias.parent = self
587
- cm_alias.full_name = nil # force update for new parent
715
+
716
+ # Don't move top-level aliases under Object, they look ugly there
717
+ unless RDoc::TopLevel === cm_alias.parent then
718
+ cm_alias.parent = self
719
+ cm_alias.full_name = nil # force update for new parent
720
+ end
721
+
588
722
  cm_alias.aliases.clear
589
723
  cm_alias.is_alias_for = cm
590
724
 
591
725
  if cm.module? then
592
- RDoc::TopLevel.all_modules_hash[cm_alias.full_name] = cm_alias
726
+ @store.modules_hash[cm_alias.full_name] = cm_alias
593
727
  modules_hash[const.name] = cm_alias
594
728
  else
595
- RDoc::TopLevel.all_classes_hash[cm_alias.full_name] = cm_alias
729
+ @store.classes_hash[cm_alias.full_name] = cm_alias
596
730
  classes_hash[const.name] = cm_alias
597
731
  end
598
732
 
@@ -609,11 +743,27 @@ class RDoc::ClassModule < RDoc::Context
609
743
  def update_includes
610
744
  includes.reject! do |include|
611
745
  mod = include.module
612
- !(String === mod) && RDoc::TopLevel.all_modules_hash[mod.full_name].nil?
746
+ !(String === mod) && @store.modules_hash[mod.full_name].nil?
613
747
  end
614
748
 
615
749
  includes.uniq!
616
750
  end
617
751
 
752
+ ##
753
+ # Deletes from #extends those whose module has been removed from the
754
+ # documentation.
755
+ #--
756
+ # FIXME: like update_includes, extends are not reliably removed
757
+
758
+ def update_extends
759
+ extends.reject! do |ext|
760
+ mod = ext.module
761
+
762
+ !(String === mod) && @store.modules_hash[mod.full_name].nil?
763
+ end
764
+
765
+ extends.uniq!
766
+ end
767
+
618
768
  end
619
769