rdoc 5.0.0 → 6.3.1
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.
- checksums.yaml +5 -5
- data/CONTRIBUTING.rdoc +4 -4
- data/Gemfile +9 -0
- data/History.rdoc +12 -2
- data/README.rdoc +5 -6
- data/Rakefile +35 -65
- data/lib/rdoc/alias.rb +1 -1
- data/lib/rdoc/anon_class.rb +1 -1
- data/lib/rdoc/any_method.rb +59 -15
- data/lib/rdoc/attr.rb +1 -1
- data/lib/rdoc/class_module.rb +5 -3
- data/lib/rdoc/code_object.rb +2 -9
- data/lib/rdoc/code_objects.rb +1 -1
- data/lib/rdoc/comment.rb +32 -11
- data/lib/rdoc/constant.rb +3 -3
- data/lib/rdoc/context/section.rb +1 -14
- data/lib/rdoc/context.rb +74 -21
- data/lib/rdoc/cross_reference.rb +33 -15
- data/lib/rdoc/encoding.rb +58 -30
- data/lib/rdoc/erb_partial.rb +2 -2
- data/lib/rdoc/erbio.rb +8 -4
- data/lib/rdoc/extend.rb +1 -1
- data/lib/rdoc/generator/darkfish.rb +60 -29
- data/lib/rdoc/generator/json_index.rb +7 -4
- data/lib/rdoc/generator/markup.rb +3 -13
- data/lib/rdoc/generator/pot/message_extractor.rb +1 -1
- data/lib/rdoc/generator/pot/po.rb +3 -3
- data/lib/rdoc/generator/pot/po_entry.rb +11 -11
- data/lib/rdoc/generator/pot.rb +4 -4
- data/lib/rdoc/generator/ri.rb +1 -1
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +9 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +2 -2
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +6 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/class.rhtml +45 -47
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +55 -6
- data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -4
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +22 -99
- data/lib/rdoc/generator/template/darkfish/js/search.js +32 -31
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +15 -16
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +16 -16
- data/lib/rdoc/generator/template/json_index/js/navigation.js +4 -41
- data/lib/rdoc/generator/template/json_index/js/searcher.js +6 -6
- data/lib/rdoc/generator.rb +1 -1
- data/lib/rdoc/ghost_method.rb +1 -1
- data/lib/rdoc/i18n/locale.rb +2 -2
- data/lib/rdoc/i18n/text.rb +5 -5
- data/lib/rdoc/i18n.rb +3 -3
- data/lib/rdoc/include.rb +1 -1
- data/lib/rdoc/known_classes.rb +1 -1
- data/lib/rdoc/markdown/entities.rb +1 -1
- data/lib/rdoc/markdown/literals.kpeg +1 -0
- data/lib/rdoc/markdown/literals.rb +19 -7
- data/lib/rdoc/markdown.kpeg +92 -44
- data/lib/rdoc/markdown.rb +1171 -610
- data/lib/rdoc/markup/attr_changer.rb +1 -1
- data/lib/rdoc/markup/attr_span.rb +9 -3
- data/lib/rdoc/markup/attribute_manager.rb +115 -50
- data/lib/rdoc/markup/attributes.rb +7 -7
- data/lib/rdoc/markup/blank_line.rb +1 -1
- data/lib/rdoc/markup/block_quote.rb +1 -1
- data/lib/rdoc/markup/document.rb +1 -1
- data/lib/rdoc/markup/formatter.rb +25 -24
- data/lib/rdoc/markup/hard_break.rb +1 -1
- data/lib/rdoc/markup/heading.rb +4 -4
- data/lib/rdoc/markup/include.rb +1 -1
- data/lib/rdoc/markup/indented_paragraph.rb +1 -1
- data/lib/rdoc/markup/list.rb +1 -1
- data/lib/rdoc/markup/list_item.rb +1 -1
- data/lib/rdoc/markup/paragraph.rb +1 -1
- data/lib/rdoc/markup/parser.rb +79 -47
- data/lib/rdoc/markup/pre_process.rb +11 -6
- data/lib/rdoc/markup/raw.rb +1 -1
- data/lib/rdoc/markup/regexp_handling.rb +41 -0
- data/lib/rdoc/markup/rule.rb +1 -1
- data/lib/rdoc/markup/to_ansi.rb +1 -1
- data/lib/rdoc/markup/to_bs.rb +4 -4
- data/lib/rdoc/markup/to_html.rb +71 -26
- data/lib/rdoc/markup/to_html_crossref.rb +41 -26
- data/lib/rdoc/markup/to_html_snippet.rb +10 -10
- data/lib/rdoc/markup/to_joined_paragraph.rb +7 -32
- data/lib/rdoc/markup/to_label.rb +10 -10
- data/lib/rdoc/markup/to_markdown.rb +9 -9
- data/lib/rdoc/markup/to_rdoc.rb +35 -7
- data/lib/rdoc/markup/to_table_of_contents.rb +2 -1
- data/lib/rdoc/markup/to_test.rb +1 -1
- data/lib/rdoc/markup/to_tt_only.rb +3 -3
- data/lib/rdoc/markup/verbatim.rb +1 -1
- data/lib/rdoc/markup.rb +14 -17
- data/lib/rdoc/meta_method.rb +1 -1
- data/lib/rdoc/method_attr.rb +2 -2
- data/lib/rdoc/mixin.rb +1 -1
- data/lib/rdoc/normal_class.rb +3 -3
- data/lib/rdoc/normal_module.rb +1 -1
- data/lib/rdoc/options.rb +79 -21
- data/lib/rdoc/parser/c.rb +147 -194
- data/lib/rdoc/parser/changelog.rb +150 -19
- data/lib/rdoc/parser/markdown.rb +1 -1
- data/lib/rdoc/parser/rd.rb +1 -1
- data/lib/rdoc/parser/ripper_state_lex.rb +590 -0
- data/lib/rdoc/parser/ruby.rb +634 -465
- data/lib/rdoc/parser/ruby_tools.rb +33 -34
- data/lib/rdoc/parser/simple.rb +3 -3
- data/lib/rdoc/parser/text.rb +1 -1
- data/lib/rdoc/parser.rb +12 -35
- data/lib/rdoc/rd/block_parser.rb +109 -108
- data/lib/rdoc/rd/block_parser.ry +3 -3
- data/lib/rdoc/rd/inline.rb +5 -5
- data/lib/rdoc/rd/inline_parser.rb +186 -185
- data/lib/rdoc/rd/inline_parser.ry +1 -1
- data/lib/rdoc/rd.rb +1 -1
- data/lib/rdoc/rdoc.rb +54 -41
- data/lib/rdoc/require.rb +1 -1
- data/lib/rdoc/ri/driver.rb +132 -42
- data/lib/rdoc/ri/formatter.rb +1 -1
- data/lib/rdoc/ri/paths.rb +4 -18
- data/lib/rdoc/ri/store.rb +1 -1
- data/lib/rdoc/ri/task.rb +2 -2
- data/lib/rdoc/ri.rb +1 -1
- data/lib/rdoc/rubygems_hook.rb +3 -3
- data/lib/rdoc/servlet.rb +21 -12
- data/lib/rdoc/single_class.rb +1 -1
- data/lib/rdoc/stats/normal.rb +24 -18
- data/lib/rdoc/stats/quiet.rb +1 -1
- data/lib/rdoc/stats/verbose.rb +1 -1
- data/lib/rdoc/stats.rb +1 -1
- data/lib/rdoc/store.rb +38 -27
- data/lib/rdoc/task.rb +2 -2
- data/lib/rdoc/text.rb +16 -21
- data/lib/rdoc/token_stream.rb +56 -33
- data/lib/rdoc/tom_doc.rb +17 -12
- data/lib/rdoc/top_level.rb +9 -3
- data/lib/rdoc/version.rb +8 -0
- data/lib/rdoc.rb +24 -10
- data/man/ri.1 +247 -0
- data/rdoc.gemspec +206 -15
- metadata +15 -64
- data/.document +0 -5
- data/.gitignore +0 -13
- data/.travis.yml +0 -23
- data/lib/gauntlet_rdoc.rb +0 -82
- data/lib/rdoc/generator/template/darkfish/js/jquery.js +0 -4
- data/lib/rdoc/markup/formatter_test_case.rb +0 -764
- data/lib/rdoc/markup/inline.rb +0 -2
- data/lib/rdoc/markup/special.rb +0 -41
- data/lib/rdoc/markup/text_formatter_test_case.rb +0 -115
- data/lib/rdoc/ruby_lex.rb +0 -1367
- data/lib/rdoc/ruby_token.rb +0 -461
- data/lib/rdoc/test_case.rb +0 -204
data/lib/rdoc/rd.rb
CHANGED
data/lib/rdoc/rdoc.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
require 'rdoc'
|
3
3
|
|
4
4
|
require 'find'
|
@@ -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
|
27
|
+
# give rdoc on the command line. See <tt>rdoc --help</tt> for details.
|
28
28
|
|
29
29
|
class RDoc::RDoc
|
30
30
|
|
@@ -35,11 +35,6 @@ class RDoc::RDoc
|
|
35
35
|
|
36
36
|
GENERATORS = {}
|
37
37
|
|
38
|
-
##
|
39
|
-
# File pattern to exclude
|
40
|
-
|
41
|
-
attr_accessor :exclude
|
42
|
-
|
43
38
|
##
|
44
39
|
# Generator instance used for creating output
|
45
40
|
|
@@ -93,7 +88,6 @@ class RDoc::RDoc
|
|
93
88
|
|
94
89
|
def initialize
|
95
90
|
@current = nil
|
96
|
-
@exclude = nil
|
97
91
|
@generator = nil
|
98
92
|
@last_modified = {}
|
99
93
|
@old_siginfo = nil
|
@@ -116,13 +110,19 @@ class RDoc::RDoc
|
|
116
110
|
def gather_files files
|
117
111
|
files = ["."] if files.empty?
|
118
112
|
|
119
|
-
file_list = normalized_file_list files, true, @exclude
|
113
|
+
file_list = normalized_file_list files, true, @options.exclude
|
120
114
|
|
121
|
-
file_list = file_list
|
115
|
+
file_list = remove_unparseable(file_list)
|
122
116
|
|
123
|
-
file_list
|
124
|
-
|
125
|
-
|
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
|
126
126
|
end
|
127
127
|
|
128
128
|
##
|
@@ -166,8 +166,15 @@ class RDoc::RDoc
|
|
166
166
|
rescue Psych::SyntaxError
|
167
167
|
end
|
168
168
|
|
169
|
+
return RDoc::Options.new if options == false # Allow empty file.
|
170
|
+
|
169
171
|
raise RDoc::Error, "#{options_file} is not a valid rdoc options file" unless
|
170
|
-
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
|
171
178
|
|
172
179
|
options
|
173
180
|
end
|
@@ -188,7 +195,7 @@ class RDoc::RDoc
|
|
188
195
|
error "#{dir} exists and is not a directory" unless File.directory? dir
|
189
196
|
|
190
197
|
begin
|
191
|
-
open flag_file do |io|
|
198
|
+
File.open flag_file do |io|
|
192
199
|
unless force then
|
193
200
|
Time.parse io.gets
|
194
201
|
|
@@ -232,8 +239,11 @@ option)
|
|
232
239
|
|
233
240
|
def update_output_dir(op_dir, time, last = {})
|
234
241
|
return if @options.dry_run or not @options.update_output_dir
|
242
|
+
unless ENV['SOURCE_DATE_EPOCH'].nil?
|
243
|
+
time = Time.at(ENV['SOURCE_DATE_EPOCH'].to_i).gmtime
|
244
|
+
end
|
235
245
|
|
236
|
-
open output_flag_file(op_dir), "w" do |f|
|
246
|
+
File.open output_flag_file(op_dir), "w" do |f|
|
237
247
|
f.puts time.rfc2822
|
238
248
|
last.each do |n, t|
|
239
249
|
f.puts "#{n}\t#{t.rfc2822}"
|
@@ -257,11 +267,11 @@ option)
|
|
257
267
|
# read and strip comments
|
258
268
|
patterns = File.read(filename).gsub(/#.*/, '')
|
259
269
|
|
260
|
-
result =
|
270
|
+
result = {}
|
261
271
|
|
262
|
-
patterns.split.each do |patt|
|
272
|
+
patterns.split(' ').each do |patt|
|
263
273
|
candidates = Dir.glob(File.join(in_dir, patt))
|
264
|
-
result.
|
274
|
+
result.update normalized_file_list(candidates, false, @options.exclude)
|
265
275
|
end
|
266
276
|
|
267
277
|
result
|
@@ -281,21 +291,21 @@ option)
|
|
281
291
|
|
282
292
|
def normalized_file_list(relative_files, force_doc = false,
|
283
293
|
exclude_pattern = nil)
|
284
|
-
file_list =
|
294
|
+
file_list = {}
|
285
295
|
|
286
296
|
relative_files.each do |rel_file_name|
|
297
|
+
rel_file_name = rel_file_name.sub(/^\.\//, '')
|
287
298
|
next if rel_file_name.end_with? 'created.rid'
|
288
299
|
next if exclude_pattern && exclude_pattern =~ rel_file_name
|
289
300
|
stat = File.stat rel_file_name rescue next
|
290
301
|
|
291
302
|
case type = stat.ftype
|
292
303
|
when "file" then
|
293
|
-
|
294
|
-
|
304
|
+
mtime = (stat.mtime unless (last_modified = @last_modified[rel_file_name] and
|
305
|
+
stat.mtime.to_i <= last_modified.to_i))
|
295
306
|
|
296
307
|
if force_doc or RDoc::Parser.can_parse(rel_file_name) then
|
297
|
-
file_list
|
298
|
-
@last_modified[rel_file_name] = stat.mtime
|
308
|
+
file_list[rel_file_name] = mtime
|
299
309
|
end
|
300
310
|
when "directory" then
|
301
311
|
next if rel_file_name == "CVS" || rel_file_name == ".svn"
|
@@ -306,16 +316,16 @@ option)
|
|
306
316
|
dot_doc = File.join rel_file_name, RDoc::DOT_DOC_FILENAME
|
307
317
|
|
308
318
|
if File.file? dot_doc then
|
309
|
-
file_list
|
319
|
+
file_list.update(parse_dot_doc_file(rel_file_name, dot_doc))
|
310
320
|
else
|
311
|
-
file_list
|
321
|
+
file_list.update(list_files_in_directory(rel_file_name))
|
312
322
|
end
|
313
323
|
else
|
314
324
|
warn "rdoc can't parse the #{type} #{rel_file_name}"
|
315
325
|
end
|
316
326
|
end
|
317
327
|
|
318
|
-
file_list
|
328
|
+
file_list
|
319
329
|
end
|
320
330
|
|
321
331
|
##
|
@@ -358,7 +368,7 @@ option)
|
|
358
368
|
relative_path.relative_path_from @options.page_dir
|
359
369
|
end
|
360
370
|
|
361
|
-
top_level = @store.add_file filename, relative_path.to_s
|
371
|
+
top_level = @store.add_file filename, relative_name: relative_path.to_s
|
362
372
|
|
363
373
|
parser = RDoc::Parser.for top_level, filename, content, @options, @stats
|
364
374
|
|
@@ -430,10 +440,10 @@ The internal error was:
|
|
430
440
|
# files for emacs and vim.
|
431
441
|
|
432
442
|
def remove_unparseable files
|
433
|
-
files.reject do |file
|
443
|
+
files.reject do |file, *|
|
434
444
|
file =~ /\.(?:class|eps|erb|scpt\.txt|svg|ttf|yml)$/i or
|
435
445
|
(file =~ /tags$/i and
|
436
|
-
open(file, 'rb') { |io|
|
446
|
+
File.open(file, 'rb') { |io|
|
437
447
|
io.read(100) =~ /\A(\f\n[^,]+,\d+$|!_TAG_)/
|
438
448
|
})
|
439
449
|
end
|
@@ -469,8 +479,6 @@ The internal error was:
|
|
469
479
|
exit
|
470
480
|
end
|
471
481
|
|
472
|
-
@exclude = @options.exclude
|
473
|
-
|
474
482
|
unless @options.coverage_report then
|
475
483
|
@last_modified = setup_output_dir @options.op_dir, @options.force_update
|
476
484
|
end
|
@@ -521,13 +529,18 @@ The internal error was:
|
|
521
529
|
# by the RDoc options
|
522
530
|
|
523
531
|
def generate
|
524
|
-
|
525
|
-
|
526
|
-
$stderr.puts "\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}..."
|
527
|
-
end
|
528
|
-
|
532
|
+
if @options.dry_run then
|
533
|
+
# do nothing
|
529
534
|
@generator.generate
|
530
|
-
|
535
|
+
else
|
536
|
+
Dir.chdir @options.op_dir do
|
537
|
+
unless @options.quiet then
|
538
|
+
$stderr.puts "\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}..."
|
539
|
+
end
|
540
|
+
|
541
|
+
@generator.generate
|
542
|
+
update_output_dir '.', @start_time, @last_modified
|
543
|
+
end
|
531
544
|
end
|
532
545
|
end
|
533
546
|
|
@@ -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
|
-
|
565
|
-
|
566
|
-
|
577
|
+
require_relative 'generator/darkfish'
|
578
|
+
require_relative 'generator/ri'
|
579
|
+
require_relative 'generator/pot'
|
data/lib/rdoc/require.rb
CHANGED
data/lib/rdoc/ri/driver.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
require 'abbrev'
|
3
3
|
require 'optparse'
|
4
4
|
|
@@ -17,7 +17,7 @@ require 'rdoc'
|
|
17
17
|
##
|
18
18
|
# For RubyGems backwards compatibility
|
19
19
|
|
20
|
-
|
20
|
+
require_relative 'formatter'
|
21
21
|
|
22
22
|
##
|
23
23
|
# The RI driver implements the command-line ri tool.
|
@@ -47,13 +47,24 @@ class RDoc::RI::Driver
|
|
47
47
|
|
48
48
|
class NotFoundError < Error
|
49
49
|
|
50
|
+
def initialize(klass, suggestions = nil) # :nodoc:
|
51
|
+
@klass = klass
|
52
|
+
@suggestions = suggestions
|
53
|
+
end
|
54
|
+
|
50
55
|
##
|
51
56
|
# Name that wasn't found
|
52
57
|
|
53
|
-
|
58
|
+
def name
|
59
|
+
@klass
|
60
|
+
end
|
54
61
|
|
55
62
|
def message # :nodoc:
|
56
|
-
"Nothing known about #{
|
63
|
+
str = "Nothing known about #{@klass}"
|
64
|
+
if @suggestions and !@suggestions.empty?
|
65
|
+
str += "\nDid you mean? #{@suggestions.join("\n ")}"
|
66
|
+
end
|
67
|
+
str
|
57
68
|
end
|
58
69
|
end
|
59
70
|
|
@@ -80,7 +91,6 @@ class RDoc::RI::Driver
|
|
80
91
|
options[:interactive] = false
|
81
92
|
options[:profile] = false
|
82
93
|
options[:show_all] = false
|
83
|
-
options[:use_cache] = true
|
84
94
|
options[:use_stdout] = !$stdout.tty?
|
85
95
|
options[:width] = 72
|
86
96
|
|
@@ -100,7 +110,7 @@ class RDoc::RI::Driver
|
|
100
110
|
def self.dump data_path
|
101
111
|
require 'pp'
|
102
112
|
|
103
|
-
open data_path, 'rb' do |io|
|
113
|
+
File.open data_path, 'rb' do |io|
|
104
114
|
pp Marshal.load(io.read)
|
105
115
|
end
|
106
116
|
end
|
@@ -122,7 +132,7 @@ class RDoc::RI::Driver
|
|
122
132
|
opt.summary_indent = ' ' * 4
|
123
133
|
|
124
134
|
opt.banner = <<-EOT
|
125
|
-
Usage: #{opt.program_name} [options] [
|
135
|
+
Usage: #{opt.program_name} [options] [name ...]
|
126
136
|
|
127
137
|
Where name can be:
|
128
138
|
|
@@ -132,8 +142,8 @@ Where name can be:
|
|
132
142
|
|
133
143
|
gem_name: | gem_name:README | gem_name:History
|
134
144
|
|
135
|
-
All class names may be abbreviated to their minimum unambiguous form.
|
136
|
-
is ambiguous, all valid options will be listed.
|
145
|
+
All class names may be abbreviated to their minimum unambiguous form.
|
146
|
+
If a name is ambiguous, all valid options will be listed.
|
137
147
|
|
138
148
|
A '.' matches either class or instance methods, while #method
|
139
149
|
matches only instance and ::method matches only class methods.
|
@@ -151,23 +161,23 @@ For example:
|
|
151
161
|
#{opt.program_name} zip
|
152
162
|
#{opt.program_name} rdoc:README
|
153
163
|
|
154
|
-
Note that shell quoting or escaping may be required for method names
|
155
|
-
punctuation:
|
164
|
+
Note that shell quoting or escaping may be required for method names
|
165
|
+
containing punctuation:
|
156
166
|
|
157
167
|
#{opt.program_name} 'Array.[]'
|
158
168
|
#{opt.program_name} compact\\!
|
159
169
|
|
160
|
-
To see the default directories
|
170
|
+
To see the default directories #{opt.program_name} will search, run:
|
161
171
|
|
162
172
|
#{opt.program_name} --list-doc-dirs
|
163
173
|
|
164
|
-
Specifying the --system, --site, --home, --gems or --doc-dir options
|
165
|
-
limit ri to searching only the specified directories.
|
174
|
+
Specifying the --system, --site, --home, --gems, or --doc-dir options
|
175
|
+
will limit ri to searching only the specified directories.
|
166
176
|
|
167
|
-
ri options may be set in the
|
177
|
+
ri options may be set in the RI environment variable.
|
168
178
|
|
169
|
-
The ri pager can be set with the
|
170
|
-
|
179
|
+
The ri pager can be set with the RI_PAGER environment variable
|
180
|
+
or the PAGER environment variable.
|
171
181
|
EOT
|
172
182
|
|
173
183
|
opt.separator nil
|
@@ -199,15 +209,15 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
199
209
|
opt.separator nil
|
200
210
|
|
201
211
|
opt.on("--[no-]pager",
|
202
|
-
"Send output
|
203
|
-
"rather than to
|
212
|
+
"Send output to a pager,",
|
213
|
+
"rather than directly to stdout.") do |use_pager|
|
204
214
|
options[:use_stdout] = !use_pager
|
205
215
|
end
|
206
216
|
|
207
217
|
opt.separator nil
|
208
218
|
|
209
219
|
opt.on("-T",
|
210
|
-
"Synonym for --no-pager") do
|
220
|
+
"Synonym for --no-pager.") do
|
211
221
|
options[:use_stdout] = true
|
212
222
|
end
|
213
223
|
|
@@ -220,7 +230,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
220
230
|
|
221
231
|
opt.separator nil
|
222
232
|
|
223
|
-
opt.on("--server
|
233
|
+
opt.on("--server[=PORT]", Integer,
|
224
234
|
"Run RDoc server on the given port.",
|
225
235
|
"The default port is 8214.") do |port|
|
226
236
|
options[:server] = port || 8214
|
@@ -235,13 +245,29 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
235
245
|
formatters -= %w[html label test] # remove useless output formats
|
236
246
|
|
237
247
|
opt.on("--format=NAME", "-f",
|
238
|
-
"
|
248
|
+
"Use the selected formatter. The default",
|
239
249
|
"formatter is bs for paged output and ansi",
|
240
|
-
"otherwise.
|
241
|
-
formatters.join(' '), formatters) do |value|
|
250
|
+
"otherwise. Valid formatters are:",
|
251
|
+
"#{formatters.join(', ')}.", formatters) do |value|
|
242
252
|
options[:formatter] = RDoc::Markup.const_get "To#{value.capitalize}"
|
243
253
|
end
|
244
254
|
|
255
|
+
opt.separator nil
|
256
|
+
|
257
|
+
opt.on("--help", "-h",
|
258
|
+
"Show help and exit.") do
|
259
|
+
puts opts
|
260
|
+
exit
|
261
|
+
end
|
262
|
+
|
263
|
+
opt.separator nil
|
264
|
+
|
265
|
+
opt.on("--version", "-v",
|
266
|
+
"Output version information and exit.") do
|
267
|
+
puts "#{opts.program_name} #{opts.version}"
|
268
|
+
exit
|
269
|
+
end
|
270
|
+
|
245
271
|
opt.separator nil
|
246
272
|
opt.separator "Data source options:"
|
247
273
|
opt.separator nil
|
@@ -273,7 +299,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
273
299
|
"Do not include documentation from",
|
274
300
|
"the Ruby standard library, site_lib,",
|
275
301
|
"installed gems, or ~/.rdoc.",
|
276
|
-
"Use with --doc-dir") do
|
302
|
+
"Use with --doc-dir.") do
|
277
303
|
options[:use_system] = false
|
278
304
|
options[:use_site] = false
|
279
305
|
options[:use_gems] = false
|
@@ -283,8 +309,8 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
283
309
|
opt.separator nil
|
284
310
|
|
285
311
|
opt.on("--[no-]system",
|
286
|
-
"Include documentation from Ruby's
|
287
|
-
"library. Defaults to true.") do |value|
|
312
|
+
"Include documentation from Ruby's",
|
313
|
+
"standard library. Defaults to true.") do |value|
|
288
314
|
options[:use_system] = value
|
289
315
|
end
|
290
316
|
|
@@ -318,19 +344,19 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
318
344
|
opt.separator nil
|
319
345
|
|
320
346
|
opt.on("--[no-]profile",
|
321
|
-
"Run with the ruby profiler") do |value|
|
347
|
+
"Run with the ruby profiler.") do |value|
|
322
348
|
options[:profile] = value
|
323
349
|
end
|
324
350
|
|
325
351
|
opt.separator nil
|
326
352
|
|
327
353
|
opt.on("--dump=CACHE", File,
|
328
|
-
"
|
354
|
+
"Dump data from an ri cache or data file.") do |value|
|
329
355
|
options[:dump_path] = value
|
330
356
|
end
|
331
357
|
end
|
332
358
|
|
333
|
-
argv = ENV['RI'].to_s.split.concat argv
|
359
|
+
argv = ENV['RI'].to_s.split(' ').concat argv
|
334
360
|
|
335
361
|
opts.parse! argv
|
336
362
|
|
@@ -399,6 +425,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
399
425
|
@server = options[:server]
|
400
426
|
@use_stdout = options[:use_stdout]
|
401
427
|
@show_all = options[:show_all]
|
428
|
+
@width = options[:width]
|
402
429
|
|
403
430
|
# pager process for jruby
|
404
431
|
@jruby_pager_process = nil
|
@@ -769,7 +796,9 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
769
796
|
|
770
797
|
def display document
|
771
798
|
page do |io|
|
772
|
-
|
799
|
+
f = formatter(io)
|
800
|
+
f.width = @width if @width and f.respond_to?(:width)
|
801
|
+
text = document.accept f
|
773
802
|
|
774
803
|
io.write text
|
775
804
|
end
|
@@ -902,13 +931,38 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
902
931
|
display out
|
903
932
|
end
|
904
933
|
|
934
|
+
def check_did_you_mean # :nodoc:
|
935
|
+
if defined? DidYouMean::SpellChecker
|
936
|
+
true
|
937
|
+
else
|
938
|
+
begin
|
939
|
+
require 'did_you_mean'
|
940
|
+
if defined? DidYouMean::SpellChecker
|
941
|
+
true
|
942
|
+
else
|
943
|
+
false
|
944
|
+
end
|
945
|
+
rescue LoadError
|
946
|
+
false
|
947
|
+
end
|
948
|
+
end
|
949
|
+
end
|
950
|
+
|
905
951
|
##
|
906
952
|
# Expands abbreviated klass +klass+ into a fully-qualified class. "Zl::Da"
|
907
953
|
# will be expanded to Zlib::DataError.
|
908
954
|
|
909
955
|
def expand_class klass
|
910
|
-
|
911
|
-
|
956
|
+
class_names = classes.keys
|
957
|
+
ary = class_names.grep(Regexp.new("\\A#{klass.gsub(/(?=::|\z)/, '[^:]*')}\\z"))
|
958
|
+
if ary.length != 1 && ary.first != klass
|
959
|
+
if check_did_you_mean
|
960
|
+
suggestions = DidYouMean::SpellChecker.new(dictionary: class_names).correct(klass)
|
961
|
+
raise NotFoundError.new(klass, suggestions)
|
962
|
+
else
|
963
|
+
raise NotFoundError, klass
|
964
|
+
end
|
965
|
+
end
|
912
966
|
ary.first
|
913
967
|
end
|
914
968
|
|
@@ -1174,7 +1228,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
1174
1228
|
# +cache+ indicate if it is a class or instance method.
|
1175
1229
|
|
1176
1230
|
def load_method store, cache, klass, type, name
|
1177
|
-
methods = store.
|
1231
|
+
methods = store.public_send(cache)[klass]
|
1178
1232
|
|
1179
1233
|
return unless methods
|
1180
1234
|
|
@@ -1220,7 +1274,21 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
1220
1274
|
def lookup_method name
|
1221
1275
|
found = load_methods_matching name
|
1222
1276
|
|
1223
|
-
|
1277
|
+
if found.empty?
|
1278
|
+
if check_did_you_mean
|
1279
|
+
methods = []
|
1280
|
+
_, _, method_name = parse_name name
|
1281
|
+
find_methods name do |store, klass, ancestor, types, method|
|
1282
|
+
methods.push(*store.class_methods[klass]) if [:class, :both].include? types
|
1283
|
+
methods.push(*store.instance_methods[klass]) if [:instance, :both].include? types
|
1284
|
+
end
|
1285
|
+
methods = methods.uniq
|
1286
|
+
suggestions = DidYouMean::SpellChecker.new(dictionary: methods).correct(method_name)
|
1287
|
+
raise NotFoundError.new(name, suggestions)
|
1288
|
+
else
|
1289
|
+
raise NotFoundError, name
|
1290
|
+
end
|
1291
|
+
end
|
1224
1292
|
|
1225
1293
|
filter_methods found, name
|
1226
1294
|
end
|
@@ -1375,7 +1443,13 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
1375
1443
|
|
1376
1444
|
render_method_arguments out, method.arglists
|
1377
1445
|
render_method_superclass out, method
|
1378
|
-
|
1446
|
+
if method.is_alias_for
|
1447
|
+
al = method.is_alias_for
|
1448
|
+
alias_for = store.load_method al.parent_name, "#{al.name_prefix}#{al.name}"
|
1449
|
+
render_method_comment out, method, alias_for
|
1450
|
+
else
|
1451
|
+
render_method_comment out, method
|
1452
|
+
end
|
1379
1453
|
end
|
1380
1454
|
|
1381
1455
|
def render_method_arguments out, arglists # :nodoc:
|
@@ -1387,10 +1461,22 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
1387
1461
|
out << RDoc::Markup::Rule.new(1)
|
1388
1462
|
end
|
1389
1463
|
|
1390
|
-
def render_method_comment out, method # :nodoc:
|
1391
|
-
|
1392
|
-
|
1393
|
-
|
1464
|
+
def render_method_comment out, method, alias_for = nil# :nodoc:
|
1465
|
+
if alias_for
|
1466
|
+
unless method.comment.nil? or method.comment.empty?
|
1467
|
+
out << RDoc::Markup::BlankLine.new
|
1468
|
+
out << method.comment
|
1469
|
+
end
|
1470
|
+
out << RDoc::Markup::BlankLine.new
|
1471
|
+
out << RDoc::Markup::Paragraph.new("(This method is an alias for #{alias_for.full_name}.)")
|
1472
|
+
out << RDoc::Markup::BlankLine.new
|
1473
|
+
out << alias_for.comment
|
1474
|
+
out << RDoc::Markup::BlankLine.new
|
1475
|
+
else
|
1476
|
+
out << RDoc::Markup::BlankLine.new
|
1477
|
+
out << method.comment
|
1478
|
+
out << RDoc::Markup::BlankLine.new
|
1479
|
+
end
|
1394
1480
|
end
|
1395
1481
|
|
1396
1482
|
def render_method_superclass out, method # :nodoc:
|
@@ -1435,7 +1521,7 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
1435
1521
|
pagers.compact.uniq.each do |pager|
|
1436
1522
|
next unless pager
|
1437
1523
|
|
1438
|
-
pager_cmd = pager.split.first
|
1524
|
+
pager_cmd = pager.split(' ').first
|
1439
1525
|
|
1440
1526
|
next unless in_path? pager_cmd
|
1441
1527
|
|
@@ -1465,7 +1551,11 @@ The ri pager can be set with the 'RI_PAGER' environment variable or the
|
|
1465
1551
|
# Starts a WEBrick server for ri.
|
1466
1552
|
|
1467
1553
|
def start_server
|
1468
|
-
|
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
|
1469
1559
|
|
1470
1560
|
server = WEBrick::HTTPServer.new :Port => @server
|
1471
1561
|
|