rdoc 6.4.1.1 → 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 (60) 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 +2 -2
  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 +17 -1
  10. data/lib/rdoc/generator/markup.rb +1 -1
  11. data/lib/rdoc/generator/template/darkfish/_head.rhtml +10 -10
  12. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +27 -3
  13. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +22 -2
  14. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +25 -4
  15. data/lib/rdoc/generator/template/darkfish/class.rhtml +22 -20
  16. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +24 -1
  17. data/lib/rdoc/generator/template/darkfish/index.rhtml +1 -1
  18. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +1 -1
  19. data/lib/rdoc/generator/template/darkfish/js/search.js +1 -1
  20. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +2 -2
  21. data/lib/rdoc/generator.rb +5 -5
  22. data/lib/rdoc/i18n.rb +1 -1
  23. data/lib/rdoc/known_classes.rb +5 -4
  24. data/lib/rdoc/markdown/literals.rb +43 -66
  25. data/lib/rdoc/markdown.kpeg +25 -18
  26. data/lib/rdoc/markdown.rb +252 -194
  27. data/lib/rdoc/markup/attribute_manager.rb +29 -35
  28. data/lib/rdoc/markup/parser.rb +12 -6
  29. data/lib/rdoc/markup/to_html.rb +18 -14
  30. data/lib/rdoc/markup/to_label.rb +1 -1
  31. data/lib/rdoc/markup/to_rdoc.rb +3 -20
  32. data/lib/rdoc/markup.rb +35 -667
  33. data/lib/rdoc/method_attr.rb +1 -1
  34. data/lib/rdoc/normal_class.rb +1 -1
  35. data/lib/rdoc/normal_module.rb +1 -1
  36. data/lib/rdoc/options.rb +33 -18
  37. data/lib/rdoc/parser/c.rb +89 -101
  38. data/lib/rdoc/parser/ruby.rb +25 -10
  39. data/lib/rdoc/parser.rb +19 -2
  40. data/lib/rdoc/rd/block_parser.rb +14 -12
  41. data/lib/rdoc/rd/block_parser.ry +12 -8
  42. data/lib/rdoc/rd/inline_parser.rb +2 -4
  43. data/lib/rdoc/rd.rb +3 -4
  44. data/lib/rdoc/rdoc.rb +17 -3
  45. data/lib/rdoc/ri/driver.rb +11 -78
  46. data/lib/rdoc/ri.rb +4 -5
  47. data/lib/rdoc/rubygems_hook.rb +1 -1
  48. data/lib/rdoc/servlet.rb +1 -1
  49. data/lib/rdoc/single_class.rb +5 -0
  50. data/lib/rdoc/stats.rb +3 -4
  51. data/lib/rdoc/store.rb +19 -26
  52. data/lib/rdoc/task.rb +3 -3
  53. data/lib/rdoc/version.rb +3 -1
  54. data/lib/rdoc.rb +46 -46
  55. metadata +7 -9
  56. data/Gemfile +0 -12
  57. data/Rakefile +0 -107
  58. data/bin/console +0 -7
  59. data/bin/setup +0 -6
  60. 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
@@ -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,7 +1293,7 @@ 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
 
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
 
@@ -259,18 +264,18 @@ class RDoc::Parser::C < RDoc::Parser
259
264
  @content.scan(/rb_attr\s*\(
260
265
  \s*(\w+),
261
266
  \s*([\w"()]+),
262
- \s*([01]),
263
- \s*([01]),
264
- \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|
265
270
  handle_attr var_name, attr_name, read, write
266
271
  end
267
272
 
268
273
  @content.scan(%r%rb_define_attr\(
269
274
  \s*([\w\.]+),
270
275
  \s*"([^"]+)",
271
- \s*(\d+),
272
- \s*(\d+)\s*\);
273
- %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|
274
279
  handle_attr var_name, attr_name, read, write
275
280
  end
276
281
  end
@@ -295,94 +300,92 @@ class RDoc::Parser::C < RDoc::Parser
295
300
 
296
301
  @content.scan(
297
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
+
298
312
  (?<var_name>[\w\.]+)\s* =
299
313
  \s*rb_(?:
300
314
  define_(?:
301
- class(?: # rb_define_class(class_name_1, parent_name_1)
302
- \s*\(
303
- \s*"(?<class_name_1>\w+)",
304
- \s*(?<parent_name_1>\w+)\s*
305
- \)
306
- |
307
- _under\s*\( # rb_define_class_under(class_under, class_name2, parent_name2...)
308
- \s* (?<class_under>\w+),
309
- \s* "(?<class_name_2>\w+)",
310
- \s*
311
- (?:
312
- (?<parent_name_2>[\w\*\s\(\)\.\->]+) |
313
- rb_path2class\("(?<path>[\w:]+)"\)
314
- )
315
+ class(?: # rb_define_class(name, parent_name)
316
+ \(\s*
317
+ \g<name>,
318
+ \g<parent>
315
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>
316
326
  )
317
327
  |
318
- module(?: # rb_define_module(module_name_1)
319
- \s*\(
320
- \s*"(?<module_name_1>\w+)"\s*
321
- \)
328
+ (?<module>)
329
+ module(?: # rb_define_module(name)
330
+ \g<open>
331
+ \g<name>
332
+ \g<close>
322
333
  |
323
- _under\s*\( # rb_define_module_under(module_under, module_name_2)
324
- \s*(?<module_under>\w+),
325
- \s*"(?<module_name_2>\w+)"
326
- \s*\)
334
+ _under\g<open> # rb_define_module_under(under, name)
335
+ \g<under>,
336
+ \g<name>
337
+ \g<close>
327
338
  )
328
339
  )
329
340
  |
330
- struct_define_without_accessor\s*\( # rb_struct_define_without_accessor(class_name_3, parent_name_3, ...)
331
- \s*"(?<class_name_3>\w+)",
332
- \s*(?<parent_name_3>\w+),
333
- \s*\w+, # Allocation function
334
- (?:\s*"\w+",)* # Attributes
335
- \s*NULL
336
- \)
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>
337
362
  |
338
- singleton_class\s*\( # rb_singleton_class(target_class_name)
339
- \s*(?<target_class_name>\w+)
340
- \)
363
+ singleton_class\g<open> # rb_singleton_class(target_class_name)
364
+ (?<target_class_name>\w+)
365
+ \g<close>
341
366
  )
342
367
  )mx
343
368
  ) do
344
- class_name = $~[:class_name_1]
345
- type = :class
346
- if class_name
347
- # rb_define_class(class_name_1, parent_name_1)
348
- parent_name = $~[:parent_name_1]
349
- #under = nil
350
- else
351
- class_name = $~[:class_name_2]
352
- if class_name
353
- # rb_define_class_under(class_under, class_name2, parent_name2...)
354
- parent_name = $~[:parent_name_2] || $~[:path]
355
- under = $~[:class_under]
356
- else
357
- class_name = $~[:class_name_3]
358
- if class_name
359
- # rb_struct_define_without_accessor(class_name_3, parent_name_3, ...)
360
- parent_name = $~[:parent_name_3]
361
- #under = nil
362
- else
363
- type = :module
364
- class_name = $~[:module_name_1]
365
- #parent_name = nil
366
- if class_name
367
- # rb_define_module(module_name_1)
368
- #under = nil
369
- else
370
- class_name = $~[:module_name_2]
371
- if class_name
372
- # rb_define_module_under(module_under, module_name_1)
373
- under = $~[:module_under]
374
- else
375
- # rb_singleton_class(target_class_name)
376
- target_class_name = $~[:target_class_name]
377
- handle_singleton $~[:var_name], target_class_name
378
- next
379
- end
380
- end
381
- end
382
- 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
383
373
  end
384
374
 
385
- 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
386
389
  end
387
390
  end
388
391
 
@@ -677,13 +680,14 @@ class RDoc::Parser::C < RDoc::Parser
677
680
  ##
678
681
  # Finds a RDoc::NormalClass or RDoc::NormalModule for +raw_name+
679
682
 
680
- def find_class(raw_name, name)
683
+ def find_class(raw_name, name, base_name = nil)
681
684
  unless @classes[raw_name]
682
685
  if raw_name =~ /^rb_m/
683
686
  container = @top_level.add_module RDoc::NormalModule, name
684
687
  else
685
688
  container = @top_level.add_class RDoc::NormalClass, name
686
689
  end
690
+ container.name = base_name if base_name
687
691
 
688
692
  container.record_location @top_level
689
693
  @classes[raw_name] = container
@@ -724,7 +728,7 @@ class RDoc::Parser::C < RDoc::Parser
724
728
  ((?>/\*.*?\*/\s+))
725
729
  (static\s+)?
726
730
  void\s+
727
- Init_#{class_name}\s*(?:_\(\s*)?\(\s*(?:void\s*)?\)%xmi then
731
+ Init(?:VM)?_(?i:#{class_name})\s*(?:_\(\s*)?\(\s*(?:void\s*)?\)%xm then
728
732
  comment = $1.sub(%r%Document-(?:class|module):\s+#{class_name}%, '')
729
733
  elsif @content =~ %r%Document-(?:class|module):\s+#{class_name}\s*?
730
734
  (?:<\s+[:,\w]+)?\n((?>.*?\*/))%xm then
@@ -824,8 +828,8 @@ class RDoc::Parser::C < RDoc::Parser
824
828
 
825
829
  def handle_attr(var_name, attr_name, read, write)
826
830
  rw = ''
827
- rw += 'R' if '1' == read
828
- rw += 'W' if '1' == write
831
+ rw += 'R' if TRUE_VALUES.include?(read)
832
+ rw += 'W' if TRUE_VALUES.include?(write)
829
833
 
830
834
  class_name = @known_classes[var_name]
831
835
 
@@ -921,7 +925,7 @@ class RDoc::Parser::C < RDoc::Parser
921
925
 
922
926
  return unless class_name
923
927
 
924
- class_obj = find_class var_name, class_name
928
+ class_obj = find_class var_name, class_name, class_name[/::\K[^:]+\z/]
925
929
 
926
930
  unless class_obj then
927
931
  @options.warn 'Enclosing class or module %p is not known' % [const_name]
@@ -1025,7 +1029,8 @@ class RDoc::Parser::C < RDoc::Parser
1025
1029
  elsif p_count == -1 then # argc, argv
1026
1030
  rb_scan_args body
1027
1031
  else
1028
- "(#{(1..p_count).map { |i| "p#{i}" }.join ', '})"
1032
+ args = (1..p_count).map { |i| "p#{i}" }
1033
+ "(#{args.join ', '})"
1029
1034
  end
1030
1035
 
1031
1036
 
@@ -1052,23 +1057,6 @@ class RDoc::Parser::C < RDoc::Parser
1052
1057
  @singleton_classes[sclass_var] = class_name
1053
1058
  end
1054
1059
 
1055
- ##
1056
- # Normalizes tabs in +body+
1057
-
1058
- def handle_tab_width(body)
1059
- if /\t/ =~ body
1060
- tab_width = @options.tab_width
1061
- body.split(/\n/).map do |line|
1062
- 1 while line.gsub!(/\t+/) do
1063
- ' ' * (tab_width * $&.length - $`.length % tab_width)
1064
- end && $~
1065
- line
1066
- end.join "\n"
1067
- else
1068
- body
1069
- end
1070
- end
1071
-
1072
1060
  ##
1073
1061
  # Loads the variable map with the given +name+ from the RDoc::Store, if
1074
1062
  # present.
@@ -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
data/lib/rdoc/parser.rb CHANGED
@@ -263,9 +263,26 @@ class RDoc::Parser
263
263
  @preprocess.options = @options
264
264
  end
265
265
 
266
- autoload :RubyTools, 'rdoc/parser/ruby_tools'
267
- autoload :Text, 'rdoc/parser/text'
266
+ autoload :RubyTools, "#{__dir__}/parser/ruby_tools"
267
+ autoload :Text, "#{__dir__}/parser/text"
268
268
 
269
+ ##
270
+ # Normalizes tabs in +body+
271
+
272
+ def handle_tab_width(body)
273
+ if /\t/ =~ body
274
+ tab_width = @options.tab_width
275
+ body.split(/\n/).map do |line|
276
+ 1 while line.gsub!(/\t+/) do
277
+ b, e = $~.offset(0)
278
+ ' ' * (tab_width * (e-b) - b % tab_width)
279
+ end
280
+ line
281
+ end.join "\n"
282
+ else
283
+ body
284
+ end
285
+ end
269
286
  end
270
287
 
271
288
  # simple must come first in order to show up last in the parsers list
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
  #
3
3
  # DO NOT MODIFY!!!!
4
- # This file is automatically generated by Racc 1.7.3
5
- # from Racc grammar file "block_parser.ry".
4
+ # This file is automatically generated by Racc 1.6.0
5
+ # from Racc grammar file "".
6
6
  #
7
7
 
8
8
  require 'racc/parser.rb'
@@ -18,8 +18,6 @@ class BlockParser < Racc::Parser
18
18
 
19
19
  # :stopdoc:
20
20
 
21
- TMPFILE = ["rdtmp", $$, 0]
22
-
23
21
  MARK_TO_LEVEL = {
24
22
  '=' => 1,
25
23
  '==' => 2,
@@ -129,15 +127,19 @@ def next_token # :nodoc:
129
127
  # non-RD part begin
130
128
  when /^=begin\s+(\w+)/
131
129
  part = $1
130
+ =begin # not imported to RDoc
132
131
  if @in_part # if in non-RD part
133
132
  @part_content.push(line)
134
133
  else
135
134
  @in_part = part if @tree.filter[part] # if filter exists
136
135
  # p "BEGIN_PART: #{@in_part}" # DEBUG
137
136
  end
137
+ =end
138
+ @in_part = part
138
139
  # non-RD part end
139
- when /^=end/
140
+ when /^=end(?:$|[\s\0\C-d\C-z])/
140
141
  if @in_part # if in non-RD part
142
+ =begin # not imported to RDoc
141
143
  # p "END_PART: #{@in_part}" # DEBUG
142
144
  # make Part-in object
143
145
  part = RDoc::RD::Part.new(@part_content.join(""), @tree, "r")
@@ -148,20 +150,22 @@ def next_token # :nodoc:
148
150
  if @tree.filter[@in_part].mode == :rd # if output is RD formatted
149
151
  subtree = parse_subtree(part_out.to_a)
150
152
  else # if output is target formatted
151
- basename = TMPFILE.join('.')
152
- TMPFILE[-1] += 1
153
- tmpfile = open(@tree.tmp_dir + "/" + basename + ".#{@in_part}", "w")
154
- tmpfile.print(part_out)
155
- tmpfile.close
153
+ basename = Tempfile.create(["rdtmp", ".#{@in_part}"], @tree.tmp_dir) do |tmpfile|
154
+ tmpfile.print(part_out)
155
+ File.basename(tmpfile.path)
156
+ end
156
157
  subtree = parse_subtree(["=begin\n", "<<< #{basename}\n", "=end\n"])
157
158
  end
158
159
  @in_part = nil
159
160
  return [:SUBTREE, subtree]
161
+ =end
160
162
  end
161
163
  else
164
+ =begin # not imported to RDoc
162
165
  if @in_part # if in non-RD part
163
166
  @part_content.push(line)
164
167
  end
168
+ =end
165
169
  end
166
170
  end
167
171
 
@@ -620,7 +624,6 @@ Racc_arg = [
620
624
  racc_shift_n,
621
625
  racc_reduce_n,
622
626
  racc_use_result_var ]
623
- Ractor.make_shareable(Racc_arg) if defined?(Ractor)
624
627
 
625
628
  Racc_token_to_s_table = [
626
629
  "$end",
@@ -671,7 +674,6 @@ Racc_token_to_s_table = [
671
674
  "blocks_in_list",
672
675
  "block_in_list",
673
676
  "whitelines2" ]
674
- Ractor.make_shareable(Racc_token_to_s_table) if defined?(Ractor)
675
677
 
676
678
  Racc_debug_parser = false
677
679
 
@@ -230,8 +230,6 @@ end
230
230
 
231
231
  # :stopdoc:
232
232
 
233
- TMPFILE = ["rdtmp", $$, 0]
234
-
235
233
  MARK_TO_LEVEL = {
236
234
  '=' => 1,
237
235
  '==' => 2,
@@ -341,15 +339,19 @@ def next_token # :nodoc:
341
339
  # non-RD part begin
342
340
  when /^=begin\s+(\w+)/
343
341
  part = $1
342
+ =begin # not imported to RDoc
344
343
  if @in_part # if in non-RD part
345
344
  @part_content.push(line)
346
345
  else
347
346
  @in_part = part if @tree.filter[part] # if filter exists
348
347
  # p "BEGIN_PART: #{@in_part}" # DEBUG
349
348
  end
349
+ =end
350
+ @in_part = part
350
351
  # non-RD part end
351
- when /^=end/
352
+ when /^=end(?:$|[\s\0\C-d\C-z])/
352
353
  if @in_part # if in non-RD part
354
+ =begin # not imported to RDoc
353
355
  # p "END_PART: #{@in_part}" # DEBUG
354
356
  # make Part-in object
355
357
  part = RDoc::RD::Part.new(@part_content.join(""), @tree, "r")
@@ -360,20 +362,22 @@ def next_token # :nodoc:
360
362
  if @tree.filter[@in_part].mode == :rd # if output is RD formatted
361
363
  subtree = parse_subtree(part_out.to_a)
362
364
  else # if output is target formatted
363
- basename = TMPFILE.join('.')
364
- TMPFILE[-1] += 1
365
- tmpfile = open(@tree.tmp_dir + "/" + basename + ".#{@in_part}", "w")
366
- tmpfile.print(part_out)
367
- tmpfile.close
365
+ basename = Tempfile.create(["rdtmp", ".#{@in_part}"], @tree.tmp_dir) do |tmpfile|
366
+ tmpfile.print(part_out)
367
+ File.basename(tmpfile.path)
368
+ end
368
369
  subtree = parse_subtree(["=begin\n", "<<< #{basename}\n", "=end\n"])
369
370
  end
370
371
  @in_part = nil
371
372
  return [:SUBTREE, subtree]
373
+ =end
372
374
  end
373
375
  else
376
+ =begin # not imported to RDoc
374
377
  if @in_part # if in non-RD part
375
378
  @part_content.push(line)
376
379
  end
380
+ =end
377
381
  end
378
382
  end
379
383