rdoc 3.12.2 → 4.0.0.preview2
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 +6 -6
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/.autotest +3 -2
- data/DEVELOPERS.rdoc +53 -0
- data/History.rdoc +159 -25
- data/LEGAL.rdoc +12 -0
- data/Manifest.txt +56 -3
- data/README.rdoc +87 -19
- data/Rakefile +11 -2
- data/TODO.rdoc +20 -13
- data/bin/rdoc +4 -0
- data/lib/gauntlet_rdoc.rb +1 -1
- data/lib/rdoc.rb +32 -71
- data/lib/rdoc/any_method.rb +75 -21
- data/lib/rdoc/attr.rb +49 -10
- data/lib/rdoc/class_module.rb +182 -32
- data/lib/rdoc/code_object.rb +54 -12
- data/lib/rdoc/comment.rb +8 -1
- data/lib/rdoc/constant.rb +100 -6
- data/lib/rdoc/context.rb +93 -41
- data/lib/rdoc/context/section.rb +143 -28
- data/lib/rdoc/cross_reference.rb +58 -50
- data/lib/rdoc/encoding.rb +34 -29
- data/lib/rdoc/erb_partial.rb +18 -0
- data/lib/rdoc/extend.rb +117 -0
- data/lib/rdoc/generator.rb +11 -6
- data/lib/rdoc/generator/darkfish.rb +250 -62
- data/lib/rdoc/generator/json_index.rb +20 -12
- data/lib/rdoc/generator/markup.rb +10 -12
- data/lib/rdoc/generator/ri.rb +7 -60
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +7 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +16 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +14 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +1 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +13 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +15 -1
- data/lib/rdoc/generator/template/darkfish/images/arrow_up.png +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +7 -9
- data/lib/rdoc/generator/template/darkfish/page.rhtml +2 -0
- data/lib/rdoc/generator/template/darkfish/rdoc.css +31 -0
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +18 -0
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +37 -0
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +3 -3
- data/lib/rdoc/include.rb +12 -3
- data/lib/rdoc/markdown.kpeg +1186 -0
- data/lib/rdoc/markdown.rb +16336 -0
- data/lib/rdoc/markdown/entities.rb +2128 -0
- data/lib/rdoc/markdown/literals_1_8.kpeg +18 -0
- data/lib/rdoc/markdown/literals_1_8.rb +454 -0
- data/lib/rdoc/markdown/literals_1_9.kpeg +22 -0
- data/lib/rdoc/markdown/literals_1_9.rb +417 -0
- data/lib/rdoc/markup.rb +69 -10
- data/lib/rdoc/markup/attr_changer.rb +2 -5
- data/lib/rdoc/markup/attribute_manager.rb +23 -14
- data/lib/rdoc/markup/attributes.rb +70 -0
- data/lib/rdoc/markup/block_quote.rb +14 -0
- data/lib/rdoc/markup/document.rb +20 -4
- data/lib/rdoc/markup/formatter.rb +17 -6
- data/lib/rdoc/markup/formatter_test_case.rb +93 -24
- data/lib/rdoc/markup/hard_break.rb +31 -0
- data/lib/rdoc/markup/heading.rb +1 -1
- data/lib/rdoc/markup/indented_paragraph.rb +14 -0
- data/lib/rdoc/markup/list.rb +23 -4
- data/lib/rdoc/markup/list_item.rb +17 -4
- data/lib/rdoc/markup/paragraph.rb +14 -0
- data/lib/rdoc/markup/parser.rb +107 -60
- data/lib/rdoc/markup/raw.rb +4 -4
- data/lib/rdoc/markup/special.rb +3 -3
- data/lib/rdoc/markup/to_ansi.rb +7 -1
- data/lib/rdoc/markup/to_html.rb +42 -14
- data/lib/rdoc/markup/to_html_crossref.rb +10 -9
- data/lib/rdoc/markup/to_html_snippet.rb +20 -4
- data/lib/rdoc/markup/to_joined_paragraph.rb +68 -0
- data/lib/rdoc/markup/to_label.rb +20 -1
- data/lib/rdoc/markup/to_markdown.rb +134 -0
- data/lib/rdoc/markup/to_rdoc.rb +36 -5
- data/lib/rdoc/markup/to_table_of_contents.rb +6 -1
- data/lib/rdoc/markup/to_tt_only.rb +11 -2
- data/lib/rdoc/markup/verbatim.rb +19 -0
- data/lib/rdoc/method_attr.rb +33 -19
- data/lib/rdoc/normal_class.rb +26 -7
- data/lib/rdoc/normal_module.rb +10 -5
- data/lib/rdoc/options.rb +95 -21
- data/lib/rdoc/parser.rb +6 -2
- data/lib/rdoc/parser/c.rb +212 -97
- data/lib/rdoc/parser/markdown.rb +23 -0
- data/lib/rdoc/parser/ruby.rb +115 -35
- data/lib/rdoc/parser/ruby_tools.rb +8 -3
- data/lib/rdoc/rd.rb +8 -4
- data/lib/rdoc/rd/block_parser.rb +1 -1
- data/lib/rdoc/rd/block_parser.ry +1 -1
- data/lib/rdoc/rdoc.rb +45 -21
- data/lib/rdoc/ri/driver.rb +322 -76
- data/lib/rdoc/ri/paths.rb +90 -31
- data/lib/rdoc/ri/store.rb +2 -353
- data/lib/rdoc/ruby_lex.rb +5 -21
- data/lib/rdoc/ruby_token.rb +2 -3
- data/lib/rdoc/rubygems_hook.rb +21 -9
- data/lib/rdoc/servlet.rb +302 -0
- data/lib/rdoc/stats.rb +28 -20
- data/lib/rdoc/store.rb +881 -0
- data/lib/rdoc/task.rb +2 -1
- data/lib/rdoc/test_case.rb +103 -1
- data/lib/rdoc/text.rb +5 -4
- data/lib/rdoc/tom_doc.rb +17 -16
- data/lib/rdoc/top_level.rb +43 -285
- data/test/MarkdownTest_1.0.3/Amps and angle encoding.text +21 -0
- data/test/MarkdownTest_1.0.3/Auto links.text +13 -0
- data/test/MarkdownTest_1.0.3/Backslash escapes.text +120 -0
- data/test/MarkdownTest_1.0.3/Blockquotes with code blocks.text +11 -0
- data/test/MarkdownTest_1.0.3/Code Blocks.text +14 -0
- data/test/MarkdownTest_1.0.3/Code Spans.text +6 -0
- data/test/MarkdownTest_1.0.3/Hard-wrapped paragraphs with list-like lines.text +8 -0
- data/test/MarkdownTest_1.0.3/Horizontal rules.text +67 -0
- data/test/MarkdownTest_1.0.3/Inline HTML (Advanced).text +15 -0
- data/test/MarkdownTest_1.0.3/Inline HTML (Simple).text +69 -0
- data/test/MarkdownTest_1.0.3/Inline HTML comments.text +13 -0
- data/test/MarkdownTest_1.0.3/Links, inline style.text +12 -0
- data/test/MarkdownTest_1.0.3/Links, reference style.text +71 -0
- data/test/MarkdownTest_1.0.3/Links, shortcut references.text +20 -0
- data/test/MarkdownTest_1.0.3/Literal quotes in titles.text +7 -0
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Basics.text +306 -0
- data/test/MarkdownTest_1.0.3/Markdown Documentation - Syntax.text +888 -0
- data/test/MarkdownTest_1.0.3/Nested blockquotes.text +5 -0
- data/test/MarkdownTest_1.0.3/Ordered and unordered lists.text +131 -0
- data/test/MarkdownTest_1.0.3/Strong and em together.text +7 -0
- data/test/MarkdownTest_1.0.3/Tabs.text +21 -0
- data/test/MarkdownTest_1.0.3/Tidyness.text +5 -0
- data/test/test_attribute_manager.rb +7 -4
- data/test/test_rdoc_any_method.rb +84 -13
- data/test/test_rdoc_attr.rb +59 -9
- data/test/test_rdoc_class_module.rb +670 -73
- data/test/test_rdoc_code_object.rb +21 -1
- data/test/test_rdoc_comment.rb +1 -1
- data/test/test_rdoc_constant.rb +132 -0
- data/test/test_rdoc_context.rb +84 -18
- data/test/test_rdoc_context_section.rb +99 -15
- data/test/test_rdoc_cross_reference.rb +1 -1
- data/test/test_rdoc_encoding.rb +17 -1
- data/test/test_rdoc_extend.rb +94 -0
- data/test/test_rdoc_generator_darkfish.rb +45 -19
- data/test/test_rdoc_generator_json_index.rb +27 -7
- data/test/test_rdoc_generator_markup.rb +3 -3
- data/test/test_rdoc_generator_ri.rb +11 -9
- data/test/test_rdoc_include.rb +12 -0
- data/test/test_rdoc_markdown.rb +977 -0
- data/test/test_rdoc_markdown_test.rb +1891 -0
- data/test/test_rdoc_markup.rb +1 -1
- data/test/test_rdoc_markup_attribute_manager.rb +2 -2
- data/test/test_rdoc_markup_attributes.rb +39 -0
- data/test/test_rdoc_markup_document.rb +16 -1
- data/test/test_rdoc_markup_formatter.rb +7 -4
- data/test/test_rdoc_markup_hard_break.rb +31 -0
- data/test/test_rdoc_markup_indented_paragraph.rb +14 -0
- data/test/test_rdoc_markup_paragraph.rb +15 -1
- data/test/test_rdoc_markup_parser.rb +152 -89
- data/test/test_rdoc_markup_to_ansi.rb +23 -2
- data/test/test_rdoc_markup_to_bs.rb +24 -0
- data/test/test_rdoc_markup_to_html.rb +50 -19
- data/test/test_rdoc_markup_to_html_crossref.rb +23 -5
- data/test/test_rdoc_markup_to_html_snippet.rb +49 -8
- data/test/test_rdoc_markup_to_joined_paragraph.rb +32 -0
- data/test/test_rdoc_markup_to_label.rb +63 -1
- data/test/test_rdoc_markup_to_markdown.rb +352 -0
- data/test/test_rdoc_markup_to_rdoc.rb +22 -2
- data/test/test_rdoc_markup_to_table_of_contents.rb +44 -39
- data/test/test_rdoc_markup_to_tt_only.rb +20 -0
- data/test/test_rdoc_markup_verbatim.rb +13 -0
- data/test/test_rdoc_method_attr.rb +5 -0
- data/test/test_rdoc_normal_class.rb +24 -5
- data/test/test_rdoc_normal_module.rb +1 -1
- data/test/test_rdoc_options.rb +21 -6
- data/test/test_rdoc_parser.rb +24 -0
- data/test/test_rdoc_parser_c.rb +151 -26
- data/test/test_rdoc_parser_markdown.rb +55 -0
- data/test/test_rdoc_parser_rd.rb +2 -2
- data/test/test_rdoc_parser_ruby.rb +468 -109
- data/test/test_rdoc_parser_simple.rb +2 -2
- data/test/test_rdoc_rd_block_parser.rb +0 -4
- data/test/test_rdoc_rdoc.rb +110 -22
- data/test/test_rdoc_ri_driver.rb +415 -80
- data/test/test_rdoc_ri_paths.rb +122 -13
- data/test/test_rdoc_ruby_lex.rb +5 -61
- data/test/test_rdoc_ruby_token.rb +19 -0
- data/test/test_rdoc_rubygems_hook.rb +64 -43
- data/test/test_rdoc_servlet.rb +429 -0
- data/test/test_rdoc_stats.rb +83 -24
- data/test/{test_rdoc_ri_store.rb → test_rdoc_store.rb} +395 -22
- data/test/test_rdoc_task.rb +2 -2
- data/test/test_rdoc_text.rb +37 -11
- data/test/test_rdoc_tom_doc.rb +59 -62
- data/test/test_rdoc_top_level.rb +71 -113
- data/test/xref_test_case.rb +7 -9
- metadata +122 -39
- metadata.gz.sig +0 -0
- data/CVE-2013-0256.rdoc +0 -49
- data/lib/rdoc/markup/attribute.rb +0 -51
data/lib/rdoc/rdoc.rb
CHANGED
@@ -2,10 +2,11 @@ require 'rdoc'
|
|
2
2
|
|
3
3
|
require 'find'
|
4
4
|
require 'fileutils'
|
5
|
+
require 'pathname'
|
5
6
|
require 'time'
|
6
7
|
|
7
8
|
##
|
8
|
-
# This is the driver for generating RDoc output. It file parsing and
|
9
|
+
# This is the driver for generating RDoc output. It handles file parsing and
|
9
10
|
# generation of output.
|
10
11
|
#
|
11
12
|
# To use this class to generate RDoc output via the API, the recommended way
|
@@ -58,6 +59,11 @@ class RDoc::RDoc
|
|
58
59
|
|
59
60
|
attr_reader :stats
|
60
61
|
|
62
|
+
##
|
63
|
+
# The current documentation store
|
64
|
+
|
65
|
+
attr_reader :store
|
66
|
+
|
61
67
|
##
|
62
68
|
# Add +klass+ that can generate output after parsing
|
63
69
|
|
@@ -80,15 +86,6 @@ class RDoc::RDoc
|
|
80
86
|
@current = rdoc
|
81
87
|
end
|
82
88
|
|
83
|
-
##
|
84
|
-
# Resets all internal state
|
85
|
-
|
86
|
-
def self.reset
|
87
|
-
RDoc::TopLevel.reset
|
88
|
-
RDoc::Parser::C.reset
|
89
|
-
RDoc::RDoc.current = nil
|
90
|
-
end
|
91
|
-
|
92
89
|
##
|
93
90
|
# Creates a new RDoc::RDoc instance. Call #document to parse files and
|
94
91
|
# generate documentation.
|
@@ -101,6 +98,7 @@ class RDoc::RDoc
|
|
101
98
|
@old_siginfo = nil
|
102
99
|
@options = nil
|
103
100
|
@stats = nil
|
101
|
+
@store = nil
|
104
102
|
end
|
105
103
|
|
106
104
|
##
|
@@ -122,13 +120,15 @@ class RDoc::RDoc
|
|
122
120
|
file_list = file_list.uniq
|
123
121
|
|
124
122
|
file_list = remove_unparseable file_list
|
123
|
+
|
124
|
+
file_list.sort
|
125
125
|
end
|
126
126
|
|
127
127
|
##
|
128
128
|
# Turns RDoc from stdin into HTML
|
129
129
|
|
130
130
|
def handle_pipe
|
131
|
-
@html = RDoc::Markup::ToHtml.new
|
131
|
+
@html = RDoc::Markup::ToHtml.new @options
|
132
132
|
|
133
133
|
parser = RDoc::Text::MARKUP_FORMAT[@options.markup]
|
134
134
|
|
@@ -223,6 +223,15 @@ option)
|
|
223
223
|
last
|
224
224
|
end
|
225
225
|
|
226
|
+
##
|
227
|
+
# Sets the current documentation tree to +store+ and sets the store's rdoc
|
228
|
+
# driver to this instance.
|
229
|
+
|
230
|
+
def store= store
|
231
|
+
@store = store
|
232
|
+
@store.rdoc = self
|
233
|
+
end
|
234
|
+
|
226
235
|
##
|
227
236
|
# Update the flag file in an output directory.
|
228
237
|
|
@@ -303,7 +312,7 @@ option)
|
|
303
312
|
file_list << list_files_in_directory(rel_file_name)
|
304
313
|
end
|
305
314
|
else
|
306
|
-
|
315
|
+
warn "rdoc can't parse the #{type} #{rel_file_name}"
|
307
316
|
end
|
308
317
|
end
|
309
318
|
|
@@ -337,7 +346,10 @@ option)
|
|
337
346
|
|
338
347
|
return unless content
|
339
348
|
|
340
|
-
|
349
|
+
filename_path = Pathname(filename).expand_path
|
350
|
+
relative_path = filename_path.relative_path_from @options.root
|
351
|
+
|
352
|
+
top_level = @store.add_file filename, relative_path.to_s
|
341
353
|
|
342
354
|
parser = RDoc::Parser.for top_level, filename, content, @options, @stats
|
343
355
|
|
@@ -352,6 +364,14 @@ option)
|
|
352
364
|
|
353
365
|
top_level
|
354
366
|
|
367
|
+
rescue Errno::EACCES => e
|
368
|
+
$stderr.puts <<-EOF
|
369
|
+
Unable to read #{filename}, #{e.message}
|
370
|
+
|
371
|
+
Please check the permissions for this file. Perhaps you do not have access to
|
372
|
+
it or perhaps the original author's permissions are to restrictive. If the
|
373
|
+
this is not your library please report a bug to the author.
|
374
|
+
EOF
|
355
375
|
rescue => e
|
356
376
|
$stderr.puts <<-EOF
|
357
377
|
Before reporting this, could you check that the file you're documenting
|
@@ -378,7 +398,7 @@ The internal error was:
|
|
378
398
|
|
379
399
|
def parse_files files
|
380
400
|
file_list = gather_files files
|
381
|
-
@stats = RDoc::Stats.new file_list.
|
401
|
+
@stats = RDoc::Stats.new @store, file_list.length, @options.verbosity
|
382
402
|
|
383
403
|
return [] if file_list.empty?
|
384
404
|
|
@@ -425,8 +445,7 @@ The internal error was:
|
|
425
445
|
# current directory, so make sure you're somewhere writable before invoking.
|
426
446
|
|
427
447
|
def document options
|
428
|
-
RDoc::
|
429
|
-
RDoc::RDoc.current = self
|
448
|
+
self.store = RDoc::Store.new
|
430
449
|
|
431
450
|
if RDoc::Options === options then
|
432
451
|
@options = options
|
@@ -447,13 +466,18 @@ The internal error was:
|
|
447
466
|
@last_modified = setup_output_dir @options.op_dir, @options.force_update
|
448
467
|
end
|
449
468
|
|
469
|
+
@store.encoding = @options.encoding if @options.respond_to? :encoding
|
470
|
+
@store.dry_run = @options.dry_run
|
471
|
+
@store.main = @options.main_page
|
472
|
+
@store.title = @options.title
|
473
|
+
|
450
474
|
@start_time = Time.now
|
451
475
|
|
452
476
|
file_info = parse_files @options.files
|
453
477
|
|
454
478
|
@options.default_title = "RDoc Documentation"
|
455
479
|
|
456
|
-
|
480
|
+
@store.complete @options.visibility
|
457
481
|
|
458
482
|
@stats.coverage_level = @options.coverage_report
|
459
483
|
|
@@ -466,9 +490,9 @@ The internal error was:
|
|
466
490
|
else
|
467
491
|
gen_klass = @options.generator
|
468
492
|
|
469
|
-
@generator = gen_klass.new @options
|
493
|
+
@generator = gen_klass.new @store, @options
|
470
494
|
|
471
|
-
generate
|
495
|
+
generate
|
472
496
|
end
|
473
497
|
|
474
498
|
if @stats and (@options.coverage_report or not @options.quiet) then
|
@@ -484,13 +508,13 @@ The internal error was:
|
|
484
508
|
# output dir using the generator selected
|
485
509
|
# by the RDoc options
|
486
510
|
|
487
|
-
def generate
|
511
|
+
def generate
|
488
512
|
Dir.chdir @options.op_dir do
|
489
513
|
unless @options.quiet then
|
490
514
|
$stderr.puts "\nGenerating #{@generator.class.name.sub(/^.*::/, '')} format into #{Dir.pwd}..."
|
491
515
|
end
|
492
516
|
|
493
|
-
@generator.generate
|
517
|
+
@generator.generate
|
494
518
|
update_output_dir '.', @start_time, @last_modified
|
495
519
|
end
|
496
520
|
end
|
data/lib/rdoc/ri/driver.rb
CHANGED
@@ -56,6 +56,11 @@ class RDoc::RI::Driver
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
+
##
|
60
|
+
# Show all method documentation following a class or module
|
61
|
+
|
62
|
+
attr_accessor :show_all
|
63
|
+
|
59
64
|
##
|
60
65
|
# An RDoc::RI::Store for each entry in the RI path
|
61
66
|
|
@@ -71,17 +76,18 @@ class RDoc::RI::Driver
|
|
71
76
|
|
72
77
|
def self.default_options
|
73
78
|
options = {}
|
74
|
-
options[:use_stdout] = !$stdout.tty?
|
75
|
-
options[:width] = 72
|
76
79
|
options[:interactive] = false
|
77
|
-
options[:
|
78
|
-
options[:
|
80
|
+
options[:profile] = false
|
81
|
+
options[:show_all] = false
|
82
|
+
options[:use_cache] = true
|
83
|
+
options[:use_stdout] = !$stdout.tty?
|
84
|
+
options[:width] = 72
|
79
85
|
|
80
86
|
# By default all standard paths are used.
|
81
|
-
options[:use_system]
|
82
|
-
options[:use_site]
|
83
|
-
options[:use_home]
|
84
|
-
options[:use_gems]
|
87
|
+
options[:use_system] = true
|
88
|
+
options[:use_site] = true
|
89
|
+
options[:use_home] = true
|
90
|
+
options[:use_gems] = true
|
85
91
|
options[:extra_doc_dirs] = []
|
86
92
|
|
87
93
|
return options
|
@@ -119,7 +125,11 @@ Usage: #{opt.program_name} [options] [names...]
|
|
119
125
|
|
120
126
|
Where name can be:
|
121
127
|
|
122
|
-
Class |
|
128
|
+
Class | Module | Module::Class
|
129
|
+
|
130
|
+
Class::method | Class#method | Class.method | method
|
131
|
+
|
132
|
+
gem_name: | gem_name:README | gem_name:History
|
123
133
|
|
124
134
|
All class names may be abbreviated to their minimum unambiguous form. If a name
|
125
135
|
is ambiguous, all valid options will be listed.
|
@@ -127,12 +137,18 @@ is ambiguous, all valid options will be listed.
|
|
127
137
|
A '.' matches either class or instance methods, while #method
|
128
138
|
matches only instance and ::method matches only class methods.
|
129
139
|
|
140
|
+
README and other files may be displayed by prefixing them with the gem name
|
141
|
+
they're contained in. If the gem name is followed by a ':' all files in the
|
142
|
+
gem will be shown. The file name extension may be omitted where it is
|
143
|
+
unambiguous.
|
144
|
+
|
130
145
|
For example:
|
131
146
|
|
132
147
|
#{opt.program_name} Fil
|
133
148
|
#{opt.program_name} File
|
134
149
|
#{opt.program_name} File.new
|
135
150
|
#{opt.program_name} zip
|
151
|
+
#{opt.program_name} rdoc:README
|
136
152
|
|
137
153
|
Note that shell quoting or escaping may be required for method names containing
|
138
154
|
punctuation:
|
@@ -147,7 +163,10 @@ To see the default directories ri will search, run:
|
|
147
163
|
Specifying the --system, --site, --home, --gems or --doc-dir options will
|
148
164
|
limit ri to searching only the specified directories.
|
149
165
|
|
150
|
-
|
166
|
+
ri options may be set in the 'RI' environment variable.
|
167
|
+
|
168
|
+
The ri pager can be set with the 'RI_PAGER' environment variable or the
|
169
|
+
'PAGER' environment variable.
|
151
170
|
EOT
|
152
171
|
|
153
172
|
opt.separator nil
|
@@ -155,64 +174,74 @@ Options may also be set in the 'RI' environment variable.
|
|
155
174
|
|
156
175
|
opt.separator nil
|
157
176
|
|
158
|
-
|
159
|
-
|
160
|
-
|
177
|
+
opt.on("--[no-]interactive", "-i",
|
178
|
+
"In interactive mode you can repeatedly",
|
179
|
+
"look up methods with autocomplete.") do |interactive|
|
180
|
+
options[:interactive] = interactive
|
161
181
|
end
|
162
182
|
|
163
|
-
opt.
|
164
|
-
|
165
|
-
|
166
|
-
"
|
167
|
-
|
168
|
-
options[:
|
183
|
+
opt.separator nil
|
184
|
+
|
185
|
+
opt.on("--[no-]all", "-a",
|
186
|
+
"Show all documentation for a class or",
|
187
|
+
"module.") do |show_all|
|
188
|
+
options[:show_all] = show_all
|
169
189
|
end
|
170
190
|
|
171
191
|
opt.separator nil
|
172
192
|
|
173
|
-
opt.on("--no-
|
174
|
-
"
|
175
|
-
|
176
|
-
options[:use_stdout] = true
|
193
|
+
opt.on("--[no-]list", "-l",
|
194
|
+
"List classes ri knows about.") do |list|
|
195
|
+
options[:list] = list
|
177
196
|
end
|
178
197
|
|
179
198
|
opt.separator nil
|
180
199
|
|
181
|
-
opt.on("--
|
182
|
-
"
|
183
|
-
|
200
|
+
opt.on("--[no-]pager", "-T",
|
201
|
+
"Send output directly to stdout,",
|
202
|
+
"rather than to a pager.") do |use_pager|
|
203
|
+
options[:use_stdout] = !use_pager
|
184
204
|
end
|
185
205
|
|
186
206
|
opt.separator nil
|
187
207
|
|
188
|
-
opt.on("--
|
189
|
-
"
|
190
|
-
|
191
|
-
options[:interactive] = true
|
208
|
+
opt.on("--width=WIDTH", "-w", OptionParser::DecimalInteger,
|
209
|
+
"Set the width of the output.") do |width|
|
210
|
+
options[:width] = width
|
192
211
|
end
|
193
212
|
|
194
213
|
opt.separator nil
|
195
214
|
|
196
|
-
opt.on("--
|
197
|
-
"
|
198
|
-
|
215
|
+
opt.on("--server [PORT]", Integer,
|
216
|
+
"Run RDoc server on the given port.",
|
217
|
+
"The default port is 8214.") do |port|
|
218
|
+
options[:server] = port || 8214
|
199
219
|
end
|
200
220
|
|
201
221
|
opt.separator nil
|
202
222
|
|
203
|
-
|
204
|
-
|
205
|
-
|
223
|
+
formatters = RDoc::Markup.constants.grep(/^To[A-Z][a-z]+$/).sort
|
224
|
+
formatters = formatters.sort.map do |formatter|
|
225
|
+
formatter.to_s.sub('To', '').downcase
|
226
|
+
end
|
227
|
+
formatters -= %w[html label test] # remove useless output formats
|
228
|
+
|
229
|
+
opt.on("--format=NAME", "-f",
|
230
|
+
"Uses the selected formatter. The default",
|
231
|
+
"formatter is bs for paged output and ansi",
|
232
|
+
"otherwise. Valid formatters are:",
|
233
|
+
formatters.join(' '), formatters) do |value|
|
234
|
+
options[:formatter] = RDoc::Markup.const_get "To#{value.capitalize}"
|
206
235
|
end
|
207
236
|
|
208
237
|
opt.separator nil
|
209
238
|
opt.separator "Data source options:"
|
210
239
|
opt.separator nil
|
211
240
|
|
212
|
-
opt.on("--list-doc-dirs",
|
241
|
+
opt.on("--[no-]list-doc-dirs",
|
213
242
|
"List the directories from which ri will",
|
214
|
-
"source documentation on stdout and exit.") do
|
215
|
-
options[:list_doc_dirs] =
|
243
|
+
"source documentation on stdout and exit.") do |list_doc_dirs|
|
244
|
+
options[:list_doc_dirs] = list_doc_dirs
|
216
245
|
end
|
217
246
|
|
218
247
|
opt.separator nil
|
@@ -280,6 +309,13 @@ Options may also be set in the 'RI' environment variable.
|
|
280
309
|
opt.separator "Debug options:"
|
281
310
|
opt.separator nil
|
282
311
|
|
312
|
+
opt.on("--[no-]profile",
|
313
|
+
"Run with the ruby profiler") do |value|
|
314
|
+
options[:profile] = value
|
315
|
+
end
|
316
|
+
|
317
|
+
opt.separator nil
|
318
|
+
|
283
319
|
opt.on("--dump=CACHE", File,
|
284
320
|
"Dumps data from an ri cache or data file") do |value|
|
285
321
|
options[:dump_path] = value
|
@@ -352,7 +388,12 @@ Options may also be set in the 'RI' environment variable.
|
|
352
388
|
@list_doc_dirs = options[:list_doc_dirs]
|
353
389
|
|
354
390
|
@interactive = options[:interactive]
|
391
|
+
@server = options[:server]
|
355
392
|
@use_stdout = options[:use_stdout]
|
393
|
+
@show_all = options[:show_all]
|
394
|
+
|
395
|
+
# pager process for jruby
|
396
|
+
@jruby_pager_process = nil
|
356
397
|
end
|
357
398
|
|
358
399
|
##
|
@@ -400,15 +441,23 @@ Options may also be set in the 'RI' environment variable.
|
|
400
441
|
end
|
401
442
|
|
402
443
|
##
|
403
|
-
# Adds +
|
444
|
+
# Adds +extends+ to +out+
|
404
445
|
|
405
|
-
def
|
406
|
-
|
446
|
+
def add_extends out, extends
|
447
|
+
add_extension_modules out, 'Extended by', extends
|
448
|
+
end
|
449
|
+
|
450
|
+
##
|
451
|
+
# Adds a list of +extensions+ to this module of the given +type+ to +out+.
|
452
|
+
# add_includes and add_extends call this, so you should use those directly.
|
453
|
+
|
454
|
+
def add_extension_modules out, type, extensions
|
455
|
+
return if extensions.empty?
|
407
456
|
|
408
457
|
out << RDoc::Markup::Rule.new(1)
|
409
|
-
out << RDoc::Markup::Heading.new(1, "
|
458
|
+
out << RDoc::Markup::Heading.new(1, "#{type}:")
|
410
459
|
|
411
|
-
|
460
|
+
extensions.each do |modules, store|
|
412
461
|
if modules.length == 1 then
|
413
462
|
include = modules.first
|
414
463
|
name = include.name
|
@@ -445,6 +494,37 @@ Options may also be set in the 'RI' environment variable.
|
|
445
494
|
end
|
446
495
|
end
|
447
496
|
|
497
|
+
##
|
498
|
+
# Adds +includes+ to +out+
|
499
|
+
|
500
|
+
def add_includes out, includes
|
501
|
+
add_extension_modules out, 'Includes', includes
|
502
|
+
end
|
503
|
+
|
504
|
+
##
|
505
|
+
# Looks up the method +name+ and adds it to +out+
|
506
|
+
|
507
|
+
def add_method out, name
|
508
|
+
filtered = lookup_method name
|
509
|
+
|
510
|
+
method_out = method_document name, filtered
|
511
|
+
|
512
|
+
out.concat method_out.parts
|
513
|
+
end
|
514
|
+
|
515
|
+
##
|
516
|
+
# Adds documentation for all methods in +klass+ to +out+
|
517
|
+
|
518
|
+
def add_method_documentation out, klass
|
519
|
+
klass.method_list.each do |method|
|
520
|
+
begin
|
521
|
+
add_method out, method.full_name
|
522
|
+
rescue NotFoundError
|
523
|
+
next
|
524
|
+
end
|
525
|
+
end
|
526
|
+
end
|
527
|
+
|
448
528
|
##
|
449
529
|
# Adds a list of +methods+ to +out+ with a heading of +name+
|
450
530
|
|
@@ -454,10 +534,10 @@ Options may also be set in the 'RI' environment variable.
|
|
454
534
|
out << RDoc::Markup::Heading.new(1, "#{name}:")
|
455
535
|
out << RDoc::Markup::BlankLine.new
|
456
536
|
|
457
|
-
if @use_stdout and !@interactive
|
458
|
-
out.
|
537
|
+
if @use_stdout and !@interactive then
|
538
|
+
out.concat methods.map { |method|
|
459
539
|
RDoc::Markup::Verbatim.new method
|
460
|
-
|
540
|
+
}
|
461
541
|
else
|
462
542
|
out << RDoc::Markup::IndentedParagraph.new(2, methods.join(', '))
|
463
543
|
end
|
@@ -489,8 +569,8 @@ Options may also be set in the 'RI' environment variable.
|
|
489
569
|
|
490
570
|
klasses = klasses - seen
|
491
571
|
|
492
|
-
ancestors.
|
493
|
-
unexamined.
|
572
|
+
ancestors.concat klasses
|
573
|
+
unexamined.concat klasses
|
494
574
|
end
|
495
575
|
|
496
576
|
ancestors.reverse
|
@@ -505,7 +585,7 @@ Options may also be set in the 'RI' environment variable.
|
|
505
585
|
##
|
506
586
|
# Builds a RDoc::Markup::Document from +found+, +klasess+ and +includes+
|
507
587
|
|
508
|
-
def class_document name, found, klasses, includes
|
588
|
+
def class_document name, found, klasses, includes, extends
|
509
589
|
also_in = []
|
510
590
|
|
511
591
|
out = RDoc::Markup::Document.new
|
@@ -513,6 +593,7 @@ Options may also be set in the 'RI' environment variable.
|
|
513
593
|
add_class out, name, klasses
|
514
594
|
|
515
595
|
add_includes out, includes
|
596
|
+
add_extends out, extends
|
516
597
|
|
517
598
|
found.each do |store, klass|
|
518
599
|
comment = klass.comment
|
@@ -538,7 +619,7 @@ Options may also be set in the 'RI' environment variable.
|
|
538
619
|
parts.flatten!
|
539
620
|
parts.pop
|
540
621
|
|
541
|
-
out.
|
622
|
+
out.concat parts
|
542
623
|
else
|
543
624
|
out << comment
|
544
625
|
end
|
@@ -555,13 +636,13 @@ Options may also be set in the 'RI' environment variable.
|
|
555
636
|
|
556
637
|
constants = klass.constants.sort_by { |constant| constant.name }
|
557
638
|
|
558
|
-
list.
|
639
|
+
list.items.concat constants.map { |constant|
|
559
640
|
parts = constant.comment.parts if constant.comment
|
560
641
|
parts << RDoc::Markup::Paragraph.new('[not documented]') if
|
561
642
|
parts.empty?
|
562
643
|
|
563
644
|
RDoc::Markup::ListItem.new(constant.name, *parts)
|
564
|
-
|
645
|
+
}
|
565
646
|
|
566
647
|
out << list
|
567
648
|
out << RDoc::Markup::BlankLine.new
|
@@ -570,6 +651,8 @@ Options may also be set in the 'RI' environment variable.
|
|
570
651
|
add_method_list out, class_methods, 'Class methods'
|
571
652
|
add_method_list out, instance_methods, 'Instance methods'
|
572
653
|
add_method_list out, attributes, 'Attributes'
|
654
|
+
|
655
|
+
add_method_documentation out, klass if @show_all
|
573
656
|
end
|
574
657
|
|
575
658
|
add_also_in out, also_in
|
@@ -597,26 +680,29 @@ Options may also be set in the 'RI' environment variable.
|
|
597
680
|
end
|
598
681
|
|
599
682
|
##
|
600
|
-
# Returns the stores
|
601
|
-
# includes that match it
|
683
|
+
# Returns the stores wherein +name+ is found along with the classes,
|
684
|
+
# extends and includes that match it
|
602
685
|
|
603
|
-
def
|
686
|
+
def classes_and_includes_and_extends_for name
|
604
687
|
klasses = []
|
688
|
+
extends = []
|
605
689
|
includes = []
|
606
690
|
|
607
691
|
found = @stores.map do |store|
|
608
692
|
begin
|
609
693
|
klass = store.load_class name
|
610
694
|
klasses << klass
|
695
|
+
extends << [klass.extends, store] if klass.extends
|
611
696
|
includes << [klass.includes, store] if klass.includes
|
612
697
|
[store, klass]
|
613
|
-
rescue
|
698
|
+
rescue RDoc::Store::MissingFileError
|
614
699
|
end
|
615
700
|
end.compact
|
616
701
|
|
702
|
+
extends.reject! do |modules,| modules.empty? end
|
617
703
|
includes.reject! do |modules,| modules.empty? end
|
618
704
|
|
619
|
-
[found, klasses, includes]
|
705
|
+
[found, klasses, includes, extends]
|
620
706
|
end
|
621
707
|
|
622
708
|
##
|
@@ -655,7 +741,7 @@ Options may also be set in the 'RI' environment variable.
|
|
655
741
|
completions << "#{klass}#{selector}"
|
656
742
|
end
|
657
743
|
|
658
|
-
completions.
|
744
|
+
completions.concat methods
|
659
745
|
end
|
660
746
|
|
661
747
|
completions.sort.uniq
|
@@ -678,11 +764,12 @@ Options may also be set in the 'RI' environment variable.
|
|
678
764
|
def display_class name
|
679
765
|
return if name =~ /#|\./
|
680
766
|
|
681
|
-
found, klasses, includes =
|
767
|
+
found, klasses, includes, extends =
|
768
|
+
classes_and_includes_and_extends_for name
|
682
769
|
|
683
770
|
return if found.empty?
|
684
771
|
|
685
|
-
out = class_document name, found, klasses, includes
|
772
|
+
out = class_document name, found, klasses, includes, extends
|
686
773
|
|
687
774
|
display out
|
688
775
|
end
|
@@ -691,13 +778,9 @@ Options may also be set in the 'RI' environment variable.
|
|
691
778
|
# Outputs formatted RI data for method +name+
|
692
779
|
|
693
780
|
def display_method name
|
694
|
-
|
695
|
-
|
696
|
-
raise NotFoundError, name if found.empty?
|
697
|
-
|
698
|
-
filtered = filter_methods found, name
|
781
|
+
out = RDoc::Markup::Document.new
|
699
782
|
|
700
|
-
out
|
783
|
+
add_method out, name
|
701
784
|
|
702
785
|
display out
|
703
786
|
end
|
@@ -709,6 +792,11 @@ Options may also be set in the 'RI' environment variable.
|
|
709
792
|
# be guessed, raises an error if +name+ couldn't be guessed.
|
710
793
|
|
711
794
|
def display_name name
|
795
|
+
if name =~ /\w:(\w|$)/ then
|
796
|
+
display_page name
|
797
|
+
return true
|
798
|
+
end
|
799
|
+
|
712
800
|
return true if display_class name
|
713
801
|
|
714
802
|
display_method name if name =~ /::|#|\./
|
@@ -723,7 +811,7 @@ Options may also be set in the 'RI' environment variable.
|
|
723
811
|
page do |io|
|
724
812
|
io.puts "#{name} not found, maybe you meant:"
|
725
813
|
io.puts
|
726
|
-
io.puts matches.join("\n")
|
814
|
+
io.puts matches.sort.join("\n")
|
727
815
|
end
|
728
816
|
|
729
817
|
false
|
@@ -740,6 +828,63 @@ Options may also be set in the 'RI' environment variable.
|
|
740
828
|
end
|
741
829
|
end
|
742
830
|
|
831
|
+
##
|
832
|
+
# Outputs formatted RI data for page +name+.
|
833
|
+
|
834
|
+
def display_page name
|
835
|
+
store_name, page_name = name.split ':', 2
|
836
|
+
|
837
|
+
store = @stores.find { |s| s.source == store_name }
|
838
|
+
|
839
|
+
return display_page_list store if page_name.empty?
|
840
|
+
|
841
|
+
pages = store.cache[:pages]
|
842
|
+
|
843
|
+
unless pages.include? page_name then
|
844
|
+
found_names = pages.select do |n|
|
845
|
+
n =~ /#{Regexp.escape page_name}\.[^.]+$/
|
846
|
+
end
|
847
|
+
|
848
|
+
if found_names.length.zero? then
|
849
|
+
return display_page_list store, pages
|
850
|
+
elsif found_names.length > 1 then
|
851
|
+
return display_page_list store, found_names, page_name
|
852
|
+
end
|
853
|
+
|
854
|
+
page_name = found_names.first
|
855
|
+
end
|
856
|
+
|
857
|
+
page = store.load_page page_name
|
858
|
+
|
859
|
+
display page.comment
|
860
|
+
end
|
861
|
+
|
862
|
+
##
|
863
|
+
# Outputs a formatted RI page list for the pages in +store+.
|
864
|
+
|
865
|
+
def display_page_list store, pages = store.cache[:pages], search = nil
|
866
|
+
out = RDoc::Markup::Document.new
|
867
|
+
|
868
|
+
title = if search then
|
869
|
+
"#{search} pages"
|
870
|
+
else
|
871
|
+
'Pages'
|
872
|
+
end
|
873
|
+
|
874
|
+
out << RDoc::Markup::Heading.new(1, "#{title} in #{store.friendly_path}")
|
875
|
+
out << RDoc::Markup::BlankLine.new
|
876
|
+
|
877
|
+
list = RDoc::Markup::List.new(:BULLET)
|
878
|
+
|
879
|
+
pages.each do |page|
|
880
|
+
list << RDoc::Markup::Paragraph.new(page)
|
881
|
+
end
|
882
|
+
|
883
|
+
out << list
|
884
|
+
|
885
|
+
display out
|
886
|
+
end
|
887
|
+
|
743
888
|
##
|
744
889
|
# Expands abbreviated klass +klass+ into a fully-qualified class. "Zl::Da"
|
745
890
|
# will be expanded to Zlib::DataError.
|
@@ -772,7 +917,12 @@ Options may also be set in the 'RI' environment variable.
|
|
772
917
|
|
773
918
|
return [selector, method].join if klass.empty?
|
774
919
|
|
775
|
-
|
920
|
+
case selector
|
921
|
+
when ':' then
|
922
|
+
[find_store(klass), selector, method]
|
923
|
+
else
|
924
|
+
[expand_class(klass), selector, method]
|
925
|
+
end.join
|
776
926
|
end
|
777
927
|
|
778
928
|
##
|
@@ -836,6 +986,55 @@ Options may also be set in the 'RI' environment variable.
|
|
836
986
|
self
|
837
987
|
end
|
838
988
|
|
989
|
+
##
|
990
|
+
# Finds the given +pager+ for jruby. Returns an IO if +pager+ was found.
|
991
|
+
#
|
992
|
+
# Returns false if +pager+ does not exist.
|
993
|
+
#
|
994
|
+
# Returns nil if the jruby JVM doesn't support ProcessBuilder redirection
|
995
|
+
# (1.6 and older).
|
996
|
+
|
997
|
+
def find_pager_jruby pager
|
998
|
+
require 'java'
|
999
|
+
require 'shellwords'
|
1000
|
+
|
1001
|
+
return nil unless java.lang.ProcessBuilder.constants.include? :Redirect
|
1002
|
+
|
1003
|
+
pager = Shellwords.split pager
|
1004
|
+
|
1005
|
+
pb = java.lang.ProcessBuilder.new(*pager)
|
1006
|
+
pb = pb.redirect_output java.lang.ProcessBuilder::Redirect::INHERIT
|
1007
|
+
|
1008
|
+
@jruby_pager_process = pb.start
|
1009
|
+
|
1010
|
+
input = @jruby_pager_process.output_stream
|
1011
|
+
|
1012
|
+
io = input.to_io
|
1013
|
+
io.sync = true
|
1014
|
+
io
|
1015
|
+
rescue java.io.IOException
|
1016
|
+
false
|
1017
|
+
end
|
1018
|
+
|
1019
|
+
##
|
1020
|
+
# Finds a store that matches +name+ which can be the name of a gem, "ruby",
|
1021
|
+
# "home" or "site".
|
1022
|
+
#
|
1023
|
+
# See also RDoc::Store#source
|
1024
|
+
|
1025
|
+
def find_store name
|
1026
|
+
@stores.each do |store|
|
1027
|
+
source = store.source
|
1028
|
+
|
1029
|
+
return source if source == name
|
1030
|
+
|
1031
|
+
return source if
|
1032
|
+
store.type == :gem and source =~ /^#{Regexp.escape name}-\d/
|
1033
|
+
end
|
1034
|
+
|
1035
|
+
raise RDoc::RI::Driver::NotFoundError, name
|
1036
|
+
end
|
1037
|
+
|
839
1038
|
##
|
840
1039
|
# Creates a new RDoc::Markup::Formatter. If a formatter is given with -f,
|
841
1040
|
# use it. If we're outputting to a pager, use bs, otherwise ansi.
|
@@ -905,7 +1104,7 @@ Options may also be set in the 'RI' environment variable.
|
|
905
1104
|
classes = []
|
906
1105
|
|
907
1106
|
stores.each do |store|
|
908
|
-
classes << store.
|
1107
|
+
classes << store.module_names
|
909
1108
|
end
|
910
1109
|
|
911
1110
|
classes = classes.flatten.uniq.sort
|
@@ -947,7 +1146,7 @@ Options may also be set in the 'RI' environment variable.
|
|
947
1146
|
"#{klass}##{match}"
|
948
1147
|
end
|
949
1148
|
|
950
|
-
found.
|
1149
|
+
found.concat matches
|
951
1150
|
end
|
952
1151
|
end
|
953
1152
|
|
@@ -961,7 +1160,7 @@ Options may also be set in the 'RI' environment variable.
|
|
961
1160
|
"#{klass}::#{match}"
|
962
1161
|
end
|
963
1162
|
|
964
|
-
found.
|
1163
|
+
found.concat matches
|
965
1164
|
end
|
966
1165
|
end
|
967
1166
|
|
@@ -1008,7 +1207,18 @@ Options may also be set in the 'RI' environment variable.
|
|
1008
1207
|
end
|
1009
1208
|
|
1010
1209
|
##
|
1011
|
-
#
|
1210
|
+
# Returns a filtered list of methods matching +name+
|
1211
|
+
|
1212
|
+
def lookup_method name
|
1213
|
+
found = load_methods_matching name
|
1214
|
+
|
1215
|
+
raise NotFoundError, name if found.empty?
|
1216
|
+
|
1217
|
+
filter_methods found, name
|
1218
|
+
end
|
1219
|
+
|
1220
|
+
##
|
1221
|
+
# Builds a RDoc::Markup::Document from +found+, +klasses+ and +includes+
|
1012
1222
|
|
1013
1223
|
def method_document name, filtered
|
1014
1224
|
out = RDoc::Markup::Document.new
|
@@ -1023,6 +1233,7 @@ Options may also be set in the 'RI' environment variable.
|
|
1023
1233
|
unless name =~ /^#{Regexp.escape method.parent_name}/ then
|
1024
1234
|
out << RDoc::Markup::Heading.new(3, "Implementation from #{method.parent_name}")
|
1025
1235
|
end
|
1236
|
+
|
1026
1237
|
out << RDoc::Markup::Rule.new(1)
|
1027
1238
|
|
1028
1239
|
if method.arglists then
|
@@ -1032,6 +1243,12 @@ Options may also be set in the 'RI' environment variable.
|
|
1032
1243
|
out << RDoc::Markup::Rule.new(1)
|
1033
1244
|
end
|
1034
1245
|
|
1246
|
+
if method.respond_to?(:superclass_method) and method.superclass_method
|
1247
|
+
out << RDoc::Markup::BlankLine.new
|
1248
|
+
out << RDoc::Markup::Heading.new(4, "(Uses superclass method #{method.superclass_method})")
|
1249
|
+
out << RDoc::Markup::Rule.new(1)
|
1250
|
+
end
|
1251
|
+
|
1035
1252
|
out << RDoc::Markup::BlankLine.new
|
1036
1253
|
out << method.comment
|
1037
1254
|
out << RDoc::Markup::BlankLine.new
|
@@ -1076,6 +1293,7 @@ Options may also be set in the 'RI' environment variable.
|
|
1076
1293
|
yield pager
|
1077
1294
|
ensure
|
1078
1295
|
pager.close
|
1296
|
+
@jruby_pager_process.wait_for if @jruby_pager_process
|
1079
1297
|
end
|
1080
1298
|
else
|
1081
1299
|
yield $stdout
|
@@ -1100,7 +1318,7 @@ Options may also be set in the 'RI' environment variable.
|
|
1100
1318
|
# method
|
1101
1319
|
|
1102
1320
|
def parse_name name
|
1103
|
-
parts = name.split(/(
|
1321
|
+
parts = name.split(/(::?|#|\.)/)
|
1104
1322
|
|
1105
1323
|
if parts.length == 1 then
|
1106
1324
|
if parts.first =~ /^[a-z]|^([%&*+\/<>^`|~-]|\+@|-@|<<|<=>?|===?|=>|=~|>>|\[\]=?|~@)$/ then
|
@@ -1131,6 +1349,8 @@ Options may also be set in the 'RI' environment variable.
|
|
1131
1349
|
puts @doc_dirs
|
1132
1350
|
elsif @list then
|
1133
1351
|
list_known_classes @names
|
1352
|
+
elsif @server then
|
1353
|
+
start_server
|
1134
1354
|
elsif @interactive or @names.empty? then
|
1135
1355
|
interactive
|
1136
1356
|
else
|
@@ -1147,6 +1367,8 @@ Options may also be set in the 'RI' environment variable.
|
|
1147
1367
|
def setup_pager
|
1148
1368
|
return if @use_stdout
|
1149
1369
|
|
1370
|
+
jruby = Object.const_defined?(:RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
1371
|
+
|
1150
1372
|
pagers = [ENV['RI_PAGER'], ENV['PAGER'], 'pager', 'less', 'more']
|
1151
1373
|
|
1152
1374
|
pagers.compact.uniq.each do |pager|
|
@@ -1156,9 +1378,17 @@ Options may also be set in the 'RI' environment variable.
|
|
1156
1378
|
|
1157
1379
|
next unless in_path? pager_cmd
|
1158
1380
|
|
1159
|
-
|
1381
|
+
if jruby then
|
1382
|
+
case io = find_pager_jruby(pager)
|
1383
|
+
when nil then break
|
1384
|
+
when false then next
|
1385
|
+
else io
|
1386
|
+
end
|
1387
|
+
else
|
1388
|
+
io = IO.popen(pager, 'w') rescue next
|
1389
|
+
end
|
1160
1390
|
|
1161
|
-
next if $? and $?.exited? # pager didn't work
|
1391
|
+
next if $? and $?.pid == io.pid and $?.exited? # pager didn't work
|
1162
1392
|
|
1163
1393
|
@paging = true
|
1164
1394
|
|
@@ -1170,5 +1400,21 @@ Options may also be set in the 'RI' environment variable.
|
|
1170
1400
|
nil
|
1171
1401
|
end
|
1172
1402
|
|
1403
|
+
##
|
1404
|
+
# Starts a WEBrick server for ri.
|
1405
|
+
|
1406
|
+
def start_server
|
1407
|
+
require 'webrick'
|
1408
|
+
|
1409
|
+
server = WEBrick::HTTPServer.new :Port => @server
|
1410
|
+
|
1411
|
+
server.mount '/', RDoc::Servlet
|
1412
|
+
|
1413
|
+
trap 'INT' do server.shutdown end
|
1414
|
+
trap 'TERM' do server.shutdown end
|
1415
|
+
|
1416
|
+
server.start
|
1417
|
+
end
|
1418
|
+
|
1173
1419
|
end
|
1174
1420
|
|