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
data/lib/rdoc/rdoc.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'rdoc'
2
+ require_relative '../rdoc'
3
3
 
4
4
  require 'find'
5
5
  require 'fileutils'
@@ -14,7 +14,7 @@ require 'time'
14
14
  # is:
15
15
  #
16
16
  # rdoc = RDoc::RDoc.new
17
- # options = rdoc.load_options # returns an RDoc::Options instance
17
+ # options = RDoc::Options.load_options # returns an RDoc::Options instance
18
18
  # # set extra options
19
19
  # rdoc.document options
20
20
  #
@@ -35,6 +35,17 @@ class RDoc::RDoc
35
35
 
36
36
  GENERATORS = {}
37
37
 
38
+ ##
39
+ # List of directory names always skipped
40
+
41
+ UNCONDITIONALLY_SKIPPED_DIRECTORIES = %w[CVS .svn .git].freeze
42
+
43
+ ##
44
+ # List of directory names skipped if test suites should be skipped
45
+
46
+ TEST_SUITE_DIRECTORY_NAMES = %w[spec test].freeze
47
+
48
+
38
49
  ##
39
50
  # Generator instance used for creating output
40
51
 
@@ -108,7 +119,7 @@ class RDoc::RDoc
108
119
  # +files+.
109
120
 
110
121
  def gather_files files
111
- files = ["."] if files.empty?
122
+ files = [@options.root.to_s] if files.empty?
112
123
 
113
124
  file_list = normalized_file_list files, true, @options.exclude
114
125
 
@@ -151,34 +162,6 @@ class RDoc::RDoc
151
162
  end
152
163
  end
153
164
 
154
- ##
155
- # Loads options from .rdoc_options if the file exists, otherwise creates a
156
- # new RDoc::Options instance.
157
-
158
- def load_options
159
- options_file = File.expand_path '.rdoc_options'
160
- return RDoc::Options.new unless File.exist? options_file
161
-
162
- RDoc.load_yaml
163
-
164
- begin
165
- options = YAML.load_file '.rdoc_options'
166
- rescue Psych::SyntaxError
167
- end
168
-
169
- return RDoc::Options.new if options == false # Allow empty file.
170
-
171
- raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
172
- RDoc::Options === options or Hash === options
173
-
174
- if Hash === options
175
- # Override the default values with the contents of YAML file.
176
- options = RDoc::Options.new options
177
- end
178
-
179
- options
180
- end
181
-
182
165
  ##
183
166
  # Create an output dir if it doesn't exist. If it does exist, but doesn't
184
167
  # contain the flag file <tt>created.rid</tt> then we refuse to use it, as
@@ -308,7 +291,10 @@ option)
308
291
  file_list[rel_file_name] = mtime
309
292
  end
310
293
  when "directory" then
311
- next if rel_file_name == "CVS" || rel_file_name == ".svn"
294
+ next if UNCONDITIONALLY_SKIPPED_DIRECTORIES.include?(rel_file_name)
295
+
296
+ basename = File.basename(rel_file_name)
297
+ next if options.skip_tests && TEST_SUITE_DIRECTORY_NAMES.include?(basename)
312
298
 
313
299
  created_rid = File.join rel_file_name, "created.rid"
314
300
  next if File.file? created_rid
@@ -443,9 +429,7 @@ The internal error was:
443
429
  files.reject do |file, *|
444
430
  file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)$/i or
445
431
  (file =~ /tags$/i and
446
- File.open(file, 'rb') { |io|
447
- io.read(100) =~ /\A(\f\n[^,]+,\d+$|!_TAG_)/
448
- })
432
+ /\A(\f\n[^,]+,\d+$|!_TAG_)/.match?(File.binread(file, 100)))
449
433
  end
450
434
  end
451
435
 
@@ -468,11 +452,11 @@ The internal error was:
468
452
 
469
453
  if RDoc::Options === options then
470
454
  @options = options
471
- @options.finish
472
455
  else
473
- @options = load_options
456
+ @options = RDoc::Options.load_options
474
457
  @options.parse options
475
458
  end
459
+ @options.finish
476
460
 
477
461
  if @options.pipe then
478
462
  handle_pipe
data/lib/rdoc/require.rb CHANGED
@@ -49,4 +49,3 @@ class RDoc::Require < RDoc::CodeObject
49
49
  end
50
50
 
51
51
  end
52
-
@@ -1,23 +1,10 @@
1
1
  # frozen_string_literal: true
2
- require 'abbrev'
3
2
  require 'optparse'
4
3
 
5
- begin
6
- require 'readline'
7
- rescue LoadError
8
- end
9
-
10
- begin
11
- require 'win32console'
12
- rescue LoadError
13
- end
14
-
15
- require 'rdoc'
16
-
17
- ##
18
- # For RubyGems backwards compatibility
4
+ require_relative '../../rdoc'
19
5
 
20
- require_relative 'formatter'
6
+ require_relative 'formatter' # For RubyGems backwards compatibility
7
+ # TODO: Fix weird documentation with `require_relative`
21
8
 
22
9
  ##
23
10
  # The RI driver implements the command-line ri tool.
@@ -47,9 +34,9 @@ class RDoc::RI::Driver
47
34
 
48
35
  class NotFoundError < Error
49
36
 
50
- def initialize(klass, suggestions = nil) # :nodoc:
37
+ def initialize(klass, suggestion_proc = nil) # :nodoc:
51
38
  @klass = klass
52
- @suggestions = suggestions
39
+ @suggestion_proc = suggestion_proc
53
40
  end
54
41
 
55
42
  ##
@@ -61,8 +48,9 @@ class RDoc::RI::Driver
61
48
 
62
49
  def message # :nodoc:
63
50
  str = "Nothing known about #{@klass}"
64
- if @suggestions and !@suggestions.empty?
65
- str += "\nDid you mean? #{@suggestions.join("\n ")}"
51
+ suggestions = @suggestion_proc&.call
52
+ if suggestions and !suggestions.empty?
53
+ str += "\nDid you mean? #{suggestions.join("\n ")}"
66
54
  end
67
55
  str
68
56
  end
@@ -142,6 +130,8 @@ Where name can be:
142
130
 
143
131
  gem_name: | gem_name:README | gem_name:History
144
132
 
133
+ ruby: | ruby:NEWS | ruby:globals
134
+
145
135
  All class names may be abbreviated to their minimum unambiguous form.
146
136
  If a name is ambiguous, all valid options will be listed.
147
137
 
@@ -153,6 +143,10 @@ they're contained in. If the gem name is followed by a ':' all files in the
153
143
  gem will be shown. The file name extension may be omitted where it is
154
144
  unambiguous.
155
145
 
146
+ 'ruby' can be used as a pseudo gem name to display files from the Ruby
147
+ core documentation. Use 'ruby:' by itself to get a list of all available
148
+ core documentation files.
149
+
156
150
  For example:
157
151
 
158
152
  #{opt.program_name} Fil
@@ -160,6 +154,7 @@ For example:
160
154
  #{opt.program_name} File.new
161
155
  #{opt.program_name} zip
162
156
  #{opt.program_name} rdoc:README
157
+ #{opt.program_name} ruby:comments
163
158
 
164
159
  Note that shell quoting or escaping may be required for method names
165
160
  containing punctuation:
@@ -426,9 +421,6 @@ or the PAGER environment variable.
426
421
  @use_stdout = options[:use_stdout]
427
422
  @show_all = options[:show_all]
428
423
  @width = options[:width]
429
-
430
- # pager process for jruby
431
- @jruby_pager_process = nil
432
424
  end
433
425
 
434
426
  ##
@@ -609,11 +601,11 @@ or the PAGER environment variable.
609
601
 
610
602
  stores = classes[current]
611
603
 
612
- break unless stores and not stores.empty?
604
+ next unless stores and not stores.empty?
613
605
 
614
- klasses = stores.map do |store|
615
- store.ancestors[current]
616
- end.flatten.uniq
606
+ klasses = stores.flat_map do |store|
607
+ store.ancestors[current] || []
608
+ end.uniq
617
609
 
618
610
  klasses = klasses - seen
619
611
 
@@ -957,8 +949,8 @@ or the PAGER environment variable.
957
949
  ary = class_names.grep(Regexp.new("\\A#{klass.gsub(/(?=::|\z)/, '[^:]*')}\\z"))
958
950
  if ary.length != 1 && ary.first != klass
959
951
  if check_did_you_mean
960
- suggestions = DidYouMean::SpellChecker.new(dictionary: class_names).correct(klass)
961
- raise NotFoundError.new(klass, suggestions)
952
+ suggestion_proc = -> { DidYouMean::SpellChecker.new(dictionary: class_names).correct(klass) }
953
+ raise NotFoundError.new(klass, suggestion_proc)
962
954
  else
963
955
  raise NotFoundError, klass
964
956
  end
@@ -1044,36 +1036,6 @@ or the PAGER environment variable.
1044
1036
  self
1045
1037
  end
1046
1038
 
1047
- ##
1048
- # Finds the given +pager+ for jruby. Returns an IO if +pager+ was found.
1049
- #
1050
- # Returns false if +pager+ does not exist.
1051
- #
1052
- # Returns nil if the jruby JVM doesn't support ProcessBuilder redirection
1053
- # (1.6 and older).
1054
-
1055
- def find_pager_jruby pager
1056
- require 'java'
1057
- require 'shellwords'
1058
-
1059
- return nil unless java.lang.ProcessBuilder.constants.include? :Redirect
1060
-
1061
- pager = Shellwords.split pager
1062
-
1063
- pb = java.lang.ProcessBuilder.new(*pager)
1064
- pb = pb.redirect_output java.lang.ProcessBuilder::Redirect::INHERIT
1065
-
1066
- @jruby_pager_process = pb.start
1067
-
1068
- input = @jruby_pager_process.output_stream
1069
-
1070
- io = input.to_io
1071
- io.sync = true
1072
- io
1073
- rescue java.io.IOException
1074
- false
1075
- end
1076
-
1077
1039
  ##
1078
1040
  # Finds a store that matches +name+ which can be the name of a gem, "ruby",
1079
1041
  # "home" or "site".
@@ -1113,6 +1075,10 @@ or the PAGER environment variable.
1113
1075
  def interactive
1114
1076
  puts "\nEnter the method name you want to look up."
1115
1077
 
1078
+ begin
1079
+ require 'readline'
1080
+ rescue LoadError
1081
+ end
1116
1082
  if defined? Readline then
1117
1083
  Readline.completion_proc = method :complete
1118
1084
  puts "You can use tab to autocomplete."
@@ -1141,17 +1107,6 @@ or the PAGER environment variable.
1141
1107
  exit
1142
1108
  end
1143
1109
 
1144
- ##
1145
- # Is +file+ in ENV['PATH']?
1146
-
1147
- def in_path? file
1148
- return true if file =~ %r%\A/% and File.exist? file
1149
-
1150
- ENV['PATH'].split(File::PATH_SEPARATOR).any? do |path|
1151
- File.exist? File.join(path, file)
1152
- end
1153
- end
1154
-
1155
1110
  ##
1156
1111
  # Lists classes known to ri starting with +names+. If +names+ is empty all
1157
1112
  # known classes are shown.
@@ -1283,8 +1238,8 @@ or the PAGER environment variable.
1283
1238
  methods.push(*store.instance_methods[klass]) if [:instance, :both].include? types
1284
1239
  end
1285
1240
  methods = methods.uniq
1286
- suggestions = DidYouMean::SpellChecker.new(dictionary: methods).correct(method_name)
1287
- raise NotFoundError.new(name, suggestions)
1241
+ suggestion_proc = -> { DidYouMean::SpellChecker.new(dictionary: methods).correct(method_name) }
1242
+ raise NotFoundError.new(name, suggestion_proc)
1288
1243
  else
1289
1244
  raise NotFoundError, name
1290
1245
  end
@@ -1346,7 +1301,6 @@ or the PAGER environment variable.
1346
1301
  yield pager
1347
1302
  ensure
1348
1303
  pager.close
1349
- @jruby_pager_process.wait_for if @jruby_pager_process
1350
1304
  end
1351
1305
  else
1352
1306
  yield $stdout
@@ -1514,27 +1468,14 @@ or the PAGER environment variable.
1514
1468
  def setup_pager
1515
1469
  return if @use_stdout
1516
1470
 
1517
- jruby = RUBY_ENGINE == 'jruby'
1518
-
1519
1471
  pagers = [ENV['RI_PAGER'], ENV['PAGER'], 'pager', 'less', 'more']
1520
1472
 
1473
+ require 'shellwords'
1521
1474
  pagers.compact.uniq.each do |pager|
1522
- next unless pager
1523
-
1524
- pager_cmd = pager.split(' ').first
1525
-
1526
- next unless in_path? pager_cmd
1527
-
1528
- if jruby then
1529
- case io = find_pager_jruby(pager)
1530
- when nil then break
1531
- when false then next
1532
- else io
1533
- end
1534
- else
1535
- io = IO.popen(pager, 'w') rescue next
1536
- end
1475
+ pager = Shellwords.split(pager)
1476
+ next if pager.empty?
1537
1477
 
1478
+ io = IO.popen(pager, 'w') rescue next
1538
1479
  next if $? and $?.pid == io.pid and $?.exited? # pager didn't work
1539
1480
 
1540
1481
  @paging = true
data/lib/rdoc/ri/store.rb CHANGED
@@ -4,4 +4,3 @@ module RDoc::RI
4
4
  Store = RDoc::Store # :nodoc:
5
5
 
6
6
  end
7
-
data/lib/rdoc/ri.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'rdoc'
2
+ require_relative '../rdoc'
3
3
 
4
4
  ##
5
5
  # Namespace for the ri command line tool's implementation.
@@ -13,9 +13,8 @@ module RDoc::RI
13
13
 
14
14
  class Error < RDoc::Error; end
15
15
 
16
- autoload :Driver, 'rdoc/ri/driver'
17
- autoload :Paths, 'rdoc/ri/paths'
18
- autoload :Store, 'rdoc/ri/store'
16
+ autoload :Driver, "#{__dir__}/ri/driver"
17
+ autoload :Paths, "#{__dir__}/ri/paths"
18
+ autoload :Store, "#{__dir__}/ri/store"
19
19
 
20
20
  end
21
-
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require 'rubygems/user_interaction'
3
3
  require 'fileutils'
4
- require 'rdoc'
4
+ require_relative '../rdoc'
5
5
 
6
6
  ##
7
7
  # Gem::RDoc provides methods to generate RDoc and ri data for installed gems
@@ -120,7 +120,9 @@ class RDoc::RubygemsHook
120
120
  options.exclude ||= [] # TODO maybe move to RDoc::Options#finish
121
121
  options.setup_generator generator
122
122
  options.op_dir = destination
123
- options.finish
123
+ Dir.chdir @spec.full_gem_path do
124
+ options.finish
125
+ end
124
126
 
125
127
  generator = options.generator.new @rdoc.store, options
126
128
 
data/lib/rdoc/servlet.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'rdoc'
2
+ require_relative '../rdoc'
3
3
  require 'erb'
4
4
  require 'time'
5
5
  require 'json'
@@ -22,5 +22,9 @@ class RDoc::SingleClass < RDoc::ClassModule
22
22
  "class << #{full_name}"
23
23
  end
24
24
 
25
+ def pretty_print q # :nodoc:
26
+ q.group 2, "[class << #{full_name}", "]" do
27
+ next
28
+ end
29
+ end
25
30
  end
26
-
@@ -57,4 +57,3 @@ class RDoc::Stats::Quiet
57
57
  def done_adding(*) end
58
58
 
59
59
  end
60
-
@@ -42,5 +42,3 @@ class RDoc::Stats::Verbose < RDoc::Stats::Normal
42
42
  end
43
43
 
44
44
  end
45
-
46
-
data/lib/rdoc/stats.rb CHANGED
@@ -454,9 +454,8 @@ class RDoc::Stats
454
454
  [params.length, undoc]
455
455
  end
456
456
 
457
- autoload :Quiet, 'rdoc/stats/quiet'
458
- autoload :Normal, 'rdoc/stats/normal'
459
- autoload :Verbose, 'rdoc/stats/verbose'
457
+ autoload :Quiet, "#{__dir__}/stats/quiet"
458
+ autoload :Normal, "#{__dir__}/stats/normal"
459
+ autoload :Verbose, "#{__dir__}/stats/verbose"
460
460
 
461
461
  end
462
-
data/lib/rdoc/store.rb CHANGED
@@ -197,6 +197,9 @@ class RDoc::Store
197
197
  top_level
198
198
  end
199
199
 
200
+ ##
201
+ # Sets the parser of +absolute_name+, unless it from a source code file.
202
+
200
203
  def update_parser_of_file(absolute_name, parser)
201
204
  if top_level = @files_hash[absolute_name] then
202
205
  @text_files_hash[absolute_name] = top_level if top_level.text?
@@ -556,9 +559,7 @@ class RDoc::Store
556
559
  def load_cache
557
560
  #orig_enc = @encoding
558
561
 
559
- File.open cache_path, 'rb' do |io|
560
- @cache = Marshal.load io.read
561
- end
562
+ @cache = marshal_load(cache_path)
562
563
 
563
564
  load_enc = @cache[:encoding]
564
565
 
@@ -615,9 +616,7 @@ class RDoc::Store
615
616
  def load_class_data klass_name
616
617
  file = class_file klass_name
617
618
 
618
- File.open file, 'rb' do |io|
619
- Marshal.load io.read
620
- end
619
+ marshal_load(file)
621
620
  rescue Errno::ENOENT => e
622
621
  error = MissingFileError.new(self, file, klass_name)
623
622
  error.set_backtrace e.backtrace
@@ -630,14 +629,10 @@ class RDoc::Store
630
629
  def load_method klass_name, method_name
631
630
  file = method_file klass_name, method_name
632
631
 
633
- File.open file, 'rb' do |io|
634
- obj = Marshal.load io.read
635
- obj.store = self
636
- obj.parent =
637
- find_class_or_module(klass_name) || load_class(klass_name) unless
638
- obj.parent
639
- obj
640
- end
632
+ obj = marshal_load(file)
633
+ obj.store = self
634
+ obj.parent ||= find_class_or_module(klass_name) || load_class(klass_name)
635
+ obj
641
636
  rescue Errno::ENOENT => e
642
637
  error = MissingFileError.new(self, file, klass_name + method_name)
643
638
  error.set_backtrace e.backtrace
@@ -650,11 +645,9 @@ class RDoc::Store
650
645
  def load_page page_name
651
646
  file = page_file page_name
652
647
 
653
- File.open file, 'rb' do |io|
654
- obj = Marshal.load io.read
655
- obj.store = self
656
- obj
657
- end
648
+ obj = marshal_load(file)
649
+ obj.store = self
650
+ obj
658
651
  rescue Errno::ENOENT => e
659
652
  error = MissingFileError.new(self, file, page_name)
660
653
  error.set_backtrace e.backtrace
@@ -976,4 +969,21 @@ class RDoc::Store
976
969
  @unique_modules
977
970
  end
978
971
 
972
+ private
973
+ def marshal_load(file)
974
+ File.open(file, 'rb') {|io| Marshal.load(io, MarshalFilter)}
975
+ end
976
+
977
+ MarshalFilter = proc do |obj|
978
+ case obj
979
+ when true, false, nil, Array, Class, Encoding, Hash, Integer, String, Symbol, RDoc::Text
980
+ else
981
+ unless obj.class.name.start_with?("RDoc::")
982
+ raise TypeError, "not permitted class: #{obj.class.name}"
983
+ end
984
+ end
985
+ obj
986
+ end
987
+ private_constant :MarshalFilter
988
+
979
989
  end
data/lib/rdoc/task.rb CHANGED
@@ -32,7 +32,7 @@ begin
32
32
  rescue Gem::LoadError
33
33
  end unless defined?(Rake)
34
34
 
35
- require 'rdoc'
35
+ require_relative '../rdoc'
36
36
  require 'rake'
37
37
  require 'rake/tasklib'
38
38
 
@@ -50,6 +50,9 @@ require 'rake/tasklib'
50
50
  # [rerdoc]
51
51
  # Rebuild the rdoc files from scratch, even if they are not out of date.
52
52
  #
53
+ # [rdoc:coverage]
54
+ # Print RDoc coverage report for all rdoc files.
55
+ #
53
56
  # Simple Example:
54
57
  #
55
58
  # require 'rdoc/task'
@@ -71,7 +74,7 @@ require 'rake/tasklib'
71
74
  # require 'rdoc/task'
72
75
  #
73
76
  # RDoc::Task.new :rdoc_dev do |rdoc|
74
- # rdoc.main = "README.doc"
77
+ # rdoc.main = "README.rdoc"
75
78
  # rdoc.rdoc_files.include("README.rdoc", "lib/**/*.rb")
76
79
  # rdoc.options << "--all"
77
80
  # end
@@ -90,8 +93,8 @@ require 'rake/tasklib'
90
93
  # RDoc::Task.new(:rdoc => "rdoc", :clobber_rdoc => "rdoc:clean",
91
94
  # :rerdoc => "rdoc:force")
92
95
  #
93
- # This will create the tasks <tt>:rdoc</tt>, <tt>:rdoc:clean</tt> and
94
- # <tt>:rdoc:force</tt>.
96
+ # This will create the tasks <tt>:rdoc</tt>, <tt>:rdoc:clean</tt>,
97
+ # <tt>:rdoc:force</tt>, and <tt>:rdoc:coverage</tt>.
95
98
 
96
99
  class RDoc::Task < Rake::TaskLib
97
100
 
@@ -248,6 +251,18 @@ class RDoc::Task < Rake::TaskLib
248
251
  RDoc::RDoc.new.document args
249
252
  end
250
253
 
254
+ namespace rdoc_task_name do
255
+ desc coverage_task_description
256
+ task coverage_task_name do
257
+ @before_running_rdoc.call if @before_running_rdoc
258
+ opts = option_list << "-C"
259
+ args = opts + @rdoc_files
260
+
261
+ $stderr.puts "rdoc #{args.join ' '}" if Rake.application.options.trace
262
+ RDoc::RDoc.new.document args
263
+ end
264
+ end
265
+
251
266
  self
252
267
  end
253
268
 
@@ -288,6 +303,13 @@ class RDoc::Task < Rake::TaskLib
288
303
  "Rebuild RDoc HTML files"
289
304
  end
290
305
 
306
+ ##
307
+ # Task description for the coverage task or its renamed description
308
+
309
+ def coverage_task_description
310
+ "Print RDoc coverage report"
311
+ end
312
+
291
313
  private
292
314
 
293
315
  def rdoc_target
@@ -315,6 +337,10 @@ class RDoc::Task < Rake::TaskLib
315
337
  end
316
338
  end
317
339
 
340
+ def coverage_task_name
341
+ "coverage"
342
+ end
343
+
318
344
  end
319
345
 
320
346
  # :stopdoc:
@@ -323,7 +349,7 @@ module Rake
323
349
  ##
324
350
  # For backwards compatibility
325
351
 
326
- RDocTask = RDoc::Task
352
+ RDocTask = RDoc::Task # :nodoc:
327
353
 
328
354
  end
329
355
  # :startdoc:
data/lib/rdoc/text.rb CHANGED
@@ -10,6 +10,10 @@ require 'strscan'
10
10
 
11
11
  module RDoc::Text
12
12
 
13
+ ##
14
+ # The language for this text. This affects stripping comments
15
+ # markers.
16
+
13
17
  attr_accessor :language
14
18
 
15
19
  ##
@@ -218,10 +222,10 @@ module RDoc::Text
218
222
  when s.scan(/\.\.\.(\.?)/) then
219
223
  html << s[1] << encoded[:ellipsis]
220
224
  after_word = nil
221
- when s.scan(/\(c\)/) then
225
+ when s.scan(/\(c\)/i) then
222
226
  html << encoded[:copyright]
223
227
  after_word = nil
224
- when s.scan(/\(r\)/) then
228
+ when s.scan(/\(r\)/i) then
225
229
  html << encoded[:trademark]
226
230
  after_word = nil
227
231
  when s.scan(/---/) then
@@ -237,10 +241,18 @@ module RDoc::Text
237
241
  when s.scan(/``/) then # backtick double quote
238
242
  html << encoded[:open_dquote]
239
243
  after_word = nil
240
- when s.scan(/''/) then # tick double quote
244
+ when s.scan(/(?:&#39;|'){2}/) then # tick double quote
241
245
  html << encoded[:close_dquote]
242
246
  after_word = nil
243
- when s.scan(/'/) then # single quote
247
+ when s.scan(/`/) then # backtick
248
+ if insquotes or after_word
249
+ html << '`'
250
+ after_word = false
251
+ else
252
+ html << encoded[:open_squote]
253
+ insquotes = true
254
+ end
255
+ when s.scan(/&#39;|'/) then # single quote
244
256
  if insquotes
245
257
  html << encoded[:close_squote]
246
258
  insquotes = false
@@ -301,4 +313,10 @@ module RDoc::Text
301
313
  res.join.strip
302
314
  end
303
315
 
316
+ ##
317
+ # Character class to be separated by a space when concatenating
318
+ # lines.
319
+
320
+ SPACE_SEPARATED_LETTER_CLASS = /[\p{Nd}\p{Lc}\p{Pc}]|[!-~&&\W]/
321
+
304
322
  end
@@ -112,8 +112,7 @@ module RDoc::TokenStream
112
112
  # Returns a string representation of the token stream
113
113
 
114
114
  def tokens_to_s
115
- token_stream.compact.map { |token| token[:text] }.join ''
115
+ (token_stream or return '').compact.map { |token| token[:text] }.join ''
116
116
  end
117
117
 
118
118
  end
119
-