rdoc 5.1.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 +4 -4
- data/README.rdoc +5 -6
- data/Rakefile +35 -67
- 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 +63 -20
- 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 +6 -3
- 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 +1 -1
- 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 +68 -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 +632 -466
- 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 +9 -34
- data/lib/rdoc/rd/block_parser.rb +47 -46
- data/lib/rdoc/rd/block_parser.ry +2 -2
- data/lib/rdoc/rd/inline.rb +5 -5
- data/lib/rdoc/rd/inline_parser.rb +139 -138
- 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 -24
- 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/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
|
|
data/lib/rdoc/ri/formatter.rb
CHANGED
data/lib/rdoc/ri/paths.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# frozen_string_literal:
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
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 =
|
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
|
-
|
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/store.rb
CHANGED
data/lib/rdoc/ri/task.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
begin
|
3
3
|
gem 'rdoc'
|
4
4
|
rescue Gem::LoadError
|
5
5
|
end unless defined?(RDoc)
|
6
6
|
|
7
|
-
|
7
|
+
require_relative '../task'
|
8
8
|
|
9
9
|
##
|
10
10
|
# RDoc::RI::Task creates ri data in <code>./.rdoc</code> for your project.
|
data/lib/rdoc/ri.rb
CHANGED
data/lib/rdoc/rubygems_hook.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
require 'rubygems/user_interaction'
|
3
3
|
require 'fileutils'
|
4
4
|
require 'rdoc'
|
@@ -70,7 +70,7 @@ class RDoc::RubygemsHook
|
|
70
70
|
def self.load_rdoc
|
71
71
|
return if @rdoc_version
|
72
72
|
|
73
|
-
|
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
@@ -1,8 +1,14 @@
|
|
1
|
-
# frozen_string_literal:
|
1
|
+
# frozen_string_literal: true
|
2
2
|
require 'rdoc'
|
3
|
+
require 'erb'
|
3
4
|
require 'time'
|
4
5
|
require 'json'
|
5
|
-
|
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
|
6
12
|
|
7
13
|
##
|
8
14
|
# This is a WEBrick servlet that allows you to browse ri documentation.
|
@@ -101,9 +107,9 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
|
|
101
107
|
res.body = File.read asset_path
|
102
108
|
|
103
109
|
res.content_type = case req.path
|
104
|
-
when /
|
105
|
-
when /
|
106
|
-
else
|
110
|
+
when /\.css\z/ then 'text/css'
|
111
|
+
when /\.js\z/ then 'application/javascript'
|
112
|
+
else 'application/octet-stream'
|
107
113
|
end
|
108
114
|
end
|
109
115
|
|
@@ -111,7 +117,7 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
|
|
111
117
|
# GET request entry point. Fills in +res+ for the path, etc. in +req+.
|
112
118
|
|
113
119
|
def do_GET req, res
|
114
|
-
req.path.sub!(
|
120
|
+
req.path.sub!(/\A#{Regexp.escape @mount_path}/, '') if @mount_path
|
115
121
|
|
116
122
|
case req.path
|
117
123
|
when '/' then
|
@@ -144,11 +150,14 @@ class RDoc::Servlet < WEBrick::HTTPServlet::AbstractServlet
|
|
144
150
|
# +generator+ is used to create the page.
|
145
151
|
|
146
152
|
def documentation_page store, generator, path, req, res
|
147
|
-
|
153
|
+
text_name = path.chomp '.html'
|
154
|
+
name = text_name.gsub '/', '::'
|
148
155
|
|
149
156
|
if klass = store.find_class_or_module(name) then
|
150
157
|
res.body = generator.generate_class klass
|
151
|
-
elsif page = store.find_text_page(name.sub(/_([^_]*)
|
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
|
152
161
|
res.body = generator.generate_page page
|
153
162
|
else
|
154
163
|
not_found generator, req, res
|
@@ -217,7 +226,7 @@ exception:
|
|
217
226
|
<pre>#{ERB::Util.html_escape exception.message}</pre>
|
218
227
|
|
219
228
|
<p>Please report this to the
|
220
|
-
<a href="https://github.com/
|
229
|
+
<a href="https://github.com/ruby/rdoc/issues">RDoc issues tracker</a>. Please
|
221
230
|
include the RDoc version, the URI above and exception class, message and
|
222
231
|
backtrace. If you're viewing a gem's documentation, include the gem name and
|
223
232
|
version. If you're viewing Ruby's documentation, include the version of ruby.
|
@@ -415,7 +424,7 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
|
|
415
424
|
RDoc::Store.new RDoc::RI::Paths.system_dir, :system
|
416
425
|
when 'site' then
|
417
426
|
RDoc::Store.new RDoc::RI::Paths.site_dir, :site
|
418
|
-
when
|
427
|
+
when /\Aextra-(\d+)\z/ then
|
419
428
|
index = $1.to_i - 1
|
420
429
|
ri_dir = installed_docs[index][4]
|
421
430
|
RDoc::Store.new ri_dir, :extra
|
@@ -427,14 +436,14 @@ version. If you're viewing Ruby's documentation, include the version of ruby.
|
|
427
436
|
end
|
428
437
|
|
429
438
|
raise WEBrick::HTTPStatus::NotFound,
|
430
|
-
"Could not find gem \"#{source_name}\". Are you sure you installed it?" unless ri_dir
|
439
|
+
"Could not find gem \"#{ERB::Util.html_escape(source_name)}\". Are you sure you installed it?" unless ri_dir
|
431
440
|
|
432
441
|
store = RDoc::Store.new ri_dir, type
|
433
442
|
|
434
443
|
return store if File.exist? store.cache_path
|
435
444
|
|
436
445
|
raise WEBrick::HTTPStatus::NotFound,
|
437
|
-
"Could not find documentation for \"#{source_name}\". Please run `gem rdoc --ri gem_name`"
|
446
|
+
"Could not find documentation for \"#{ERB::Util.html_escape(source_name)}\". Please run `gem rdoc --ri gem_name`"
|
438
447
|
|
439
448
|
end
|
440
449
|
end
|
data/lib/rdoc/single_class.rb
CHANGED
data/lib/rdoc/stats/normal.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
|
-
# frozen_string_literal:
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
begin
|
3
|
+
require 'io/console/size'
|
4
|
+
rescue LoadError
|
5
|
+
# for JRuby
|
6
|
+
require 'io/console'
|
7
|
+
end
|
3
8
|
|
4
9
|
##
|
5
10
|
# Stats printer that prints just the files being documented with a progress
|
@@ -21,27 +26,28 @@ class RDoc::Stats::Normal < RDoc::Stats::Quiet
|
|
21
26
|
files_so_far,
|
22
27
|
@num_files)
|
23
28
|
|
24
|
-
# Print a progress bar, but make sure it fits on a single line. Filename
|
25
|
-
# will be truncated if necessary.
|
26
|
-
terminal_width = IO.console_size[1].to_i.nonzero? || 80
|
27
|
-
max_filename_size = terminal_width - progress_bar.size
|
28
|
-
|
29
|
-
if filename.size > max_filename_size then
|
30
|
-
# Turn "some_long_filename.rb" to "...ong_filename.rb"
|
31
|
-
filename = filename[(filename.size - max_filename_size) .. -1]
|
32
|
-
filename[0..2] = "..."
|
33
|
-
end
|
34
|
-
|
35
|
-
line = "#{progress_bar}#{filename}"
|
36
29
|
if $stdout.tty?
|
30
|
+
# Print a progress bar, but make sure it fits on a single line. Filename
|
31
|
+
# will be truncated if necessary.
|
32
|
+
size = IO.respond_to?(:console_size) ? IO.console_size : IO.console.winsize
|
33
|
+
terminal_width = size[1].to_i.nonzero? || 80
|
34
|
+
max_filename_size = (terminal_width - progress_bar.size) - 1
|
35
|
+
|
36
|
+
if filename.size > max_filename_size then
|
37
|
+
# Turn "some_long_filename.rb" to "...ong_filename.rb"
|
38
|
+
filename = filename[(filename.size - max_filename_size) .. -1]
|
39
|
+
filename[0..2] = "..."
|
40
|
+
end
|
41
|
+
|
37
42
|
# Clean the line with whitespaces so that leftover output from the
|
38
43
|
# previous line doesn't show up.
|
39
|
-
$stdout.print("\r
|
40
|
-
@last_width =
|
41
|
-
|
44
|
+
$stdout.print("\r\e[K") if @last_width && @last_width > 0
|
45
|
+
@last_width = progress_bar.size + filename.size
|
46
|
+
term = "\r"
|
42
47
|
else
|
43
|
-
|
48
|
+
term = "\n"
|
44
49
|
end
|
50
|
+
$stdout.print(progress_bar, filename, term)
|
45
51
|
$stdout.flush
|
46
52
|
end
|
47
53
|
|
data/lib/rdoc/stats/quiet.rb
CHANGED
data/lib/rdoc/stats/verbose.rb
CHANGED
data/lib/rdoc/stats.rb
CHANGED