rdoc 5.1.0 → 6.3.1

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 (158) hide show
  1. checksums.yaml +5 -5
  2. data/CONTRIBUTING.rdoc +4 -4
  3. data/Gemfile +9 -0
  4. data/History.rdoc +4 -4
  5. data/README.rdoc +5 -6
  6. data/Rakefile +35 -67
  7. data/lib/rdoc/alias.rb +1 -1
  8. data/lib/rdoc/anon_class.rb +1 -1
  9. data/lib/rdoc/any_method.rb +59 -15
  10. data/lib/rdoc/attr.rb +1 -1
  11. data/lib/rdoc/class_module.rb +5 -3
  12. data/lib/rdoc/code_object.rb +2 -9
  13. data/lib/rdoc/code_objects.rb +1 -1
  14. data/lib/rdoc/comment.rb +32 -11
  15. data/lib/rdoc/constant.rb +3 -3
  16. data/lib/rdoc/context/section.rb +1 -14
  17. data/lib/rdoc/context.rb +63 -20
  18. data/lib/rdoc/cross_reference.rb +33 -15
  19. data/lib/rdoc/encoding.rb +58 -30
  20. data/lib/rdoc/erb_partial.rb +2 -2
  21. data/lib/rdoc/erbio.rb +8 -4
  22. data/lib/rdoc/extend.rb +1 -1
  23. data/lib/rdoc/generator/darkfish.rb +60 -29
  24. data/lib/rdoc/generator/json_index.rb +6 -3
  25. data/lib/rdoc/generator/markup.rb +3 -13
  26. data/lib/rdoc/generator/pot/message_extractor.rb +1 -1
  27. data/lib/rdoc/generator/pot/po.rb +3 -3
  28. data/lib/rdoc/generator/pot/po_entry.rb +11 -11
  29. data/lib/rdoc/generator/pot.rb +4 -4
  30. data/lib/rdoc/generator/ri.rb +1 -1
  31. data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
  32. data/lib/rdoc/generator/template/darkfish/_head.rhtml +9 -7
  33. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
  34. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
  35. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
  36. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
  37. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
  38. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
  39. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +5 -5
  40. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  41. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
  42. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  43. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
  44. data/lib/rdoc/generator/template/darkfish/class.rhtml +45 -47
  45. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +55 -6
  46. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
  47. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +22 -99
  48. data/lib/rdoc/generator/template/darkfish/js/search.js +32 -31
  49. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
  50. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
  51. data/lib/rdoc/generator/template/json_index/js/navigation.js +4 -41
  52. data/lib/rdoc/generator/template/json_index/js/searcher.js +6 -6
  53. data/lib/rdoc/generator.rb +1 -1
  54. data/lib/rdoc/ghost_method.rb +1 -1
  55. data/lib/rdoc/i18n/locale.rb +1 -1
  56. data/lib/rdoc/i18n/text.rb +5 -5
  57. data/lib/rdoc/i18n.rb +3 -3
  58. data/lib/rdoc/include.rb +1 -1
  59. data/lib/rdoc/known_classes.rb +1 -1
  60. data/lib/rdoc/markdown/entities.rb +1 -1
  61. data/lib/rdoc/markdown/literals.kpeg +1 -0
  62. data/lib/rdoc/markdown/literals.rb +19 -7
  63. data/lib/rdoc/markdown.kpeg +92 -44
  64. data/lib/rdoc/markdown.rb +1171 -610
  65. data/lib/rdoc/markup/attr_changer.rb +1 -1
  66. data/lib/rdoc/markup/attr_span.rb +9 -3
  67. data/lib/rdoc/markup/attribute_manager.rb +115 -50
  68. data/lib/rdoc/markup/attributes.rb +7 -7
  69. data/lib/rdoc/markup/blank_line.rb +1 -1
  70. data/lib/rdoc/markup/block_quote.rb +1 -1
  71. data/lib/rdoc/markup/document.rb +1 -1
  72. data/lib/rdoc/markup/formatter.rb +25 -24
  73. data/lib/rdoc/markup/hard_break.rb +1 -1
  74. data/lib/rdoc/markup/heading.rb +4 -4
  75. data/lib/rdoc/markup/include.rb +1 -1
  76. data/lib/rdoc/markup/indented_paragraph.rb +1 -1
  77. data/lib/rdoc/markup/list.rb +1 -1
  78. data/lib/rdoc/markup/list_item.rb +1 -1
  79. data/lib/rdoc/markup/paragraph.rb +1 -1
  80. data/lib/rdoc/markup/parser.rb +79 -47
  81. data/lib/rdoc/markup/pre_process.rb +11 -6
  82. data/lib/rdoc/markup/raw.rb +1 -1
  83. data/lib/rdoc/markup/regexp_handling.rb +41 -0
  84. data/lib/rdoc/markup/rule.rb +1 -1
  85. data/lib/rdoc/markup/to_ansi.rb +1 -1
  86. data/lib/rdoc/markup/to_bs.rb +4 -4
  87. data/lib/rdoc/markup/to_html.rb +68 -26
  88. data/lib/rdoc/markup/to_html_crossref.rb +41 -26
  89. data/lib/rdoc/markup/to_html_snippet.rb +10 -10
  90. data/lib/rdoc/markup/to_joined_paragraph.rb +7 -32
  91. data/lib/rdoc/markup/to_label.rb +10 -10
  92. data/lib/rdoc/markup/to_markdown.rb +9 -9
  93. data/lib/rdoc/markup/to_rdoc.rb +35 -7
  94. data/lib/rdoc/markup/to_table_of_contents.rb +2 -1
  95. data/lib/rdoc/markup/to_test.rb +1 -1
  96. data/lib/rdoc/markup/to_tt_only.rb +3 -3
  97. data/lib/rdoc/markup/verbatim.rb +1 -1
  98. data/lib/rdoc/markup.rb +14 -17
  99. data/lib/rdoc/meta_method.rb +1 -1
  100. data/lib/rdoc/method_attr.rb +2 -2
  101. data/lib/rdoc/mixin.rb +1 -1
  102. data/lib/rdoc/normal_class.rb +3 -3
  103. data/lib/rdoc/normal_module.rb +1 -1
  104. data/lib/rdoc/options.rb +79 -21
  105. data/lib/rdoc/parser/c.rb +147 -194
  106. data/lib/rdoc/parser/changelog.rb +150 -19
  107. data/lib/rdoc/parser/markdown.rb +1 -1
  108. data/lib/rdoc/parser/rd.rb +1 -1
  109. data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
  110. data/lib/rdoc/parser/ruby.rb +632 -466
  111. data/lib/rdoc/parser/ruby_tools.rb +33 -34
  112. data/lib/rdoc/parser/simple.rb +3 -3
  113. data/lib/rdoc/parser/text.rb +1 -1
  114. data/lib/rdoc/parser.rb +9 -34
  115. data/lib/rdoc/rd/block_parser.rb +47 -46
  116. data/lib/rdoc/rd/block_parser.ry +2 -2
  117. data/lib/rdoc/rd/inline.rb +5 -5
  118. data/lib/rdoc/rd/inline_parser.rb +139 -138
  119. data/lib/rdoc/rd/inline_parser.ry +1 -1
  120. data/lib/rdoc/rd.rb +1 -1
  121. data/lib/rdoc/rdoc.rb +54 -41
  122. data/lib/rdoc/require.rb +1 -1
  123. data/lib/rdoc/ri/driver.rb +132 -42
  124. data/lib/rdoc/ri/formatter.rb +1 -1
  125. data/lib/rdoc/ri/paths.rb +4 -18
  126. data/lib/rdoc/ri/store.rb +1 -1
  127. data/lib/rdoc/ri/task.rb +2 -2
  128. data/lib/rdoc/ri.rb +1 -1
  129. data/lib/rdoc/rubygems_hook.rb +3 -3
  130. data/lib/rdoc/servlet.rb +21 -12
  131. data/lib/rdoc/single_class.rb +1 -1
  132. data/lib/rdoc/stats/normal.rb +24 -18
  133. data/lib/rdoc/stats/quiet.rb +1 -1
  134. data/lib/rdoc/stats/verbose.rb +1 -1
  135. data/lib/rdoc/stats.rb +1 -1
  136. data/lib/rdoc/store.rb +38 -27
  137. data/lib/rdoc/task.rb +2 -2
  138. data/lib/rdoc/text.rb +16 -21
  139. data/lib/rdoc/token_stream.rb +56 -33
  140. data/lib/rdoc/tom_doc.rb +17 -12
  141. data/lib/rdoc/top_level.rb +9 -3
  142. data/lib/rdoc/version.rb +8 -0
  143. data/lib/rdoc.rb +24 -10
  144. data/man/ri.1 +247 -0
  145. data/rdoc.gemspec +206 -15
  146. metadata +15 -64
  147. data/.document +0 -5
  148. data/.gitignore +0 -13
  149. data/.travis.yml +0 -24
  150. data/lib/gauntlet_rdoc.rb +0 -82
  151. data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
  152. data/lib/rdoc/markup/formatter_test_case.rb +0 -764
  153. data/lib/rdoc/markup/inline.rb +0 -2
  154. data/lib/rdoc/markup/special.rb +0 -41
  155. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -115
  156. data/lib/rdoc/ruby_lex.rb +0 -1367
  157. data/lib/rdoc/ruby_token.rb +0 -461
  158. data/lib/rdoc/test_case.rb +0 -204
data/lib/rdoc/parser/c.rb CHANGED
@@ -1,17 +1,17 @@
1
- # frozen_string_literal: false
1
+ # frozen_string_literal: true
2
2
  require 'tsort'
3
3
 
4
4
  ##
5
5
  # RDoc::Parser::C attempts to parse C extension files. It looks for
6
- # the standard patterns that you find in extensions: <tt>rb_define_class,
7
- # rb_define_method</tt> and so on. It tries to find the corresponding
6
+ # the standard patterns that you find in extensions: +rb_define_class+,
7
+ # +rb_define_method+ and so on. It tries to find the corresponding
8
8
  # C source for the methods and extract comments, but if we fail
9
9
  # we don't worry too much.
10
10
  #
11
11
  # The comments associated with a Ruby method are extracted from the C
12
12
  # comment block associated with the routine that _implements_ that
13
13
  # method, that is to say the method whose name is given in the
14
- # <tt>rb_define_method</tt> call. For example, you might write:
14
+ # +rb_define_method+ call. For example, you might write:
15
15
  #
16
16
  # /*
17
17
  # * Returns a new array that is a one-dimensional flattening of this
@@ -24,8 +24,7 @@ require 'tsort'
24
24
  # * a.flatten #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
25
25
  # */
26
26
  # static VALUE
27
- # rb_ary_flatten(ary)
28
- # VALUE ary;
27
+ # rb_ary_flatten(VALUE ary)
29
28
  # {
30
29
  # ary = rb_obj_dup(ary);
31
30
  # rb_ary_flatten_bang(ary);
@@ -35,16 +34,16 @@ require 'tsort'
35
34
  # ...
36
35
  #
37
36
  # void
38
- # Init_Array()
37
+ # Init_Array(void)
39
38
  # {
40
39
  # ...
41
40
  # rb_define_method(rb_cArray, "flatten", rb_ary_flatten, 0);
42
41
  #
43
- # Here RDoc will determine from the rb_define_method line that there's a
42
+ # Here RDoc will determine from the +rb_define_method+ line that there's a
44
43
  # method called "flatten" in class Array, and will look for the implementation
45
- # in the method rb_ary_flatten. It will then use the comment from that
44
+ # in the method +rb_ary_flatten+. It will then use the comment from that
46
45
  # method in the HTML output. This method must be in the same source file
47
- # as the rb_define_method.
46
+ # as the +rb_define_method+.
48
47
  #
49
48
  # The comment blocks may include special directives:
50
49
  #
@@ -70,15 +69,15 @@ require 'tsort'
70
69
  # [Document-variable: +name+]
71
70
  # Documentation for the named +rb_define_variable+
72
71
  #
73
- # [Document-method: +method_name+]
72
+ # [Document-method\: +method_name+]
74
73
  # Documentation for the named method. Use this when the method name is
75
74
  # unambiguous.
76
75
  #
77
- # [Document-method: <tt>ClassName::method_name<tt>]
76
+ # [Document-method\: <tt>ClassName::method_name</tt>]
78
77
  # Documentation for a singleton method in the given class. Use this when
79
78
  # the method name alone is ambiguous.
80
79
  #
81
- # [Document-method: <tt>ClassName#method_name<tt>]
80
+ # [Document-method\: <tt>ClassName#method_name</tt>]
82
81
  # Documentation for a instance method in the given class. Use this when the
83
82
  # method name alone is ambiguous.
84
83
  #
@@ -210,47 +209,6 @@ class RDoc::Parser::C < RDoc::Parser
210
209
  end
211
210
  end
212
211
 
213
- ##
214
- # Removes duplicate call-seq entries for methods using the same
215
- # implementation.
216
-
217
- def deduplicate_call_seq
218
- @methods.each do |var_name, functions|
219
- class_name = @known_classes[var_name]
220
- class_obj = find_class var_name, class_name
221
-
222
- functions.each_value do |method_names|
223
- next if method_names.length == 1
224
-
225
- method_names.each do |method_name|
226
- deduplicate_method_name class_obj, method_name
227
- end
228
- end
229
- end
230
- end
231
-
232
- ##
233
- # If two ruby methods share a C implementation (and comment) this
234
- # deduplicates the examples in the call_seq for the method to reduce
235
- # confusion in the output.
236
-
237
- def deduplicate_method_name class_obj, method_name # :nodoc:
238
- return unless
239
- method = class_obj.method_list.find { |m| m.name == method_name }
240
- return unless call_seq = method.call_seq
241
-
242
- method_name = method_name[0, 1] if method_name =~ /\A\[/
243
-
244
- entries = call_seq.split "\n"
245
-
246
- matching = entries.select do |entry|
247
- entry =~ /^\w*\.?#{Regexp.escape method_name}/ or
248
- entry =~ /\s#{Regexp.escape method_name}\s/
249
- end
250
-
251
- method.call_seq = matching.join "\n"
252
- end
253
-
254
212
  ##
255
213
  # Scans #content for rb_define_alias
256
214
 
@@ -269,23 +227,29 @@ class RDoc::Parser::C < RDoc::Parser
269
227
  end
270
228
 
271
229
  class_obj = find_class var_name, class_name
272
-
273
- al = RDoc::Alias.new '', old_name, new_name, ''
274
- al.singleton = @singleton_classes.key? var_name
275
-
276
230
  comment = find_alias_comment var_name, new_name, old_name
277
-
278
231
  comment.normalize
279
-
280
- al.comment = comment
281
-
282
- al.record_location @top_level
283
-
284
- class_obj.add_alias al
285
- @stats.add_alias al
232
+ if comment.to_s.empty? and existing_method = class_obj.method_list.find { |m| m.name == old_name}
233
+ comment = existing_method.comment
234
+ end
235
+ add_alias(var_name, class_obj, old_name, new_name, comment)
286
236
  end
287
237
  end
288
238
 
239
+ ##
240
+ # Add alias, either from a direct alias definition, or from two
241
+ # method that reference the same function.
242
+
243
+ def add_alias(var_name, class_obj, old_name, new_name, comment)
244
+ al = RDoc::Alias.new '', old_name, new_name, ''
245
+ al.singleton = @singleton_classes.key? var_name
246
+ al.comment = comment
247
+ al.record_location @top_level
248
+ class_obj.add_alias al
249
+ @stats.add_alias al
250
+ al
251
+ end
252
+
289
253
  ##
290
254
  # Scans #content for rb_attr and rb_define_attr
291
255
 
@@ -324,12 +288,100 @@ class RDoc::Parser::C < RDoc::Parser
324
288
  # Scans #content for rb_define_class, boot_defclass, rb_define_class_under
325
289
  # and rb_singleton_class
326
290
 
327
- def do_classes
328
- do_boot_defclass
329
- do_define_class
330
- do_define_class_under
331
- do_singleton_class
332
- do_struct_define_without_accessor
291
+ def do_classes_and_modules
292
+ do_boot_defclass if @file_name == "class.c"
293
+
294
+ @content.scan(
295
+ %r(
296
+ (?<var_name>[\w\.]+)\s* =
297
+ \s*rb_(?:
298
+ define_(?:
299
+ class(?: # rb_define_class(class_name_1, parent_name_1)
300
+ \s*\(
301
+ \s*"(?<class_name_1>\w+)",
302
+ \s*(?<parent_name_1>\w+)\s*
303
+ \)
304
+ |
305
+ _under\s*\( # rb_define_class_under(class_under, class_name2, parent_name2...)
306
+ \s* (?<class_under>\w+),
307
+ \s* "(?<class_name_2>\w+)",
308
+ \s*
309
+ (?:
310
+ (?<parent_name_2>[\w\*\s\(\)\.\->]+) |
311
+ rb_path2class\("(?<path>[\w:]+)"\)
312
+ )
313
+ \s*\)
314
+ )
315
+ |
316
+ module(?: # rb_define_module(module_name_1)
317
+ \s*\(
318
+ \s*"(?<module_name_1>\w+)"\s*
319
+ \)
320
+ |
321
+ _under\s*\( # rb_define_module_under(module_under, module_name_2)
322
+ \s*(?<module_under>\w+),
323
+ \s*"(?<module_name_2>\w+)"
324
+ \s*\)
325
+ )
326
+ )
327
+ |
328
+ struct_define_without_accessor\s*\( # rb_struct_define_without_accessor(class_name_3, parent_name_3, ...)
329
+ \s*"(?<class_name_3>\w+)",
330
+ \s*(?<parent_name_3>\w+),
331
+ \s*\w+, # Allocation function
332
+ (?:\s*"\w+",)* # Attributes
333
+ \s*NULL
334
+ \)
335
+ |
336
+ singleton_class\s*\( # rb_singleton_class(target_class_name)
337
+ \s*(?<target_class_name>\w+)
338
+ \)
339
+ )
340
+ )mx
341
+ ) do
342
+ class_name = $~[:class_name_1]
343
+ type = :class
344
+ if class_name
345
+ # rb_define_class(class_name_1, parent_name_1)
346
+ parent_name = $~[:parent_name_1]
347
+ #under = nil
348
+ else
349
+ class_name = $~[:class_name_2]
350
+ if class_name
351
+ # rb_define_class_under(class_under, class_name2, parent_name2...)
352
+ parent_name = $~[:parent_name_2] || $~[:path]
353
+ under = $~[:class_under]
354
+ else
355
+ class_name = $~[:class_name_3]
356
+ if class_name
357
+ # rb_struct_define_without_accessor(class_name_3, parent_name_3, ...)
358
+ parent_name = $~[:parent_name_3]
359
+ #under = nil
360
+ else
361
+ type = :module
362
+ class_name = $~[:module_name_1]
363
+ #parent_name = nil
364
+ if class_name
365
+ # rb_define_module(module_name_1)
366
+ #under = nil
367
+ else
368
+ class_name = $~[:module_name_2]
369
+ if class_name
370
+ # rb_define_module_under(module_under, module_name_1)
371
+ under = $~[:module_under]
372
+ else
373
+ # rb_singleton_class(target_class_name)
374
+ target_class_name = $~[:target_class_name]
375
+ handle_singleton $~[:var_name], target_class_name
376
+ next
377
+ end
378
+ end
379
+ end
380
+ end
381
+ end
382
+
383
+ handle_class_module($~[:var_name], type, class_name, parent_name, under)
384
+ end
333
385
  end
334
386
 
335
387
  ##
@@ -378,65 +430,6 @@ class RDoc::Parser::C < RDoc::Parser
378
430
  end
379
431
  end
380
432
 
381
- ##
382
- # Scans #content for rb_define_class
383
-
384
- def do_define_class
385
- # The '.' lets us handle SWIG-generated files
386
- @content.scan(/([\w\.]+)\s* = \s*rb_define_class\s*
387
- \(
388
- \s*"(\w+)",
389
- \s*(\w+)\s*
390
- \)/mx) do |var_name, class_name, parent|
391
- handle_class_module(var_name, :class, class_name, parent, nil)
392
- end
393
- end
394
-
395
- ##
396
- # Scans #content for rb_define_class_under
397
-
398
- def do_define_class_under
399
- @content.scan(/([\w\.]+)\s* = # var_name
400
- \s*rb_define_class_under\s*
401
- \(
402
- \s* (\w+), # under
403
- \s* "(\w+)", # class_name
404
- \s*
405
- (?:
406
- ([\w\*\s\(\)\.\->]+) | # parent_name
407
- rb_path2class\("([\w:]+)"\) # path
408
- )
409
- \s*
410
- \)
411
- /mx) do |var_name, under, class_name, parent_name, path|
412
- parent = path || parent_name
413
-
414
- handle_class_module var_name, :class, class_name, parent, under
415
- end
416
- end
417
-
418
- ##
419
- # Scans #content for rb_define_module
420
-
421
- def do_define_module
422
- @content.scan(/(\w+)\s* = \s*rb_define_module\s*\(\s*"(\w+)"\s*\)/mx) do
423
- |var_name, class_name|
424
- handle_class_module(var_name, :module, class_name, nil, nil)
425
- end
426
- end
427
-
428
- ##
429
- # Scans #content for rb_define_module_under
430
-
431
- def do_define_module_under
432
- @content.scan(/(\w+)\s* = \s*rb_define_module_under\s*
433
- \(
434
- \s*(\w+),
435
- \s*"(\w+)"
436
- \s*\)/mx) do |var_name, in_module, class_name|
437
- handle_class_module(var_name, :module, class_name, nil, in_module)
438
- end
439
- end
440
433
 
441
434
  ##
442
435
  # Scans #content for rb_include_module
@@ -446,7 +439,7 @@ class RDoc::Parser::C < RDoc::Parser
446
439
  next unless cls = @classes[c]
447
440
  m = @known_classes[m] || m
448
441
 
449
- comment = RDoc::Comment.new '', @top_level
442
+ comment = RDoc::Comment.new '', @top_level, :c
450
443
  incl = cls.add_include RDoc::Include.new(m, comment)
451
444
  incl.record_location @top_level
452
445
  end
@@ -518,42 +511,6 @@ class RDoc::Parser::C < RDoc::Parser
518
511
  end
519
512
  end
520
513
 
521
- ##
522
- # Scans #content for rb_define_module and rb_define_module_under
523
-
524
- def do_modules
525
- do_define_module
526
- do_define_module_under
527
- end
528
-
529
- ##
530
- # Scans #content for rb_singleton_class
531
-
532
- def do_singleton_class
533
- @content.scan(/([\w\.]+)\s* = \s*rb_singleton_class\s*
534
- \(
535
- \s*(\w+)
536
- \s*\)/mx) do |sclass_var, class_var|
537
- handle_singleton sclass_var, class_var
538
- end
539
- end
540
-
541
- ##
542
- # Scans #content for struct_define_without_accessor
543
-
544
- def do_struct_define_without_accessor
545
- @content.scan(/([\w\.]+)\s* = \s*rb_struct_define_without_accessor\s*
546
- \(
547
- \s*"(\w+)", # Class name
548
- \s*(\w+), # Parent class
549
- \s*\w+, # Allocation function
550
- (\s*"\w+",)* # Attributes
551
- \s*NULL
552
- \)/mx) do |var_name, class_name, parent|
553
- handle_class_module(var_name, :class, class_name, parent, nil)
554
- end
555
- end
556
-
557
514
  ##
558
515
  # Finds the comment for an alias on +class_name+ from +new_name+ to
559
516
  # +old_name+
@@ -564,7 +521,7 @@ class RDoc::Parser::C < RDoc::Parser
564
521
  \s*"#{Regexp.escape new_name}"\s*,
565
522
  \s*"#{Regexp.escape old_name}"\s*\);%xm
566
523
 
567
- RDoc::Comment.new($1 || '', @top_level)
524
+ RDoc::Comment.new($1 || '', @top_level, :c)
568
525
  end
569
526
 
570
527
  ##
@@ -603,7 +560,7 @@ class RDoc::Parser::C < RDoc::Parser
603
560
  ''
604
561
  end
605
562
 
606
- RDoc::Comment.new comment, @top_level
563
+ RDoc::Comment.new comment, @top_level, :c
607
564
  end
608
565
 
609
566
  ##
@@ -615,7 +572,7 @@ class RDoc::Parser::C < RDoc::Parser
615
572
  ((?>/\*.*?\*/\s*)?)
616
573
  ((?:(?:\w+)\s+)?
617
574
  (?:intern\s+)?VALUE\s+(\w+)
618
- \s*(?:\([^)]*\))(?:[^;]|$))
575
+ \s*(?:\([^)]*\))(?:[^\);]|$))
619
576
  | ((?>/\*.*?\*/\s*))^\s*(\#\s*define\s+(\w+)\s+(\w+))
620
577
  | ^\s*\#\s*define\s+(\w+)\s+(\w+)
621
578
  }xm) do
@@ -643,7 +600,7 @@ class RDoc::Parser::C < RDoc::Parser
643
600
 
644
601
  case type
645
602
  when :func_def
646
- comment = RDoc::Comment.new args[0], @top_level
603
+ comment = RDoc::Comment.new args[0], @top_level, :c
647
604
  body = args[1]
648
605
  offset, = args[2]
649
606
 
@@ -666,16 +623,14 @@ class RDoc::Parser::C < RDoc::Parser
666
623
 
667
624
  #meth_obj.params = params
668
625
  meth_obj.start_collecting_tokens
669
- tk = RDoc::RubyToken::Token.new nil, 1, 1
670
- tk.set_text body
626
+ tk = { :line_no => 1, :char_no => 1, :text => body }
671
627
  meth_obj.add_token tk
672
628
  meth_obj.comment = comment
673
- meth_obj.offset = offset
674
629
  meth_obj.line = file_content[0, offset].count("\n") + 1
675
630
 
676
631
  body
677
632
  when :macro_def
678
- comment = RDoc::Comment.new args[0], @top_level
633
+ comment = RDoc::Comment.new args[0], @top_level, :c
679
634
  body = args[1]
680
635
  offset, = args[2]
681
636
 
@@ -685,11 +640,9 @@ class RDoc::Parser::C < RDoc::Parser
685
640
  find_modifiers comment, meth_obj
686
641
 
687
642
  meth_obj.start_collecting_tokens
688
- tk = RDoc::RubyToken::Token.new nil, 1, 1
689
- tk.set_text body
643
+ tk = { :line_no => 1, :char_no => 1, :text => body }
690
644
  meth_obj.add_token tk
691
645
  meth_obj.comment = comment
692
- meth_obj.offset = offset
693
646
  meth_obj.line = file_content[0, offset].count("\n") + 1
694
647
 
695
648
  body
@@ -784,7 +737,7 @@ class RDoc::Parser::C < RDoc::Parser
784
737
  comment = ''
785
738
  end
786
739
 
787
- comment = RDoc::Comment.new comment, @top_level
740
+ comment = RDoc::Comment.new comment, @top_level, :c
788
741
  comment.normalize
789
742
 
790
743
  look_for_directives_in class_mod, comment
@@ -829,7 +782,7 @@ class RDoc::Parser::C < RDoc::Parser
829
782
  table[const_name] ||
830
783
  ''
831
784
 
832
- RDoc::Comment.new comment, @top_level
785
+ RDoc::Comment.new comment, @top_level, :c
833
786
  end
834
787
 
835
788
  ##
@@ -860,7 +813,7 @@ class RDoc::Parser::C < RDoc::Parser
860
813
 
861
814
  return unless comment
862
815
 
863
- RDoc::Comment.new comment, @top_level
816
+ RDoc::Comment.new comment, @top_level, :c
864
817
  end
865
818
 
866
819
  ##
@@ -869,8 +822,8 @@ class RDoc::Parser::C < RDoc::Parser
869
822
 
870
823
  def handle_attr(var_name, attr_name, read, write)
871
824
  rw = ''
872
- rw << 'R' if '1' == read
873
- rw << 'W' if '1' == write
825
+ rw += 'R' if '1' == read
826
+ rw += 'W' if '1' == write
874
827
 
875
828
  class_name = @known_classes[var_name]
876
829
 
@@ -956,7 +909,7 @@ class RDoc::Parser::C < RDoc::Parser
956
909
  # can override the C value of the comment to give a friendly definition.
957
910
  #
958
911
  # /* 300: The perfect score in bowling */
959
- # rb_define_const(cFoo, "PERFECT", INT2FIX(300);
912
+ # rb_define_const(cFoo, "PERFECT", INT2FIX(300));
960
913
  #
961
914
  # Will override <tt>INT2FIX(300)</tt> with the value +300+ in the output
962
915
  # RDoc. Values may include quotes and escaped colons (\:).
@@ -986,15 +939,15 @@ class RDoc::Parser::C < RDoc::Parser
986
939
  if new_definition.empty? then # Default to literal C definition
987
940
  new_definition = definition
988
941
  else
989
- new_definition.gsub!("\:", ":")
990
- new_definition.gsub!("\\", '\\')
942
+ new_definition = new_definition.gsub("\:", ":")
943
+ new_definition = new_definition.gsub("\\", '\\')
991
944
  end
992
945
 
993
946
  new_definition.sub!(/\A(\s+)/, '')
994
947
 
995
948
  new_comment = "#{$1}#{new_comment.lstrip}"
996
949
 
997
- new_comment = RDoc::Comment.new new_comment, @top_level
950
+ new_comment = RDoc::Comment.new new_comment, @top_level, :c
998
951
 
999
952
  con = RDoc::Constant.new const_name, new_definition, new_comment
1000
953
  else
@@ -1032,6 +985,10 @@ class RDoc::Parser::C < RDoc::Parser
1032
985
 
1033
986
  class_obj = find_class var_name, class_name
1034
987
 
988
+ if existing_method = class_obj.method_list.find { |m| m.c_function == function }
989
+ add_alias(var_name, class_obj, existing_method.name, meth_name, existing_method.comment)
990
+ end
991
+
1035
992
  if class_obj then
1036
993
  if meth_name == 'initialize' then
1037
994
  meth_name = 'new'
@@ -1241,7 +1198,7 @@ class RDoc::Parser::C < RDoc::Parser
1241
1198
  # when scanning for classes and methods
1242
1199
 
1243
1200
  def remove_commented_out_lines
1244
- @content.gsub!(%r%//.*rb_define_%, '//')
1201
+ @content = @content.gsub(%r%//.*rb_define_%, '//')
1245
1202
  end
1246
1203
 
1247
1204
  ##
@@ -1251,8 +1208,7 @@ class RDoc::Parser::C < RDoc::Parser
1251
1208
  def scan
1252
1209
  remove_commented_out_lines
1253
1210
 
1254
- do_modules
1255
- do_classes
1211
+ do_classes_and_modules
1256
1212
  do_missing
1257
1213
 
1258
1214
  do_constants
@@ -1261,12 +1217,9 @@ class RDoc::Parser::C < RDoc::Parser
1261
1217
  do_aliases
1262
1218
  do_attrs
1263
1219
 
1264
- deduplicate_call_seq
1265
-
1266
1220
  @store.add_c_variables self
1267
1221
 
1268
1222
  @top_level
1269
1223
  end
1270
1224
 
1271
1225
  end
1272
-