rdoc 6.3.3 → 6.6.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.rdoc +1 -2
  3. data/LEGAL.rdoc +1 -1
  4. data/README.rdoc +2 -2
  5. data/TODO.rdoc +1 -1
  6. data/exe/rdoc +0 -1
  7. data/lib/rdoc/alias.rb +0 -1
  8. data/lib/rdoc/anon_class.rb +0 -1
  9. data/lib/rdoc/any_method.rb +21 -3
  10. data/lib/rdoc/attr.rb +0 -1
  11. data/lib/rdoc/class_module.rb +0 -1
  12. data/lib/rdoc/code_objects.rb +1 -2
  13. data/lib/rdoc/comment.rb +20 -41
  14. data/lib/rdoc/constant.rb +0 -1
  15. data/lib/rdoc/context/section.rb +2 -1
  16. data/lib/rdoc/context.rb +1 -3
  17. data/lib/rdoc/cross_reference.rb +45 -19
  18. data/lib/rdoc/encoding.rb +1 -17
  19. data/lib/rdoc/erb_partial.rb +0 -1
  20. data/lib/rdoc/erbio.rb +2 -7
  21. data/lib/rdoc/extend.rb +0 -1
  22. data/lib/rdoc/generator/darkfish.rb +4 -8
  23. data/lib/rdoc/generator/json_index.rb +2 -2
  24. data/lib/rdoc/generator/markup.rb +1 -2
  25. data/lib/rdoc/generator/pot.rb +1 -0
  26. data/lib/rdoc/generator/ri.rb +0 -1
  27. data/lib/rdoc/generator/template/darkfish/_head.rhtml +11 -13
  28. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +27 -3
  29. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +22 -2
  30. data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +1 -1
  31. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +25 -4
  32. data/lib/rdoc/generator/template/darkfish/class.rhtml +28 -20
  33. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +55 -7
  34. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  35. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  36. data/lib/rdoc/generator/template/darkfish/index.rhtml +1 -1
  37. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +14 -1
  38. data/lib/rdoc/generator/template/darkfish/js/search.js +4 -4
  39. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +7 -6
  40. data/lib/rdoc/generator/template/json_index/js/navigation.js +8 -8
  41. data/lib/rdoc/generator.rb +5 -5
  42. data/lib/rdoc/ghost_method.rb +0 -1
  43. data/lib/rdoc/i18n.rb +1 -1
  44. data/lib/rdoc/include.rb +0 -1
  45. data/lib/rdoc/known_classes.rb +5 -4
  46. data/lib/rdoc/markdown/entities.rb +0 -1
  47. data/lib/rdoc/markdown/literals.kpeg +0 -2
  48. data/lib/rdoc/markdown/literals.rb +73 -35
  49. data/lib/rdoc/markdown.kpeg +26 -19
  50. data/lib/rdoc/markdown.rb +326 -227
  51. data/lib/rdoc/markup/attr_changer.rb +0 -1
  52. data/lib/rdoc/markup/attr_span.rb +0 -1
  53. data/lib/rdoc/markup/attribute_manager.rb +32 -36
  54. data/lib/rdoc/markup/attributes.rb +0 -1
  55. data/lib/rdoc/markup/blank_line.rb +0 -1
  56. data/lib/rdoc/markup/block_quote.rb +0 -1
  57. data/lib/rdoc/markup/document.rb +0 -1
  58. data/lib/rdoc/markup/formatter.rb +1 -2
  59. data/lib/rdoc/markup/hard_break.rb +0 -1
  60. data/lib/rdoc/markup/heading.rb +0 -1
  61. data/lib/rdoc/markup/include.rb +0 -1
  62. data/lib/rdoc/markup/indented_paragraph.rb +0 -1
  63. data/lib/rdoc/markup/list.rb +0 -1
  64. data/lib/rdoc/markup/list_item.rb +0 -1
  65. data/lib/rdoc/markup/paragraph.rb +0 -1
  66. data/lib/rdoc/markup/parser.rb +17 -7
  67. data/lib/rdoc/markup/pre_process.rb +2 -0
  68. data/lib/rdoc/markup/raw.rb +0 -1
  69. data/lib/rdoc/markup/regexp_handling.rb +0 -1
  70. data/lib/rdoc/markup/rule.rb +0 -1
  71. data/lib/rdoc/markup/table.rb +11 -2
  72. data/lib/rdoc/markup/to_ansi.rb +0 -1
  73. data/lib/rdoc/markup/to_html.rb +27 -19
  74. data/lib/rdoc/markup/to_html_crossref.rb +1 -1
  75. data/lib/rdoc/markup/to_html_snippet.rb +3 -1
  76. data/lib/rdoc/markup/to_joined_paragraph.rb +2 -3
  77. data/lib/rdoc/markup/to_label.rb +1 -2
  78. data/lib/rdoc/markup/to_markdown.rb +0 -1
  79. data/lib/rdoc/markup/to_rdoc.rb +3 -21
  80. data/lib/rdoc/markup/to_table_of_contents.rb +0 -1
  81. data/lib/rdoc/markup/to_test.rb +0 -1
  82. data/lib/rdoc/markup/to_tt_only.rb +0 -1
  83. data/lib/rdoc/markup/verbatim.rb +0 -1
  84. data/lib/rdoc/markup.rb +35 -667
  85. data/lib/rdoc/meta_method.rb +0 -1
  86. data/lib/rdoc/method_attr.rb +1 -2
  87. data/lib/rdoc/mixin.rb +0 -1
  88. data/lib/rdoc/normal_class.rb +1 -2
  89. data/lib/rdoc/normal_module.rb +1 -2
  90. data/lib/rdoc/options.rb +66 -21
  91. data/lib/rdoc/parser/c.rb +125 -124
  92. data/lib/rdoc/parser/changelog.rb +15 -1
  93. data/lib/rdoc/parser/markdown.rb +0 -2
  94. data/lib/rdoc/parser/rd.rb +0 -1
  95. data/lib/rdoc/parser/ripper_state_lex.rb +11 -1
  96. data/lib/rdoc/parser/ruby.rb +50 -14
  97. data/lib/rdoc/parser/ruby_tools.rb +0 -2
  98. data/lib/rdoc/parser/text.rb +0 -1
  99. data/lib/rdoc/parser.rb +19 -2
  100. data/lib/rdoc/rd/block_parser.rb +666 -12
  101. data/lib/rdoc/rd/block_parser.ry +13 -9
  102. data/lib/rdoc/rd/inline.rb +0 -1
  103. data/lib/rdoc/rd/inline_parser.rb +653 -3
  104. data/lib/rdoc/rd.rb +3 -4
  105. data/lib/rdoc/rdoc.rb +21 -37
  106. data/lib/rdoc/require.rb +0 -1
  107. data/lib/rdoc/ri/driver.rb +31 -90
  108. data/lib/rdoc/ri/store.rb +0 -1
  109. data/lib/rdoc/ri.rb +4 -5
  110. data/lib/rdoc/rubygems_hook.rb +4 -2
  111. data/lib/rdoc/servlet.rb +1 -1
  112. data/lib/rdoc/single_class.rb +5 -1
  113. data/lib/rdoc/stats/quiet.rb +0 -1
  114. data/lib/rdoc/stats/verbose.rb +0 -2
  115. data/lib/rdoc/stats.rb +3 -4
  116. data/lib/rdoc/store.rb +29 -19
  117. data/lib/rdoc/task.rb +31 -5
  118. data/lib/rdoc/text.rb +22 -4
  119. data/lib/rdoc/token_stream.rb +1 -2
  120. data/lib/rdoc/top_level.rb +3 -1
  121. data/lib/rdoc/version.rb +3 -1
  122. data/lib/rdoc.rb +58 -46
  123. metadata +13 -18
  124. data/Gemfile +0 -12
  125. data/Rakefile +0 -101
  126. data/bin/console +0 -7
  127. data/bin/setup +0 -6
  128. data/rdoc.gemspec +0 -249
@@ -4,4 +4,3 @@
4
4
 
5
5
  class RDoc::MetaMethod < RDoc::AnyMethod
6
6
  end
7
-
@@ -289,7 +289,7 @@ class RDoc::MethodAttr < RDoc::CodeObject
289
289
  # HTML id-friendly method/attribute name
290
290
 
291
291
  def html_name
292
- require 'cgi'
292
+ require 'cgi/util'
293
293
 
294
294
  CGI.escape(@name.gsub('-', '-2D')).gsub('%','-').sub(/^-/, '')
295
295
  end
@@ -416,4 +416,3 @@ class RDoc::MethodAttr < RDoc::CodeObject
416
416
  end
417
417
 
418
418
  end
419
-
data/lib/rdoc/mixin.rb CHANGED
@@ -118,4 +118,3 @@ class RDoc::Mixin < RDoc::CodeObject
118
118
  end
119
119
 
120
120
  end
121
-
@@ -56,7 +56,7 @@ class RDoc::NormalClass < RDoc::ClassModule
56
56
  def pretty_print q # :nodoc:
57
57
  superclass = @superclass ? " < #{@superclass}" : nil
58
58
 
59
- q.group 2, "[class #{full_name}#{superclass} ", "]" do
59
+ q.group 2, "[class #{full_name}#{superclass}", "]" do
60
60
  q.breakable
61
61
  q.text "includes:"
62
62
  q.breakable
@@ -90,4 +90,3 @@ class RDoc::NormalClass < RDoc::ClassModule
90
90
  end
91
91
 
92
92
  end
93
-
@@ -30,7 +30,7 @@ class RDoc::NormalModule < RDoc::ClassModule
30
30
  end
31
31
 
32
32
  def pretty_print q # :nodoc:
33
- q.group 2, "[module #{full_name}: ", "]" do
33
+ q.group 2, "[module #{full_name}:", "]" do
34
34
  q.breakable
35
35
  q.text "includes:"
36
36
  q.breakable
@@ -71,4 +71,3 @@ class RDoc::NormalModule < RDoc::ClassModule
71
71
  end
72
72
 
73
73
  end
74
-
data/lib/rdoc/options.rb CHANGED
@@ -106,6 +106,7 @@ class RDoc::Options
106
106
  generator_options
107
107
  generators
108
108
  op_dir
109
+ page_dir
109
110
  option_parser
110
111
  pipe
111
112
  rdoc_include
@@ -338,6 +339,10 @@ class RDoc::Options
338
339
 
339
340
  attr_reader :visibility
340
341
 
342
+ ##
343
+ # Indicates if files of test suites should be skipped
344
+ attr_accessor :skip_tests
345
+
341
346
  def initialize loaded_options = nil # :nodoc:
342
347
  init_ivars
343
348
  override loaded_options if loaded_options
@@ -385,6 +390,7 @@ class RDoc::Options
385
390
  @write_options = false
386
391
  @encoding = Encoding::UTF_8
387
392
  @charset = @encoding.name
393
+ @skip_tests = true
388
394
  end
389
395
 
390
396
  def init_with map # :nodoc:
@@ -434,6 +440,7 @@ class RDoc::Options
434
440
  @main_page = map['main_page'] if map.has_key?('main_page')
435
441
  @markup = map['markup'] if map.has_key?('markup')
436
442
  @op_dir = map['op_dir'] if map.has_key?('op_dir')
443
+ @page_dir = map['page_dir'] if map.has_key?('page_dir')
437
444
  @show_hash = map['show_hash'] if map.has_key?('show_hash')
438
445
  @tab_width = map['tab_width'] if map.has_key?('tab_width')
439
446
  @template_dir = map['template_dir'] if map.has_key?('template_dir')
@@ -513,19 +520,22 @@ class RDoc::Options
513
520
  ##
514
521
  # For dumping YAML
515
522
 
516
- def encode_with coder # :nodoc:
523
+ def to_yaml(*options) # :nodoc:
517
524
  encoding = @encoding ? @encoding.name : nil
518
525
 
519
- coder.add 'encoding', encoding
520
- coder.add 'static_path', sanitize_path(@static_path)
521
- coder.add 'rdoc_include', sanitize_path(@rdoc_include)
526
+ yaml = {}
527
+ yaml['encoding'] = encoding
528
+ yaml['static_path'] = sanitize_path(@static_path)
529
+ yaml['rdoc_include'] = sanitize_path(@rdoc_include)
530
+ yaml['page_dir'] = (sanitize_path([@page_dir]).first if @page_dir)
522
531
 
523
532
  ivars = instance_variables.map { |ivar| ivar.to_s[1..-1] }
524
533
  ivars -= SPECIAL
525
534
 
526
535
  ivars.sort.each do |ivar|
527
- coder.add ivar, instance_variable_get("@#{ivar}")
536
+ yaml[ivar] = instance_variable_get("@#{ivar}")
528
537
  end
538
+ yaml.to_yaml
529
539
  end
530
540
 
531
541
  ##
@@ -548,11 +558,17 @@ class RDoc::Options
548
558
  # #template.
549
559
 
550
560
  def finish
561
+ if @write_options then
562
+ write_options
563
+ exit
564
+ end
565
+
551
566
  @op_dir ||= 'doc'
552
567
 
553
- @rdoc_include << "." if @rdoc_include.empty?
554
568
  root = @root.to_s
555
- @rdoc_include << root unless @rdoc_include.include?(root)
569
+ if @rdoc_include.empty? || !@rdoc_include.include?(root)
570
+ @rdoc_include << root
571
+ end
556
572
 
557
573
  @exclude = self.exclude
558
574
 
@@ -585,14 +601,14 @@ class RDoc::Options
585
601
  def finish_page_dir
586
602
  return unless @page_dir
587
603
 
588
- @files << @page_dir.to_s
604
+ @files << @page_dir
589
605
 
590
- page_dir = nil
606
+ page_dir = Pathname(@page_dir)
591
607
  begin
592
- page_dir = @page_dir.expand_path.relative_path_from @root
608
+ page_dir = page_dir.expand_path.relative_path_from @root
593
609
  rescue ArgumentError
594
610
  # On Windows, sometimes crosses different drive letters.
595
- page_dir = @page_dir.expand_path
611
+ page_dir = page_dir.expand_path
596
612
  end
597
613
 
598
614
  @page_dir = page_dir
@@ -768,6 +784,13 @@ Usage: #{opt.program_name} [options] [names...]
768
784
 
769
785
  opt.separator nil
770
786
 
787
+ opt.on("--no-skipping-tests", nil,
788
+ "Don't skip generating documentation for test and spec files") do |value|
789
+ @skip_tests = false
790
+ end
791
+
792
+ opt.separator nil
793
+
771
794
  opt.on("--extension=NEW=OLD", "-E",
772
795
  "Treat files ending with .new as if they",
773
796
  "ended with .old. Using '-E cgi=rb' will",
@@ -847,7 +870,7 @@ Usage: #{opt.program_name} [options] [names...]
847
870
  "such files at your project root.",
848
871
  "NOTE: Do not use the same file name in",
849
872
  "the page dir and the root of your project") do |page_dir|
850
- @page_dir = Pathname(page_dir)
873
+ @page_dir = page_dir
851
874
  end
852
875
 
853
876
  opt.separator nil
@@ -971,7 +994,7 @@ Usage: #{opt.program_name} [options] [names...]
971
994
  opt.on("--template-stylesheets=FILES", PathArray,
972
995
  "Set (or add to) the list of files to",
973
996
  "include with the html template.") do |value|
974
- @template_stylesheets << value
997
+ @template_stylesheets.concat value
975
998
  end
976
999
 
977
1000
  opt.separator nil
@@ -1159,13 +1182,6 @@ Usage: #{opt.program_name} [options] [names...]
1159
1182
 
1160
1183
  @files = argv.dup
1161
1184
 
1162
- finish
1163
-
1164
- if @write_options then
1165
- write_options
1166
- exit
1167
- end
1168
-
1169
1185
  self
1170
1186
  end
1171
1187
 
@@ -1278,8 +1294,37 @@ Usage: #{opt.program_name} [options] [names...]
1278
1294
  File.open '.rdoc_options', 'w' do |io|
1279
1295
  io.set_encoding Encoding::UTF_8
1280
1296
 
1281
- YAML.dump self, io
1297
+ io.print to_yaml
1298
+ end
1299
+ end
1300
+
1301
+ ##
1302
+ # Loads options from .rdoc_options if the file exists, otherwise creates a
1303
+ # new RDoc::Options instance.
1304
+
1305
+ def self.load_options
1306
+ options_file = File.expand_path '.rdoc_options'
1307
+ return RDoc::Options.new unless File.exist? options_file
1308
+
1309
+ RDoc.load_yaml
1310
+
1311
+ begin
1312
+ options = YAML.safe_load File.read('.rdoc_options'), permitted_classes: [RDoc::Options, Symbol]
1313
+ rescue Psych::SyntaxError
1314
+ raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
1315
+ end
1316
+
1317
+ return RDoc::Options.new unless options # Allow empty file.
1318
+
1319
+ raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
1320
+ RDoc::Options === options or Hash === options
1321
+
1322
+ if Hash === options
1323
+ # Override the default values with the contents of YAML file.
1324
+ options = RDoc::Options.new options
1282
1325
  end
1326
+
1327
+ options
1283
1328
  end
1284
1329
 
1285
1330
  end
data/lib/rdoc/parser/c.rb CHANGED
@@ -122,6 +122,11 @@ class RDoc::Parser::C < RDoc::Parser
122
122
 
123
123
  include RDoc::Text
124
124
 
125
+ # :stopdoc:
126
+ BOOL_ARG_PATTERN = /\s*+\b([01]|Q?(?:true|false)|TRUE|FALSE)\b\s*/
127
+ TRUE_VALUES = ['1', 'TRUE', 'true', 'Qtrue'].freeze
128
+ # :startdoc:
129
+
125
130
  ##
126
131
  # Maps C variable names to names of Ruby classes or modules
127
132
 
@@ -173,6 +178,8 @@ class RDoc::Parser::C < RDoc::Parser
173
178
  @classes = load_variable_map :c_class_variables
174
179
  @singleton_classes = load_variable_map :c_singleton_class_variables
175
180
 
181
+ @markup = @options.markup
182
+
176
183
  # class_variable => { function => [method, ...] }
177
184
  @methods = Hash.new { |h, f| h[f] = Hash.new { |i, m| i[m] = [] } }
178
185
 
@@ -257,18 +264,18 @@ class RDoc::Parser::C < RDoc::Parser
257
264
  @content.scan(/rb_attr\s*\(
258
265
  \s*(\w+),
259
266
  \s*([\w"()]+),
260
- \s*([01]),
261
- \s*([01]),
262
- \s*\w+\);/xm) do |var_name, attr_name, read, write|
267
+ #{BOOL_ARG_PATTERN},
268
+ #{BOOL_ARG_PATTERN},
269
+ \s*\w+\);/xmo) do |var_name, attr_name, read, write|
263
270
  handle_attr var_name, attr_name, read, write
264
271
  end
265
272
 
266
273
  @content.scan(%r%rb_define_attr\(
267
274
  \s*([\w\.]+),
268
275
  \s*"([^"]+)",
269
- \s*(\d+),
270
- \s*(\d+)\s*\);
271
- %xm) do |var_name, attr_name, read, write|
276
+ #{BOOL_ARG_PATTERN},
277
+ #{BOOL_ARG_PATTERN}\);
278
+ %xmo) do |var_name, attr_name, read, write|
272
279
  handle_attr var_name, attr_name, read, write
273
280
  end
274
281
  end
@@ -293,94 +300,92 @@ class RDoc::Parser::C < RDoc::Parser
293
300
 
294
301
  @content.scan(
295
302
  %r(
303
+ (?<open>\s*\(\s*) {0}
304
+ (?<close>\s*\)\s*) {0}
305
+ (?<name>\s*"(?<class_name>\w+)") {0}
306
+ (?<parent>\s*(?:
307
+ (?<parent_name>[\w\*\s\(\)\.\->]+) |
308
+ rb_path2class\s*\(\s*"(?<path>[\w:]+)"\s*\)
309
+ )) {0}
310
+ (?<under>\w+) {0}
311
+
296
312
  (?<var_name>[\w\.]+)\s* =
297
313
  \s*rb_(?:
298
314
  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
- )
315
+ class(?: # rb_define_class(name, parent_name)
316
+ \(\s*
317
+ \g<name>,
318
+ \g<parent>
313
319
  \s*\)
320
+ |
321
+ _under\g<open> # rb_define_class_under(under, name, parent_name...)
322
+ \g<under>,
323
+ \g<name>,
324
+ \g<parent>
325
+ \g<close>
314
326
  )
315
327
  |
316
- module(?: # rb_define_module(module_name_1)
317
- \s*\(
318
- \s*"(?<module_name_1>\w+)"\s*
319
- \)
328
+ (?<module>)
329
+ module(?: # rb_define_module(name)
330
+ \g<open>
331
+ \g<name>
332
+ \g<close>
320
333
  |
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*\)
334
+ _under\g<open> # rb_define_module_under(under, name)
335
+ \g<under>,
336
+ \g<name>
337
+ \g<close>
325
338
  )
326
339
  )
327
340
  |
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
- \)
341
+ (?<attributes>(?:\s*"\w+",)*\s*NULL\s*) {0}
342
+ struct_define(?:
343
+ \g<open> # rb_struct_define(name, ...)
344
+ \g<name>,
345
+ |
346
+ _under\g<open> # rb_struct_define_under(under, name, ...)
347
+ \g<under>,
348
+ \g<name>,
349
+ |
350
+ _without_accessor(?:
351
+ \g<open> # rb_struct_define_without_accessor(name, parent_name, ...)
352
+ |
353
+ _under\g<open> # rb_struct_define_without_accessor_under(under, name, parent_name, ...)
354
+ \g<under>,
355
+ )
356
+ \g<name>,
357
+ \g<parent>,
358
+ \s*\w+, # Allocation function
359
+ )
360
+ \g<attributes>
361
+ \g<close>
335
362
  |
336
- singleton_class\s*\( # rb_singleton_class(target_class_name)
337
- \s*(?<target_class_name>\w+)
338
- \)
363
+ singleton_class\g<open> # rb_singleton_class(target_class_name)
364
+ (?<target_class_name>\w+)
365
+ \g<close>
339
366
  )
340
367
  )mx
341
368
  ) 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
369
+ if target_class_name = $~[:target_class_name]
370
+ # rb_singleton_class(target_class_name)
371
+ handle_singleton $~[:var_name], target_class_name
372
+ next
381
373
  end
382
374
 
383
- handle_class_module($~[:var_name], type, class_name, parent_name, under)
375
+ var_name = $~[:var_name]
376
+ type = $~[:module] ? :module : :class
377
+ class_name = $~[:class_name]
378
+ parent_name = $~[:parent_name] || $~[:path]
379
+ under = $~[:under]
380
+ attributes = $~[:attributes]
381
+
382
+ handle_class_module(var_name, type, class_name, parent_name, under)
383
+ if attributes and !parent_name # rb_struct_define *not* without_accessor
384
+ true_flag = 'Qtrue'
385
+ attributes.scan(/"\K\w+(?=")/) do |attr_name|
386
+ handle_attr var_name, attr_name, true_flag, true_flag
387
+ end
388
+ end
384
389
  end
385
390
  end
386
391
 
@@ -439,7 +444,7 @@ class RDoc::Parser::C < RDoc::Parser
439
444
  next unless cls = @classes[c]
440
445
  m = @known_classes[m] || m
441
446
 
442
- comment = RDoc::Comment.new '', @top_level, :c
447
+ comment = new_comment '', @top_level, :c
443
448
  incl = cls.add_include RDoc::Include.new(m, comment)
444
449
  incl.record_location @top_level
445
450
  end
@@ -521,7 +526,7 @@ class RDoc::Parser::C < RDoc::Parser
521
526
  \s*"#{Regexp.escape new_name}"\s*,
522
527
  \s*"#{Regexp.escape old_name}"\s*\);%xm
523
528
 
524
- RDoc::Comment.new($1 || '', @top_level, :c)
529
+ new_comment($1 || '', @top_level, :c)
525
530
  end
526
531
 
527
532
  ##
@@ -560,7 +565,7 @@ class RDoc::Parser::C < RDoc::Parser
560
565
  ''
561
566
  end
562
567
 
563
- RDoc::Comment.new comment, @top_level, :c
568
+ new_comment comment, @top_level, :c
564
569
  end
565
570
 
566
571
  ##
@@ -570,19 +575,18 @@ class RDoc::Parser::C < RDoc::Parser
570
575
  table = {}
571
576
  file_content.scan(%r{
572
577
  ((?>/\*.*?\*/\s*)?)
573
- ((?:(?:\w+)\s+)?
574
- (?:intern\s+)?VALUE\s+(\w+)
575
- \s*(?:\([^)]*\))(?:[^\);]|$))
578
+ ((?:\w+\s+){0,2} VALUE\s+(\w+)
579
+ \s*(?:\([^\)]*\))(?:[^\);]|$))
576
580
  | ((?>/\*.*?\*/\s*))^\s*(\#\s*define\s+(\w+)\s+(\w+))
577
581
  | ^\s*\#\s*define\s+(\w+)\s+(\w+)
578
582
  }xm) do
579
583
  case
580
- when $1
581
- table[$3] = [:func_def, $1, $2, $~.offset(2)] if !table[$3] || table[$3][0] != :func_def
582
- when $4
583
- table[$6] = [:macro_def, $4, $5, $~.offset(5), $7] if !table[$6] || table[$6][0] == :macro_alias
584
- when $8
585
- table[$8] ||= [:macro_alias, $9]
584
+ when name = $3
585
+ table[name] = [:func_def, $1, $2, $~.offset(2)] if !(t = table[name]) || t[0] != :func_def
586
+ when name = $6
587
+ table[name] = [:macro_def, $4, $5, $~.offset(5), $7] if !(t = table[name]) || t[0] == :macro_alias
588
+ when name = $8
589
+ table[name] ||= [:macro_alias, $9]
586
590
  end
587
591
  end
588
592
  table
@@ -600,7 +604,7 @@ class RDoc::Parser::C < RDoc::Parser
600
604
 
601
605
  case type
602
606
  when :func_def
603
- comment = RDoc::Comment.new args[0], @top_level, :c
607
+ comment = new_comment args[0], @top_level, :c
604
608
  body = args[1]
605
609
  offset, = args[2]
606
610
 
@@ -630,7 +634,7 @@ class RDoc::Parser::C < RDoc::Parser
630
634
 
631
635
  body
632
636
  when :macro_def
633
- comment = RDoc::Comment.new args[0], @top_level, :c
637
+ comment = new_comment args[0], @top_level, :c
634
638
  body = args[1]
635
639
  offset, = args[2]
636
640
 
@@ -675,13 +679,14 @@ class RDoc::Parser::C < RDoc::Parser
675
679
  ##
676
680
  # Finds a RDoc::NormalClass or RDoc::NormalModule for +raw_name+
677
681
 
678
- def find_class(raw_name, name)
682
+ def find_class(raw_name, name, base_name = nil)
679
683
  unless @classes[raw_name]
680
684
  if raw_name =~ /^rb_m/
681
685
  container = @top_level.add_module RDoc::NormalModule, name
682
686
  else
683
687
  container = @top_level.add_class RDoc::NormalClass, name
684
688
  end
689
+ container.name = base_name if base_name
685
690
 
686
691
  container.record_location @top_level
687
692
  @classes[raw_name] = container
@@ -722,7 +727,7 @@ class RDoc::Parser::C < RDoc::Parser
722
727
  ((?>/\*.*?\*/\s+))
723
728
  (static\s+)?
724
729
  void\s+
725
- Init_#{class_name}\s*(?:_\(\s*)?\(\s*(?:void\s*)?\)%xmi then
730
+ Init(?:VM)?_(?i:#{class_name})\s*(?:_\(\s*)?\(\s*(?:void\s*)?\)%xm then
726
731
  comment = $1.sub(%r%Document-(?:class|module):\s+#{class_name}%, '')
727
732
  elsif @content =~ %r%Document-(?:class|module):\s+#{class_name}\s*?
728
733
  (?:<\s+[:,\w]+)?\n((?>.*?\*/))%xm then
@@ -737,7 +742,7 @@ class RDoc::Parser::C < RDoc::Parser
737
742
  comment = ''
738
743
  end
739
744
 
740
- comment = RDoc::Comment.new comment, @top_level, :c
745
+ comment = new_comment comment, @top_level, :c
741
746
  comment.normalize
742
747
 
743
748
  look_for_directives_in class_mod, comment
@@ -782,7 +787,7 @@ class RDoc::Parser::C < RDoc::Parser
782
787
  table[const_name] ||
783
788
  ''
784
789
 
785
- RDoc::Comment.new comment, @top_level, :c
790
+ new_comment comment, @top_level, :c
786
791
  end
787
792
 
788
793
  ##
@@ -813,7 +818,7 @@ class RDoc::Parser::C < RDoc::Parser
813
818
 
814
819
  return unless comment
815
820
 
816
- RDoc::Comment.new comment, @top_level, :c
821
+ new_comment comment, @top_level, :c
817
822
  end
818
823
 
819
824
  ##
@@ -822,8 +827,8 @@ class RDoc::Parser::C < RDoc::Parser
822
827
 
823
828
  def handle_attr(var_name, attr_name, read, write)
824
829
  rw = ''
825
- rw += 'R' if '1' == read
826
- rw += 'W' if '1' == write
830
+ rw += 'R' if TRUE_VALUES.include?(read)
831
+ rw += 'W' if TRUE_VALUES.include?(write)
827
832
 
828
833
  class_name = @known_classes[var_name]
829
834
 
@@ -919,7 +924,7 @@ class RDoc::Parser::C < RDoc::Parser
919
924
 
920
925
  return unless class_name
921
926
 
922
- class_obj = find_class var_name, class_name
927
+ class_obj = find_class var_name, class_name, class_name[/::\K[^:]+\z/]
923
928
 
924
929
  unless class_obj then
925
930
  @options.warn 'Enclosing class or module %p is not known' % [const_name]
@@ -933,21 +938,20 @@ class RDoc::Parser::C < RDoc::Parser
933
938
  # "/* definition: comment */" form. The literal ':' and '\' characters
934
939
  # can be escaped with a backslash.
935
940
  if type.downcase == 'const' then
936
- no_match, new_definition, new_comment = comment.text.split(/(\A.*):/)
941
+ if /\A(.+?)?:(?!\S)/ =~ comment.text
942
+ new_definition, new_comment = $1, $'
937
943
 
938
- if no_match and no_match.empty? then
939
- if new_definition.empty? then # Default to literal C definition
944
+ if !new_definition # Default to literal C definition
940
945
  new_definition = definition
941
946
  else
942
- new_definition = new_definition.gsub("\:", ":")
943
- new_definition = new_definition.gsub("\\", '\\')
947
+ new_definition = new_definition.gsub(/\\([\\:])/, '\1')
944
948
  end
945
949
 
946
950
  new_definition.sub!(/\A(\s+)/, '')
947
951
 
948
952
  new_comment = "#{$1}#{new_comment.lstrip}"
949
953
 
950
- new_comment = RDoc::Comment.new new_comment, @top_level, :c
954
+ new_comment = self.new_comment(new_comment, @top_level, :c)
951
955
 
952
956
  con = RDoc::Constant.new const_name, new_definition, new_comment
953
957
  else
@@ -1023,12 +1027,18 @@ class RDoc::Parser::C < RDoc::Parser
1023
1027
  elsif p_count == -1 then # argc, argv
1024
1028
  rb_scan_args body
1025
1029
  else
1026
- "(#{(1..p_count).map { |i| "p#{i}" }.join ', '})"
1030
+ args = (1..p_count).map { |i| "p#{i}" }
1031
+ "(#{args.join ', '})"
1027
1032
  end
1028
1033
 
1029
1034
 
1030
1035
  meth_obj.record_location @top_level
1036
+
1037
+ if meth_obj.section_title
1038
+ class_obj.temporary_section = class_obj.add_section(meth_obj.section_title)
1039
+ end
1031
1040
  class_obj.add_method meth_obj
1041
+
1032
1042
  @stats.add_method meth_obj
1033
1043
  meth_obj.visibility = :private if 'private_method' == type
1034
1044
  end
@@ -1045,23 +1055,6 @@ class RDoc::Parser::C < RDoc::Parser
1045
1055
  @singleton_classes[sclass_var] = class_name
1046
1056
  end
1047
1057
 
1048
- ##
1049
- # Normalizes tabs in +body+
1050
-
1051
- def handle_tab_width(body)
1052
- if /\t/ =~ body
1053
- tab_width = @options.tab_width
1054
- body.split(/\n/).map do |line|
1055
- 1 while line.gsub!(/\t+/) do
1056
- ' ' * (tab_width * $&.length - $`.length % tab_width)
1057
- end && $~
1058
- line
1059
- end.join "\n"
1060
- else
1061
- body
1062
- end
1063
- end
1064
-
1065
1058
  ##
1066
1059
  # Loads the variable map with the given +name+ from the RDoc::Store, if
1067
1060
  # present.
@@ -1222,4 +1215,12 @@ class RDoc::Parser::C < RDoc::Parser
1222
1215
  @top_level
1223
1216
  end
1224
1217
 
1218
+ ##
1219
+ # Creates a RDoc::Comment instance.
1220
+
1221
+ def new_comment text = nil, location = nil, language = nil
1222
+ RDoc::Comment.new(text, location, language).tap do |comment|
1223
+ comment.format = @markup
1224
+ end
1225
+ end
1225
1226
  end