rdoc 6.3.3 → 6.5.0

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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.rdoc +1 -2
  3. data/LEGAL.rdoc +1 -1
  4. data/exe/rdoc +0 -1
  5. data/lib/rdoc/any_method.rb +6 -3
  6. data/lib/rdoc/code_objects.rb +1 -2
  7. data/lib/rdoc/context/section.rb +2 -0
  8. data/lib/rdoc/context.rb +1 -3
  9. data/lib/rdoc/cross_reference.rb +44 -20
  10. data/lib/rdoc/generator/darkfish.rb +2 -2
  11. data/lib/rdoc/generator/markup.rb +1 -1
  12. data/lib/rdoc/generator/template/darkfish/_head.rhtml +11 -13
  13. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +27 -3
  14. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +22 -2
  15. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +25 -4
  16. data/lib/rdoc/generator/template/darkfish/class.rhtml +22 -20
  17. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +24 -1
  18. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
  19. data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
  20. data/lib/rdoc/generator/template/darkfish/index.rhtml +1 -1
  21. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +1 -1
  22. data/lib/rdoc/generator/template/darkfish/js/search.js +1 -1
  23. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +2 -2
  24. data/lib/rdoc/generator.rb +5 -5
  25. data/lib/rdoc/i18n.rb +1 -1
  26. data/lib/rdoc/known_classes.rb +5 -4
  27. data/lib/rdoc/markdown/literals.rb +24 -8
  28. data/lib/rdoc/markdown.kpeg +25 -18
  29. data/lib/rdoc/markdown.rb +323 -226
  30. data/lib/rdoc/markup/attribute_manager.rb +29 -35
  31. data/lib/rdoc/markup/parser.rb +12 -6
  32. data/lib/rdoc/markup/pre_process.rb +2 -0
  33. data/lib/rdoc/markup/to_html.rb +20 -16
  34. data/lib/rdoc/markup/to_label.rb +1 -1
  35. data/lib/rdoc/markup/to_rdoc.rb +3 -20
  36. data/lib/rdoc/markup.rb +35 -667
  37. data/lib/rdoc/method_attr.rb +1 -1
  38. data/lib/rdoc/normal_class.rb +1 -1
  39. data/lib/rdoc/normal_module.rb +1 -1
  40. data/lib/rdoc/options.rb +63 -19
  41. data/lib/rdoc/parser/c.rb +110 -110
  42. data/lib/rdoc/parser/ruby.rb +43 -10
  43. data/lib/rdoc/parser.rb +19 -2
  44. data/lib/rdoc/rd/block_parser.rb +13 -9
  45. data/lib/rdoc/rd/block_parser.ry +12 -8
  46. data/lib/rdoc/rd/inline_parser.rb +1 -1
  47. data/lib/rdoc/rd.rb +3 -4
  48. data/lib/rdoc/rdoc.rb +19 -33
  49. data/lib/rdoc/ri/driver.rb +22 -82
  50. data/lib/rdoc/ri.rb +4 -5
  51. data/lib/rdoc/rubygems_hook.rb +4 -2
  52. data/lib/rdoc/servlet.rb +1 -1
  53. data/lib/rdoc/single_class.rb +5 -0
  54. data/lib/rdoc/stats.rb +3 -4
  55. data/lib/rdoc/store.rb +4 -4
  56. data/lib/rdoc/task.rb +3 -3
  57. data/lib/rdoc/text.rb +12 -4
  58. data/lib/rdoc/version.rb +3 -1
  59. data/lib/rdoc.rb +46 -46
  60. metadata +9 -14
  61. data/Gemfile +0 -12
  62. data/Rakefile +0 -101
  63. data/bin/console +0 -7
  64. data/bin/setup +0 -6
  65. data/rdoc.gemspec +0 -249
@@ -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
@@ -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
@@ -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
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,6 +558,11 @@ 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
568
  @rdoc_include << "." if @rdoc_include.empty?
@@ -585,14 +600,14 @@ class RDoc::Options
585
600
  def finish_page_dir
586
601
  return unless @page_dir
587
602
 
588
- @files << @page_dir.to_s
603
+ @files << @page_dir
589
604
 
590
- page_dir = nil
605
+ page_dir = Pathname(@page_dir)
591
606
  begin
592
- page_dir = @page_dir.expand_path.relative_path_from @root
607
+ page_dir = page_dir.expand_path.relative_path_from @root
593
608
  rescue ArgumentError
594
609
  # On Windows, sometimes crosses different drive letters.
595
- page_dir = @page_dir.expand_path
610
+ page_dir = page_dir.expand_path
596
611
  end
597
612
 
598
613
  @page_dir = page_dir
@@ -768,6 +783,13 @@ Usage: #{opt.program_name} [options] [names...]
768
783
 
769
784
  opt.separator nil
770
785
 
786
+ opt.on("--no-skipping-tests", nil,
787
+ "Don't skip generating documentation for test and spec files") do |value|
788
+ @skip_tests = false
789
+ end
790
+
791
+ opt.separator nil
792
+
771
793
  opt.on("--extension=NEW=OLD", "-E",
772
794
  "Treat files ending with .new as if they",
773
795
  "ended with .old. Using '-E cgi=rb' will",
@@ -847,7 +869,7 @@ Usage: #{opt.program_name} [options] [names...]
847
869
  "such files at your project root.",
848
870
  "NOTE: Do not use the same file name in",
849
871
  "the page dir and the root of your project") do |page_dir|
850
- @page_dir = Pathname(page_dir)
872
+ @page_dir = page_dir
851
873
  end
852
874
 
853
875
  opt.separator nil
@@ -971,7 +993,7 @@ Usage: #{opt.program_name} [options] [names...]
971
993
  opt.on("--template-stylesheets=FILES", PathArray,
972
994
  "Set (or add to) the list of files to",
973
995
  "include with the html template.") do |value|
974
- @template_stylesheets << value
996
+ @template_stylesheets.concat value
975
997
  end
976
998
 
977
999
  opt.separator nil
@@ -1159,13 +1181,6 @@ Usage: #{opt.program_name} [options] [names...]
1159
1181
 
1160
1182
  @files = argv.dup
1161
1183
 
1162
- finish
1163
-
1164
- if @write_options then
1165
- write_options
1166
- exit
1167
- end
1168
-
1169
1184
  self
1170
1185
  end
1171
1186
 
@@ -1278,8 +1293,37 @@ Usage: #{opt.program_name} [options] [names...]
1278
1293
  File.open '.rdoc_options', 'w' do |io|
1279
1294
  io.set_encoding Encoding::UTF_8
1280
1295
 
1281
- YAML.dump self, io
1296
+ io.print to_yaml
1282
1297
  end
1283
1298
  end
1284
1299
 
1300
+ ##
1301
+ # Loads options from .rdoc_options if the file exists, otherwise creates a
1302
+ # new RDoc::Options instance.
1303
+
1304
+ def self.load_options
1305
+ options_file = File.expand_path '.rdoc_options'
1306
+ return RDoc::Options.new unless File.exist? options_file
1307
+
1308
+ RDoc.load_yaml
1309
+
1310
+ begin
1311
+ options = YAML.safe_load File.read('.rdoc_options'), permitted_classes: [RDoc::Options, Symbol]
1312
+ rescue Psych::SyntaxError
1313
+ raise RDoc::Error, "#{options_file} is not a valid rdoc options file"
1314
+ end
1315
+
1316
+ return RDoc::Options.new unless options # Allow empty file.
1317
+
1318
+ raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
1319
+ RDoc::Options === options or Hash === options
1320
+
1321
+ if Hash === options
1322
+ # Override the default values with the contents of YAML file.
1323
+ options = RDoc::Options.new options
1324
+ end
1325
+
1326
+ options
1327
+ end
1328
+
1285
1329
  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
  ##
@@ -600,7 +605,7 @@ class RDoc::Parser::C < RDoc::Parser
600
605
 
601
606
  case type
602
607
  when :func_def
603
- comment = RDoc::Comment.new args[0], @top_level, :c
608
+ comment = new_comment args[0], @top_level, :c
604
609
  body = args[1]
605
610
  offset, = args[2]
606
611
 
@@ -630,7 +635,7 @@ class RDoc::Parser::C < RDoc::Parser
630
635
 
631
636
  body
632
637
  when :macro_def
633
- comment = RDoc::Comment.new args[0], @top_level, :c
638
+ comment = new_comment args[0], @top_level, :c
634
639
  body = args[1]
635
640
  offset, = args[2]
636
641
 
@@ -675,13 +680,14 @@ class RDoc::Parser::C < RDoc::Parser
675
680
  ##
676
681
  # Finds a RDoc::NormalClass or RDoc::NormalModule for +raw_name+
677
682
 
678
- def find_class(raw_name, name)
683
+ def find_class(raw_name, name, base_name = nil)
679
684
  unless @classes[raw_name]
680
685
  if raw_name =~ /^rb_m/
681
686
  container = @top_level.add_module RDoc::NormalModule, name
682
687
  else
683
688
  container = @top_level.add_class RDoc::NormalClass, name
684
689
  end
690
+ container.name = base_name if base_name
685
691
 
686
692
  container.record_location @top_level
687
693
  @classes[raw_name] = container
@@ -722,7 +728,7 @@ class RDoc::Parser::C < RDoc::Parser
722
728
  ((?>/\*.*?\*/\s+))
723
729
  (static\s+)?
724
730
  void\s+
725
- Init_#{class_name}\s*(?:_\(\s*)?\(\s*(?:void\s*)?\)%xmi then
731
+ Init(?:VM)?_(?i:#{class_name})\s*(?:_\(\s*)?\(\s*(?:void\s*)?\)%xm then
726
732
  comment = $1.sub(%r%Document-(?:class|module):\s+#{class_name}%, '')
727
733
  elsif @content =~ %r%Document-(?:class|module):\s+#{class_name}\s*?
728
734
  (?:<\s+[:,\w]+)?\n((?>.*?\*/))%xm then
@@ -737,7 +743,7 @@ class RDoc::Parser::C < RDoc::Parser
737
743
  comment = ''
738
744
  end
739
745
 
740
- comment = RDoc::Comment.new comment, @top_level, :c
746
+ comment = new_comment comment, @top_level, :c
741
747
  comment.normalize
742
748
 
743
749
  look_for_directives_in class_mod, comment
@@ -782,7 +788,7 @@ class RDoc::Parser::C < RDoc::Parser
782
788
  table[const_name] ||
783
789
  ''
784
790
 
785
- RDoc::Comment.new comment, @top_level, :c
791
+ new_comment comment, @top_level, :c
786
792
  end
787
793
 
788
794
  ##
@@ -813,7 +819,7 @@ class RDoc::Parser::C < RDoc::Parser
813
819
 
814
820
  return unless comment
815
821
 
816
- RDoc::Comment.new comment, @top_level, :c
822
+ new_comment comment, @top_level, :c
817
823
  end
818
824
 
819
825
  ##
@@ -822,8 +828,8 @@ class RDoc::Parser::C < RDoc::Parser
822
828
 
823
829
  def handle_attr(var_name, attr_name, read, write)
824
830
  rw = ''
825
- rw += 'R' if '1' == read
826
- rw += 'W' if '1' == write
831
+ rw += 'R' if TRUE_VALUES.include?(read)
832
+ rw += 'W' if TRUE_VALUES.include?(write)
827
833
 
828
834
  class_name = @known_classes[var_name]
829
835
 
@@ -919,7 +925,7 @@ class RDoc::Parser::C < RDoc::Parser
919
925
 
920
926
  return unless class_name
921
927
 
922
- class_obj = find_class var_name, class_name
928
+ class_obj = find_class var_name, class_name, class_name[/::\K[^:]+\z/]
923
929
 
924
930
  unless class_obj then
925
931
  @options.warn 'Enclosing class or module %p is not known' % [const_name]
@@ -947,7 +953,7 @@ class RDoc::Parser::C < RDoc::Parser
947
953
 
948
954
  new_comment = "#{$1}#{new_comment.lstrip}"
949
955
 
950
- new_comment = RDoc::Comment.new new_comment, @top_level, :c
956
+ new_comment = self.new_comment(new_comment, @top_level, :c)
951
957
 
952
958
  con = RDoc::Constant.new const_name, new_definition, new_comment
953
959
  else
@@ -1023,12 +1029,18 @@ class RDoc::Parser::C < RDoc::Parser
1023
1029
  elsif p_count == -1 then # argc, argv
1024
1030
  rb_scan_args body
1025
1031
  else
1026
- "(#{(1..p_count).map { |i| "p#{i}" }.join ', '})"
1032
+ args = (1..p_count).map { |i| "p#{i}" }
1033
+ "(#{args.join ', '})"
1027
1034
  end
1028
1035
 
1029
1036
 
1030
1037
  meth_obj.record_location @top_level
1038
+
1039
+ if meth_obj.section_title
1040
+ class_obj.temporary_section = class_obj.add_section(meth_obj.section_title)
1041
+ end
1031
1042
  class_obj.add_method meth_obj
1043
+
1032
1044
  @stats.add_method meth_obj
1033
1045
  meth_obj.visibility = :private if 'private_method' == type
1034
1046
  end
@@ -1045,23 +1057,6 @@ class RDoc::Parser::C < RDoc::Parser
1045
1057
  @singleton_classes[sclass_var] = class_name
1046
1058
  end
1047
1059
 
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
1060
  ##
1066
1061
  # Loads the variable map with the given +name+ from the RDoc::Store, if
1067
1062
  # present.
@@ -1222,4 +1217,9 @@ class RDoc::Parser::C < RDoc::Parser
1222
1217
  @top_level
1223
1218
  end
1224
1219
 
1220
+ def new_comment text = nil, location = nil, language = nil
1221
+ RDoc::Comment.new(text, location, language).tap do |comment|
1222
+ comment.format = @markup
1223
+ end
1224
+ end
1225
1225
  end
@@ -164,15 +164,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
164
164
  def initialize(top_level, file_name, content, options, stats)
165
165
  super
166
166
 
167
- if /\t/ =~ content then
168
- tab_width = @options.tab_width
169
- content = content.split(/\n/).map do |line|
170
- 1 while line.gsub!(/\t+/) {
171
- ' ' * (tab_width*$&.length - $`.length % tab_width)
172
- } && $~
173
- line
174
- end.join("\n")
175
- end
167
+ content = handle_tab_width(content)
176
168
 
177
169
  @size = 0
178
170
  @token_listeners = nil
@@ -399,6 +391,29 @@ class RDoc::Parser::Ruby < RDoc::Parser
399
391
  return [container, name_t, given_name, new_modules]
400
392
  end
401
393
 
394
+ ##
395
+ # Skip opening parentheses and yield the block.
396
+ # Skip closing parentheses too when exists.
397
+
398
+ def skip_parentheses(&block)
399
+ left_tk = peek_tk
400
+
401
+ if :on_lparen == left_tk[:kind]
402
+ get_tk
403
+
404
+ ret = skip_parentheses(&block)
405
+
406
+ right_tk = peek_tk
407
+ if :on_rparen == right_tk[:kind]
408
+ get_tk
409
+ end
410
+
411
+ ret
412
+ else
413
+ yield
414
+ end
415
+ end
416
+
402
417
  ##
403
418
  # Return a superclass, which can be either a constant of an expression
404
419
 
@@ -833,7 +848,7 @@ class RDoc::Parser::Ruby < RDoc::Parser
833
848
  cls = parse_class_regular container, declaration_context, single,
834
849
  name_t, given_name, comment
835
850
  elsif name_t[:kind] == :on_op && name_t[:text] == '<<'
836
- case name = get_class_specification
851
+ case name = skip_parentheses { get_class_specification }
837
852
  when 'self', container.name
838
853
  read_documentation_modifiers cls, RDoc::CLASS_MODIFIERS
839
854
  parse_statements container, SINGLE
@@ -1193,6 +1208,22 @@ class RDoc::Parser::Ruby < RDoc::Parser
1193
1208
  end
1194
1209
  end
1195
1210
 
1211
+ ##
1212
+ # Parses an +included+ with a block feature of ActiveSupport::Concern.
1213
+
1214
+ def parse_included_with_activesupport_concern container, comment # :nodoc:
1215
+ skip_tkspace_without_nl
1216
+ tk = get_tk
1217
+ unless tk[:kind] == :on_lbracket || (tk[:kind] == :on_kw && tk[:text] == 'do')
1218
+ unget_tk tk
1219
+ return nil # should be a block
1220
+ end
1221
+
1222
+ parse_statements container
1223
+
1224
+ container
1225
+ end
1226
+
1196
1227
  ##
1197
1228
  # Parses identifiers that can create new methods or change visibility.
1198
1229
  #
@@ -1893,6 +1924,8 @@ class RDoc::Parser::Ruby < RDoc::Parser
1893
1924
  parse_extend_or_include RDoc::Include, container, comment
1894
1925
  when "extend" then
1895
1926
  parse_extend_or_include RDoc::Extend, container, comment
1927
+ when "included" then
1928
+ parse_included_with_activesupport_concern container, comment
1896
1929
  end
1897
1930
 
1898
1931
  else