rdoc 6.1.2 → 6.3.2

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 (78) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -0
  3. data/README.rdoc +0 -1
  4. data/Rakefile +28 -18
  5. data/lib/rdoc.rb +21 -0
  6. data/lib/rdoc/any_method.rb +52 -7
  7. data/lib/rdoc/class_module.rb +1 -1
  8. data/lib/rdoc/comment.rb +12 -1
  9. data/lib/rdoc/context.rb +10 -2
  10. data/lib/rdoc/context/section.rb +0 -13
  11. data/lib/rdoc/cross_reference.rb +4 -4
  12. data/lib/rdoc/erb_partial.rb +1 -1
  13. data/lib/rdoc/erbio.rb +2 -2
  14. data/lib/rdoc/generator/darkfish.rb +9 -9
  15. data/lib/rdoc/generator/pot.rb +3 -3
  16. data/lib/rdoc/generator/template/darkfish/_head.rhtml +4 -5
  17. data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
  18. data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
  19. data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
  20. data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
  21. data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
  22. data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
  23. data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +5 -5
  24. data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
  25. data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
  26. data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
  27. data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
  28. data/lib/rdoc/generator/template/darkfish/class.rhtml +44 -44
  29. data/lib/rdoc/generator/template/darkfish/css/rdoc.css +33 -5
  30. data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
  31. data/lib/rdoc/generator/template/darkfish/js/darkfish.js +0 -1
  32. data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
  33. data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
  34. data/lib/rdoc/i18n.rb +1 -1
  35. data/lib/rdoc/markdown.kpeg +20 -2
  36. data/lib/rdoc/markdown.rb +16685 -0
  37. data/lib/rdoc/markdown/literals.rb +417 -0
  38. data/lib/rdoc/markup.rb +1 -2
  39. data/lib/rdoc/markup/attr_span.rb +8 -2
  40. data/lib/rdoc/markup/attribute_manager.rb +93 -28
  41. data/lib/rdoc/markup/formatter.rb +1 -1
  42. data/lib/rdoc/markup/parser.rb +58 -42
  43. data/lib/rdoc/markup/pre_process.rb +1 -1
  44. data/lib/rdoc/markup/table.rb +47 -0
  45. data/lib/rdoc/markup/to_html.rb +46 -6
  46. data/lib/rdoc/markup/to_html_crossref.rb +18 -6
  47. data/lib/rdoc/markup/to_joined_paragraph.rb +1 -0
  48. data/lib/rdoc/markup/to_rdoc.rb +28 -0
  49. data/lib/rdoc/markup/to_table_of_contents.rb +1 -0
  50. data/lib/rdoc/options.rb +56 -6
  51. data/lib/rdoc/parser.rb +7 -7
  52. data/lib/rdoc/parser/c.rb +139 -183
  53. data/lib/rdoc/parser/changelog.rb +145 -14
  54. data/lib/rdoc/parser/ripper_state_lex.rb +2 -1
  55. data/lib/rdoc/parser/ruby.rb +18 -8
  56. data/lib/rdoc/rd/block_parser.rb +1056 -0
  57. data/lib/rdoc/rd/inline_parser.rb +1207 -0
  58. data/lib/rdoc/rdoc.rb +35 -22
  59. data/lib/rdoc/ri/driver.rb +9 -5
  60. data/lib/rdoc/ri/paths.rb +3 -17
  61. data/lib/rdoc/ri/task.rb +1 -1
  62. data/lib/rdoc/rubygems_hook.rb +2 -2
  63. data/lib/rdoc/servlet.rb +16 -8
  64. data/lib/rdoc/store.rb +6 -14
  65. data/lib/rdoc/task.rb +1 -1
  66. data/lib/rdoc/text.rb +8 -2
  67. data/lib/rdoc/token_stream.rb +8 -3
  68. data/lib/rdoc/tom_doc.rb +6 -7
  69. data/lib/rdoc/version.rb +1 -1
  70. data/man/ri.1 +247 -0
  71. data/rdoc.gemspec +196 -9
  72. metadata +10 -70
  73. data/.document +0 -5
  74. data/.gitignore +0 -14
  75. data/.travis.yml +0 -21
  76. data/appveyor.yml +0 -36
  77. data/lib/rdoc/markup/formatter_test_case.rb +0 -764
  78. data/lib/rdoc/markup/text_formatter_test_case.rb +0 -115
data/lib/rdoc/rdoc.rb CHANGED
@@ -24,7 +24,7 @@ require 'time'
24
24
  # rdoc.document argv
25
25
  #
26
26
  # Where +argv+ is an array of strings, each corresponding to an argument you'd
27
- # give rdoc on the command line. See <tt>rdoc --help<tt> for details.
27
+ # give rdoc on the command line. See <tt>rdoc --help</tt> for details.
28
28
 
29
29
  class RDoc::RDoc
30
30
 
@@ -112,11 +112,17 @@ class RDoc::RDoc
112
112
 
113
113
  file_list = normalized_file_list files, true, @options.exclude
114
114
 
115
- file_list = file_list.uniq
115
+ file_list = remove_unparseable(file_list)
116
116
 
117
- file_list = remove_unparseable file_list
118
-
119
- file_list.sort
117
+ if file_list.count {|name, mtime|
118
+ file_list[name] = @last_modified[name] unless mtime
119
+ mtime
120
+ } > 0
121
+ @last_modified.replace file_list
122
+ file_list.keys.sort
123
+ else
124
+ []
125
+ end
120
126
  end
121
127
 
122
128
  ##
@@ -160,8 +166,15 @@ class RDoc::RDoc
160
166
  rescue Psych::SyntaxError
161
167
  end
162
168
 
169
+ return RDoc::Options.new if options == false # Allow empty file.
170
+
163
171
  raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
164
- RDoc::Options === options
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
165
178
 
166
179
  options
167
180
  end
@@ -254,11 +267,11 @@ option)
254
267
  # read and strip comments
255
268
  patterns = File.read(filename).gsub(/#.*/, '')
256
269
 
257
- result = []
270
+ result = {}
258
271
 
259
- patterns.split.each do |patt|
272
+ patterns.split(' ').each do |patt|
260
273
  candidates = Dir.glob(File.join(in_dir, patt))
261
- result.concat normalized_file_list(candidates, false, @options.exclude)
274
+ result.update normalized_file_list(candidates, false, @options.exclude)
262
275
  end
263
276
 
264
277
  result
@@ -278,21 +291,21 @@ option)
278
291
 
279
292
  def normalized_file_list(relative_files, force_doc = false,
280
293
  exclude_pattern = nil)
281
- file_list = []
294
+ file_list = {}
282
295
 
283
296
  relative_files.each do |rel_file_name|
297
+ rel_file_name = rel_file_name.sub(/^\.\//, '')
284
298
  next if rel_file_name.end_with? 'created.rid'
285
299
  next if exclude_pattern && exclude_pattern =~ rel_file_name
286
300
  stat = File.stat rel_file_name rescue next
287
301
 
288
302
  case type = stat.ftype
289
303
  when "file" then
290
- next if last_modified = @last_modified[rel_file_name] and
291
- stat.mtime.to_i <= last_modified.to_i
304
+ mtime = (stat.mtime unless (last_modified = @last_modified[rel_file_name] and
305
+ stat.mtime.to_i <= last_modified.to_i))
292
306
 
293
307
  if force_doc or RDoc::Parser.can_parse(rel_file_name) then
294
- file_list << rel_file_name.sub(/^\.\//, '')
295
- @last_modified[rel_file_name] = stat.mtime
308
+ file_list[rel_file_name] = mtime
296
309
  end
297
310
  when "directory" then
298
311
  next if rel_file_name == "CVS" || rel_file_name == ".svn"
@@ -303,16 +316,16 @@ option)
303
316
  dot_doc = File.join rel_file_name, RDoc::DOT_DOC_FILENAME
304
317
 
305
318
  if File.file? dot_doc then
306
- file_list << parse_dot_doc_file(rel_file_name, dot_doc)
319
+ file_list.update(parse_dot_doc_file(rel_file_name, dot_doc))
307
320
  else
308
- file_list << list_files_in_directory(rel_file_name)
321
+ file_list.update(list_files_in_directory(rel_file_name))
309
322
  end
310
323
  else
311
324
  warn "rdoc can't parse the #{type} #{rel_file_name}"
312
325
  end
313
326
  end
314
327
 
315
- file_list.flatten
328
+ file_list
316
329
  end
317
330
 
318
331
  ##
@@ -427,10 +440,10 @@ The internal error was:
427
440
  # files for emacs and vim.
428
441
 
429
442
  def remove_unparseable files
430
- files.reject do |file|
443
+ files.reject do |file, *|
431
444
  file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)$/i or
432
445
  (file =~ /tags$/i and
433
- open(file, 'rb') { |io|
446
+ File.open(file, 'rb') { |io|
434
447
  io.read(100) =~ /\A(\f\n[^,]+,\d+$|!_TAG_)/
435
448
  })
436
449
  end
@@ -561,6 +574,6 @@ rescue LoadError
561
574
  end
562
575
 
563
576
  # require built-in generators after discovery in case they've been replaced
564
- require 'rdoc/generator/darkfish'
565
- require 'rdoc/generator/ri'
566
- require 'rdoc/generator/pot'
577
+ require_relative 'generator/darkfish'
578
+ require_relative 'generator/ri'
579
+ require_relative 'generator/pot'
@@ -17,7 +17,7 @@ require 'rdoc'
17
17
  ##
18
18
  # For RubyGems backwards compatibility
19
19
 
20
- require 'rdoc/ri/formatter'
20
+ require_relative 'formatter'
21
21
 
22
22
  ##
23
23
  # The RI driver implements the command-line ri tool.
@@ -356,7 +356,7 @@ or the PAGER environment variable.
356
356
  end
357
357
  end
358
358
 
359
- argv = ENV['RI'].to_s.split.concat argv
359
+ argv = ENV['RI'].to_s.split(' ').concat argv
360
360
 
361
361
  opts.parse! argv
362
362
 
@@ -1228,7 +1228,7 @@ or the PAGER environment variable.
1228
1228
  # +cache+ indicate if it is a class or instance method.
1229
1229
 
1230
1230
  def load_method store, cache, klass, type, name
1231
- methods = store.send(cache)[klass]
1231
+ methods = store.public_send(cache)[klass]
1232
1232
 
1233
1233
  return unless methods
1234
1234
 
@@ -1521,7 +1521,7 @@ or the PAGER environment variable.
1521
1521
  pagers.compact.uniq.each do |pager|
1522
1522
  next unless pager
1523
1523
 
1524
- pager_cmd = pager.split.first
1524
+ pager_cmd = pager.split(' ').first
1525
1525
 
1526
1526
  next unless in_path? pager_cmd
1527
1527
 
@@ -1551,7 +1551,11 @@ or the PAGER environment variable.
1551
1551
  # Starts a WEBrick server for ri.
1552
1552
 
1553
1553
  def start_server
1554
- require 'webrick'
1554
+ begin
1555
+ require 'webrick'
1556
+ rescue LoadError
1557
+ abort "webrick is not found. You may need to `gem install webrick` to install webrick."
1558
+ end
1555
1559
 
1556
1560
  server = WEBrick::HTTPServer.new :Port => @server
1557
1561
 
data/lib/rdoc/ri/paths.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
- require 'rdoc/ri'
2
+ require_relative '../rdoc'
3
3
 
4
4
  ##
5
5
  # The directories where ri data lives. Paths can be enumerated via ::each, or
@@ -12,23 +12,9 @@ module RDoc::RI::Paths
12
12
 
13
13
  version = RbConfig::CONFIG['ruby_version']
14
14
 
15
- BASE = if RbConfig::CONFIG.key? 'ridir' then
16
- File.join RbConfig::CONFIG['ridir'], version
17
- else
18
- File.join RbConfig::CONFIG['datadir'], 'ri', version
19
- end
15
+ BASE = File.join RbConfig::CONFIG['ridir'], version
20
16
 
21
- homedir = begin
22
- File.expand_path('~')
23
- rescue ArgumentError
24
- end
25
-
26
- homedir ||= ENV['HOME'] ||
27
- ENV['USERPROFILE'] || ENV['HOMEPATH'] # for 1.8 compatibility
28
-
29
- HOMEDIR = if homedir then
30
- File.join homedir, ".rdoc"
31
- end
17
+ HOMEDIR = RDoc.home
32
18
  #:startdoc:
33
19
 
34
20
  ##
data/lib/rdoc/ri/task.rb CHANGED
@@ -4,7 +4,7 @@ begin
4
4
  rescue Gem::LoadError
5
5
  end unless defined?(RDoc)
6
6
 
7
- require 'rdoc/task'
7
+ require_relative '../task'
8
8
 
9
9
  ##
10
10
  # RDoc::RI::Task creates ri data in <code>./.rdoc</code> for your project.
@@ -70,7 +70,7 @@ class RDoc::RubygemsHook
70
70
  def self.load_rdoc
71
71
  return if @rdoc_version
72
72
 
73
- require 'rdoc/rdoc'
73
+ require_relative 'rdoc'
74
74
 
75
75
  @rdoc_version = Gem::Version.new ::RDoc::VERSION
76
76
  end
@@ -158,7 +158,7 @@ class RDoc::RubygemsHook
158
158
 
159
159
  case config_args = Gem.configuration[:rdoc]
160
160
  when String then
161
- args = args.concat config_args.split
161
+ args = args.concat config_args.split(' ')
162
162
  when Array then
163
163
  args = args.concat config_args
164
164
  end
data/lib/rdoc/servlet.rb CHANGED
@@ -3,7 +3,12 @@ require 'rdoc'
3
3
  require 'erb'
4
4
  require 'time'
5
5
  require 'json'
6
- require 'webrick'
6
+
7
+ begin
8
+ require 'webrick'
9
+ rescue LoadError
10
+ abort "webrick is not found. You may need to `gem install webrick` to install webrick."
11
+ end
7
12
 
8
13
  ##
9
14
  # This is a WEBrick servlet that allows you to browse ri documentation.
@@ -102,9 +107,9 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
102
107
  res.body = File.read asset_path
103
108
 
104
109
  res.content_type = case req.path
105
- when /css$/ then 'text/css'
106
- when /js$/ then 'application/javascript'
107
- else 'application/octet-stream'
110
+ when /\.css\z/ then 'text/css'
111
+ when /\.js\z/ then 'application/javascript'
112
+ else 'application/octet-stream'
108
113
  end
109
114
  end
110
115
 
@@ -112,7 +117,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
112
117
  # GET request entry point. Fills in +res+ for the path, etc. in +req+.
113
118
 
114
119
  def do_GET req, res
115
- req.path.sub!(/^#{Regexp.escape @mount_path}/o, '') if @mount_path
120
+ req.path.sub!(/\A#{Regexp.escape @mount_path}/, '') if @mount_path
116
121
 
117
122
  case req.path
118
123
  when '/' then
@@ -145,11 +150,14 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
145
150
  # +generator+ is used to create the page.
146
151
 
147
152
  def documentation_page store, generator, path, req, res
148
- name = path.sub(/.html$/, '').gsub '/', '::'
153
+ text_name = path.chomp '.html'
154
+ name = text_name.gsub '/', '::'
149
155
 
150
156
  if klass = store.find_class_or_module(name) then
151
157
  res.body = generator.generate_class klass
152
- elsif page = store.find_text_page(name.sub(/_([^_]*)$/, '.\1')) then
158
+ elsif page = store.find_text_page(name.sub(/_([^_]*)\z/, '.\1')) then
159
+ res.body = generator.generate_page page
160
+ elsif page = store.find_text_page(text_name.sub(/_([^_]*)\z/, '.\1')) then
153
161
  res.body = generator.generate_page page
154
162
  else
155
163
  not_found generator, req, res
@@ -416,7 +424,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
416
424
  RDoc::Store.new RDoc::RI::Paths.system_dir, :system
417
425
  when 'site' then
418
426
  RDoc::Store.new RDoc::RI::Paths.site_dir, :site
419
- when /^extra-(\d+)$/ then
427
+ when /\Aextra-(\d+)\z/ then
420
428
  index = $1.to_i - 1
421
429
  ri_dir = installed_docs[index][4]
422
430
  RDoc::Store.new ri_dir, :extra
data/lib/rdoc/store.rb CHANGED
@@ -482,7 +482,7 @@ class RDoc::Store
482
482
  when :gem then
483
483
  parent = File.expand_path '..', @path
484
484
  "gem #{File.basename parent}"
485
- when :home then '~/.rdoc'
485
+ when :home then RDoc.home
486
486
  when :site then 'ruby site'
487
487
  when :system then 'ruby core'
488
488
  else @path
@@ -723,7 +723,7 @@ class RDoc::Store
723
723
 
724
724
  def page name
725
725
  @text_files_hash.each_value.find do |file|
726
- file.page_name == name
726
+ file.page_name == name or file.base_name == name
727
727
  end
728
728
  end
729
729
 
@@ -795,10 +795,8 @@ class RDoc::Store
795
795
 
796
796
  return if @dry_run
797
797
 
798
- marshal = Marshal.dump @cache
799
-
800
798
  File.open cache_path, 'wb' do |io|
801
- io.write marshal
799
+ Marshal.dump @cache, io
802
800
  end
803
801
  end
804
802
 
@@ -871,10 +869,8 @@ class RDoc::Store
871
869
 
872
870
  FileUtils.rm_f to_delete
873
871
 
874
- marshal = Marshal.dump klass
875
-
876
872
  File.open path, 'wb' do |io|
877
- io.write marshal
873
+ Marshal.dump klass, io
878
874
  end
879
875
  end
880
876
 
@@ -896,10 +892,8 @@ class RDoc::Store
896
892
 
897
893
  return if @dry_run
898
894
 
899
- marshal = Marshal.dump method
900
-
901
895
  File.open method_file(full_name, method.full_name), 'wb' do |io|
902
- io.write marshal
896
+ Marshal.dump method, io
903
897
  end
904
898
  end
905
899
 
@@ -918,10 +912,8 @@ class RDoc::Store
918
912
 
919
913
  return if @dry_run
920
914
 
921
- marshal = Marshal.dump page
922
-
923
915
  File.open path, 'wb' do |io|
924
- io.write marshal
916
+ Marshal.dump page, io
925
917
  end
926
918
  end
927
919
 
data/lib/rdoc/task.rb CHANGED
@@ -128,7 +128,7 @@ class RDoc::Task < Rake::TaskLib
128
128
  attr_accessor :template
129
129
 
130
130
  ##
131
- # Name of format generator (<tt>--format<tt>) used by rdoc. (defaults to
131
+ # Name of format generator (<tt>--format</tt>) used by rdoc. (defaults to
132
132
  # rdoc's default)
133
133
 
134
134
  attr_accessor :generator
data/lib/rdoc/text.rb CHANGED
@@ -10,6 +10,8 @@ require 'strscan'
10
10
 
11
11
  module RDoc::Text
12
12
 
13
+ attr_accessor :language
14
+
13
15
  ##
14
16
  # Maps markup formats to classes that can parse them. If the format is
15
17
  # unknown, "rdoc" format is used.
@@ -111,8 +113,12 @@ module RDoc::Text
111
113
  def normalize_comment text
112
114
  return text if text.empty?
113
115
 
114
- text = strip_stars text
115
- text = strip_hashes text
116
+ case language
117
+ when :ruby
118
+ text = strip_hashes text
119
+ when :c
120
+ text = strip_stars text
121
+ end
116
122
  text = expand_tabs text
117
123
  text = flush_left text
118
124
  text = strip_newlines text
@@ -74,11 +74,16 @@ module RDoc::TokenStream
74
74
  ##
75
75
  # Adds +tokens+ to the collected tokens
76
76
 
77
- def add_tokens(*tokens)
78
- tokens.flatten.each { |token| @token_stream << token }
77
+ def add_tokens(tokens)
78
+ @token_stream.concat(tokens)
79
79
  end
80
80
 
81
- alias add_token add_tokens
81
+ ##
82
+ # Adds one +token+ to the collected tokens
83
+
84
+ def add_token(token)
85
+ @token_stream.push(token)
86
+ end
82
87
 
83
88
  ##
84
89
  # Starts collecting tokens
data/lib/rdoc/tom_doc.rb CHANGED
@@ -242,19 +242,18 @@ class RDoc::TomDoc < RDoc::Markup::Parser
242
242
 
243
243
  @tokens << case
244
244
  when @s.scan(/\r?\n/) then
245
- token = [:NEWLINE, @s.matched, *token_pos(pos)]
246
- @line_pos = char_pos @s.pos
247
- @line += 1
245
+ token = [:NEWLINE, @s.matched, *pos]
246
+ @s.newline!
248
247
  token
249
248
  when @s.scan(/(Examples|Signature)$/) then
250
- @tokens << [:HEADER, 3, *token_pos(pos)]
249
+ @tokens << [:HEADER, 3, *pos]
251
250
 
252
- [:TEXT, @s[1], *token_pos(pos)]
251
+ [:TEXT, @s[1], *pos]
253
252
  when @s.scan(/([:\w][\w\[\]]*)[ ]+- /) then
254
- [:NOTE, @s[1], *token_pos(pos)]
253
+ [:NOTE, @s[1], *pos]
255
254
  else
256
255
  @s.scan(/.*/)
257
- [:TEXT, @s.matched.sub(/\r$/, ''), *token_pos(pos)]
256
+ [:TEXT, @s.matched.sub(/\r$/, ''), *pos]
258
257
  end
259
258
  end
260
259