rdoc 6.3.4.1 → 8.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +195 -0
- data/History.rdoc +65 -63
- data/LEGAL.rdoc +7 -1
- data/LICENSE.rdoc +6 -0
- data/README.md +236 -0
- data/RI.md +842 -0
- data/TODO.rdoc +8 -7
- data/doc/markup_reference/markdown.md +659 -0
- data/doc/markup_reference/rdoc.rdoc +1169 -0
- data/exe/rdoc +0 -1
- data/lib/rdoc/{alias.rb → code_object/alias.rb} +4 -18
- data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +50 -24
- data/lib/rdoc/{attr.rb → code_object/attr.rb} +16 -14
- data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +225 -58
- data/lib/rdoc/{constant.rb → code_object/constant.rb} +44 -10
- data/lib/rdoc/code_object/context/section.rb +182 -0
- data/lib/rdoc/{context.rb → code_object/context.rb} +78 -106
- data/lib/rdoc/{extend.rb → code_object/extend.rb} +0 -1
- data/lib/rdoc/{include.rb → code_object/include.rb} +0 -1
- data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +46 -48
- data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +6 -4
- data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +2 -3
- data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +2 -3
- data/lib/rdoc/{require.rb → code_object/require.rb} +1 -2
- data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +5 -1
- data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +60 -63
- data/lib/rdoc/code_object.rb +11 -39
- data/lib/rdoc/code_objects.rb +1 -2
- data/lib/rdoc/comment.rb +202 -99
- data/lib/rdoc/cross_reference.rb +75 -62
- data/lib/rdoc/encoding.rb +8 -24
- data/lib/rdoc/erb_partial.rb +1 -2
- data/lib/rdoc/erbio.rb +3 -8
- data/lib/rdoc/generator/aliki.rb +200 -0
- data/lib/rdoc/generator/darkfish.rb +156 -122
- data/lib/rdoc/generator/json_index.rb +8 -24
- data/lib/rdoc/generator/markup.rb +70 -34
- data/lib/rdoc/generator/pot/message_extractor.rb +7 -7
- data/lib/rdoc/generator/pot/po.rb +1 -1
- data/lib/rdoc/generator/pot/po_entry.rb +8 -8
- data/lib/rdoc/generator/pot.rb +1 -5
- data/lib/rdoc/generator/ri.rb +1 -2
- data/lib/rdoc/generator/template/aliki/DESIGN.md +536 -0
- data/lib/rdoc/generator/template/aliki/_aside_toc.rhtml +8 -0
- data/lib/rdoc/generator/template/aliki/_footer.rhtml +23 -0
- data/lib/rdoc/generator/template/aliki/_head.rhtml +163 -0
- data/lib/rdoc/generator/template/aliki/_header.rhtml +56 -0
- data/lib/rdoc/generator/template/aliki/_icons.rhtml +208 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_ancestors.rhtml +16 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_classes.rhtml +15 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_extends.rhtml +27 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_includes.rhtml +27 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_installed.rhtml +16 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_methods.rhtml +41 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_pages.rhtml +67 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_search.rhtml +15 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_sections.rhtml +21 -0
- data/lib/rdoc/generator/template/aliki/_sidebar_toggle.rhtml +3 -0
- data/lib/rdoc/generator/template/aliki/class.rhtml +230 -0
- data/lib/rdoc/generator/template/aliki/css/rdoc.css +2181 -0
- data/lib/rdoc/generator/template/aliki/index.rhtml +22 -0
- data/lib/rdoc/generator/template/aliki/js/aliki.js +513 -0
- data/lib/rdoc/generator/template/aliki/js/bash_highlighter.js +167 -0
- data/lib/rdoc/generator/template/aliki/js/c_highlighter.js +299 -0
- data/lib/rdoc/generator/template/aliki/js/search_controller.js +129 -0
- data/lib/rdoc/generator/template/aliki/js/search_navigation.js +105 -0
- data/lib/rdoc/generator/template/aliki/js/search_ranker.js +239 -0
- data/lib/rdoc/generator/template/aliki/js/theme-toggle.js +112 -0
- data/lib/rdoc/generator/template/aliki/page.rhtml +18 -0
- data/lib/rdoc/generator/template/aliki/servlet_not_found.rhtml +14 -0
- data/lib/rdoc/generator/template/aliki/servlet_root.rhtml +65 -0
- data/lib/rdoc/generator/template/darkfish/_footer.rhtml +3 -3
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +35 -14
- data/lib/rdoc/generator/template/darkfish/_sidebar_classes.rhtml +1 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_extends.rhtml +11 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_includes.rhtml +11 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_installed.rhtml +7 -6
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +20 -11
- data/lib/rdoc/generator/template/darkfish/_sidebar_pages.rhtml +25 -5
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +4 -9
- data/lib/rdoc/generator/template/darkfish/_sidebar_search.rhtml +2 -1
- data/lib/rdoc/generator/template/darkfish/_sidebar_sections.rhtml +4 -4
- data/lib/rdoc/generator/template/darkfish/_sidebar_table_of_contents.rhtml +28 -7
- data/lib/rdoc/generator/template/darkfish/_sidebar_toggle.rhtml +3 -0
- data/lib/rdoc/generator/template/darkfish/class.rhtml +138 -90
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +420 -358
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Bold.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/fonts/SourceCodePro-Regular.ttf +0 -0
- data/lib/rdoc/generator/template/darkfish/index.rhtml +14 -12
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +59 -3
- data/lib/rdoc/generator/template/darkfish/js/search.js +15 -5
- data/lib/rdoc/generator/template/darkfish/page.rhtml +7 -6
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +12 -9
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +24 -21
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +35 -21
- data/lib/rdoc/generator/template/json_index/js/navigation.js +8 -8
- data/lib/rdoc/generator/template/json_index/js/searcher.js +48 -6
- data/lib/rdoc/generator.rb +6 -5
- data/lib/rdoc/i18n/text.rb +3 -3
- data/lib/rdoc/i18n.rb +1 -1
- data/lib/rdoc/known_classes.rb +5 -4
- data/lib/rdoc/markdown/entities.rb +0 -1
- data/lib/rdoc/markdown/literals.kpeg +0 -2
- data/lib/rdoc/markdown/literals.rb +0 -1
- data/lib/rdoc/markdown.kpeg +140 -62
- data/lib/rdoc/markdown.rb +1015 -873
- data/lib/rdoc/markup/blank_line.rb +25 -24
- data/lib/rdoc/markup/block_quote.rb +1 -2
- data/lib/rdoc/markup/document.rb +10 -11
- data/lib/rdoc/markup/element.rb +21 -0
- data/lib/rdoc/markup/formatter.rb +134 -115
- data/lib/rdoc/markup/hard_break.rb +30 -28
- data/lib/rdoc/markup/heading.rb +163 -72
- data/lib/rdoc/markup/include.rb +3 -4
- data/lib/rdoc/markup/indented_paragraph.rb +4 -5
- data/lib/rdoc/markup/inline_parser.rb +312 -0
- data/lib/rdoc/markup/list.rb +6 -7
- data/lib/rdoc/markup/list_item.rb +6 -7
- data/lib/rdoc/markup/paragraph.rb +2 -3
- data/lib/rdoc/markup/parser.rb +29 -19
- data/lib/rdoc/markup/pre_process.rb +39 -18
- data/lib/rdoc/markup/raw.rb +52 -56
- data/lib/rdoc/markup/rule.rb +2 -3
- data/lib/rdoc/markup/table.rb +49 -32
- data/lib/rdoc/markup/to_ansi.rb +58 -8
- data/lib/rdoc/markup/to_bs.rb +47 -38
- data/lib/rdoc/markup/to_html.rb +343 -105
- data/lib/rdoc/markup/to_html_crossref.rb +143 -58
- data/lib/rdoc/markup/to_html_snippet.rb +78 -76
- data/lib/rdoc/markup/to_joined_paragraph.rb +3 -9
- data/lib/rdoc/markup/to_label.rb +34 -25
- data/lib/rdoc/markup/to_markdown.rb +74 -51
- data/lib/rdoc/markup/to_rdoc.rb +141 -82
- data/lib/rdoc/markup/to_table_of_contents.rb +4 -5
- data/lib/rdoc/markup/to_test.rb +10 -3
- data/lib/rdoc/markup/to_tt_only.rb +17 -31
- data/lib/rdoc/markup/verbatim.rb +5 -6
- data/lib/rdoc/markup.rb +59 -707
- data/lib/rdoc/options.rb +228 -101
- data/lib/rdoc/parser/c.rb +186 -184
- data/lib/rdoc/parser/changelog.rb +57 -13
- data/lib/rdoc/parser/markdown.rb +0 -2
- data/lib/rdoc/parser/rbs.rb +275 -0
- data/lib/rdoc/parser/rd.rb +0 -1
- data/lib/rdoc/parser/ruby.rb +963 -2024
- data/lib/rdoc/parser/ruby_colorizer.rb +253 -0
- data/lib/rdoc/parser/simple.rb +6 -23
- data/lib/rdoc/parser/text.rb +0 -1
- data/lib/rdoc/parser.rb +35 -14
- data/lib/rdoc/rbs_helper.rb +186 -0
- data/lib/rdoc/rd/block_parser.rb +659 -11
- data/lib/rdoc/rd/block_parser.ry +13 -9
- data/lib/rdoc/rd/inline.rb +4 -5
- data/lib/rdoc/rd/inline_parser.rb +646 -2
- data/lib/rdoc/rd.rb +4 -5
- data/lib/rdoc/rdoc.rb +234 -90
- data/lib/rdoc/ri/driver.rb +172 -172
- data/lib/rdoc/ri/paths.rb +3 -3
- data/lib/rdoc/{servlet.rb → ri/servlet.rb} +28 -27
- data/lib/rdoc/ri/store.rb +0 -1
- data/lib/rdoc/ri/task.rb +3 -3
- data/lib/rdoc/ri.rb +5 -5
- data/lib/rdoc/rubygems_hook.rb +106 -25
- data/lib/rdoc/server.rb +460 -0
- data/lib/rdoc/stats/normal.rb +1 -1
- data/lib/rdoc/stats/quiet.rb +1 -2
- data/lib/rdoc/stats/verbose.rb +3 -5
- data/lib/rdoc/stats.rb +158 -136
- data/lib/rdoc/store.rb +267 -48
- data/lib/rdoc/task.rb +54 -28
- data/lib/rdoc/text.rb +60 -120
- data/lib/rdoc/token_stream.rb +30 -45
- data/lib/rdoc/tom_doc.rb +9 -15
- data/lib/rdoc/version.rb +3 -1
- data/lib/rdoc.rb +90 -52
- data/lib/rubygems_plugin.rb +14 -0
- data/man/ri.1 +2 -0
- data/rdoc-logo.svg +43 -0
- data/rdoc.gemspec +25 -200
- metadata +120 -53
- data/CONTRIBUTING.rdoc +0 -220
- data/ExampleMarkdown.md +0 -37
- data/ExampleRDoc.rdoc +0 -208
- data/Gemfile +0 -12
- data/README.rdoc +0 -129
- data/RI.rdoc +0 -57
- data/Rakefile +0 -101
- data/bin/console +0 -7
- data/bin/setup +0 -6
- data/lib/rdoc/anon_class.rb +0 -11
- data/lib/rdoc/context/section.rb +0 -232
- data/lib/rdoc/generator/template/darkfish/.document +0 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_VCS_info.rhtml +0 -19
- data/lib/rdoc/generator/template/darkfish/_sidebar_in_files.rhtml +0 -9
- data/lib/rdoc/generator/template/json_index/.document +0 -1
- data/lib/rdoc/ghost_method.rb +0 -7
- data/lib/rdoc/markup/attr_changer.rb +0 -23
- data/lib/rdoc/markup/attr_span.rb +0 -36
- data/lib/rdoc/markup/attribute_manager.rb +0 -409
- data/lib/rdoc/markup/attributes.rb +0 -71
- data/lib/rdoc/markup/regexp_handling.rb +0 -41
- data/lib/rdoc/meta_method.rb +0 -7
- data/lib/rdoc/parser/ripper_state_lex.rb +0 -590
- data/lib/rdoc/parser/ruby_tools.rb +0 -167
data/lib/rdoc/ri/driver.rb
CHANGED
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
require 'abbrev'
|
|
3
2
|
require 'optparse'
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
require 'readline'
|
|
7
|
-
rescue LoadError
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
begin
|
|
11
|
-
require 'win32console'
|
|
12
|
-
rescue LoadError
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
require 'rdoc'
|
|
16
|
-
|
|
17
|
-
##
|
|
18
|
-
# For RubyGems backwards compatibility
|
|
4
|
+
require_relative '../../rdoc'
|
|
19
5
|
|
|
20
|
-
require_relative 'formatter'
|
|
6
|
+
require_relative 'formatter' # For RubyGems backwards compatibility
|
|
7
|
+
# TODO: Fix weird documentation with `require_relative`
|
|
21
8
|
|
|
22
9
|
##
|
|
23
10
|
# The RI driver implements the command-line ri tool.
|
|
@@ -47,9 +34,9 @@ class RDoc::RI::Driver
|
|
|
47
34
|
|
|
48
35
|
class NotFoundError < Error
|
|
49
36
|
|
|
50
|
-
def initialize(klass,
|
|
37
|
+
def initialize(klass, suggestion_proc = nil) # :nodoc:
|
|
51
38
|
@klass = klass
|
|
52
|
-
@
|
|
39
|
+
@suggestion_proc = suggestion_proc
|
|
53
40
|
end
|
|
54
41
|
|
|
55
42
|
##
|
|
@@ -61,8 +48,9 @@ class RDoc::RI::Driver
|
|
|
61
48
|
|
|
62
49
|
def message # :nodoc:
|
|
63
50
|
str = "Nothing known about #{@klass}"
|
|
64
|
-
|
|
65
|
-
|
|
51
|
+
suggestions = @suggestion_proc&.call
|
|
52
|
+
if suggestions and !suggestions.empty?
|
|
53
|
+
str += "\nDid you mean? #{suggestions.join("\n ")}"
|
|
66
54
|
end
|
|
67
55
|
str
|
|
68
56
|
end
|
|
@@ -91,6 +79,7 @@ class RDoc::RI::Driver
|
|
|
91
79
|
options[:interactive] = false
|
|
92
80
|
options[:profile] = false
|
|
93
81
|
options[:show_all] = false
|
|
82
|
+
options[:expand_refs] = true
|
|
94
83
|
options[:use_stdout] = !$stdout.tty?
|
|
95
84
|
options[:width] = 72
|
|
96
85
|
|
|
@@ -107,7 +96,7 @@ class RDoc::RI::Driver
|
|
|
107
96
|
##
|
|
108
97
|
# Dump +data_path+ using pp
|
|
109
98
|
|
|
110
|
-
def self.dump
|
|
99
|
+
def self.dump(data_path)
|
|
111
100
|
require 'pp'
|
|
112
101
|
|
|
113
102
|
File.open data_path, 'rb' do |io|
|
|
@@ -118,14 +107,10 @@ class RDoc::RI::Driver
|
|
|
118
107
|
##
|
|
119
108
|
# Parses +argv+ and returns a Hash of options
|
|
120
109
|
|
|
121
|
-
def self.process_args
|
|
110
|
+
def self.process_args(argv)
|
|
122
111
|
options = default_options
|
|
123
112
|
|
|
124
113
|
opts = OptionParser.new do |opt|
|
|
125
|
-
opt.accept File do |file,|
|
|
126
|
-
File.readable?(file) and not File.directory?(file) and file
|
|
127
|
-
end
|
|
128
|
-
|
|
129
114
|
opt.program_name = File.basename $0
|
|
130
115
|
opt.version = RDoc::VERSION
|
|
131
116
|
opt.release = nil
|
|
@@ -142,6 +127,8 @@ Where name can be:
|
|
|
142
127
|
|
|
143
128
|
gem_name: | gem_name:README | gem_name:History
|
|
144
129
|
|
|
130
|
+
ruby: | ruby:NEWS | ruby:globals
|
|
131
|
+
|
|
145
132
|
All class names may be abbreviated to their minimum unambiguous form.
|
|
146
133
|
If a name is ambiguous, all valid options will be listed.
|
|
147
134
|
|
|
@@ -153,6 +140,10 @@ they're contained in. If the gem name is followed by a ':' all files in the
|
|
|
153
140
|
gem will be shown. The file name extension may be omitted where it is
|
|
154
141
|
unambiguous.
|
|
155
142
|
|
|
143
|
+
'ruby' can be used as a pseudo gem name to display files from the Ruby
|
|
144
|
+
core documentation. Use 'ruby:' by itself to get a list of all available
|
|
145
|
+
core documentation files.
|
|
146
|
+
|
|
156
147
|
For example:
|
|
157
148
|
|
|
158
149
|
#{opt.program_name} Fil
|
|
@@ -160,6 +151,7 @@ For example:
|
|
|
160
151
|
#{opt.program_name} File.new
|
|
161
152
|
#{opt.program_name} zip
|
|
162
153
|
#{opt.program_name} rdoc:README
|
|
154
|
+
#{opt.program_name} ruby:comments
|
|
163
155
|
|
|
164
156
|
Note that shell quoting or escaping may be required for method names
|
|
165
157
|
containing punctuation:
|
|
@@ -254,6 +246,12 @@ or the PAGER environment variable.
|
|
|
254
246
|
|
|
255
247
|
opt.separator nil
|
|
256
248
|
|
|
249
|
+
opt.on("--[no-]expand-refs", "Expand rdoc-refs at the end of output") do |value|
|
|
250
|
+
options[:expand_refs] = value
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
opt.separator nil
|
|
254
|
+
|
|
257
255
|
opt.on("--help", "-h",
|
|
258
256
|
"Show help and exit.") do
|
|
259
257
|
puts opts
|
|
@@ -350,9 +348,17 @@ or the PAGER environment variable.
|
|
|
350
348
|
|
|
351
349
|
opt.separator nil
|
|
352
350
|
|
|
353
|
-
opt.on("--dump=CACHE",
|
|
351
|
+
opt.on("--dump=CACHE",
|
|
354
352
|
"Dump data from an ri cache or data file.") do |value|
|
|
355
|
-
|
|
353
|
+
unless File.readable?(value)
|
|
354
|
+
abort "#{value.inspect} is not readable"
|
|
355
|
+
end
|
|
356
|
+
|
|
357
|
+
if File.directory?(value)
|
|
358
|
+
abort "#{value.inspect} is a directory"
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
options[:dump_path] = File.new(value)
|
|
356
362
|
end
|
|
357
363
|
end
|
|
358
364
|
|
|
@@ -378,7 +384,7 @@ or the PAGER environment variable.
|
|
|
378
384
|
##
|
|
379
385
|
# Runs the ri command line executable using +argv+
|
|
380
386
|
|
|
381
|
-
def self.run
|
|
387
|
+
def self.run(argv = ARGV)
|
|
382
388
|
options = process_args argv
|
|
383
389
|
|
|
384
390
|
if options[:dump_path] then
|
|
@@ -393,7 +399,7 @@ or the PAGER environment variable.
|
|
|
393
399
|
##
|
|
394
400
|
# Creates a new driver using +initial_options+ from ::process_args
|
|
395
401
|
|
|
396
|
-
def initialize
|
|
402
|
+
def initialize(initial_options = {})
|
|
397
403
|
@paging = false
|
|
398
404
|
@classes = nil
|
|
399
405
|
|
|
@@ -414,7 +420,7 @@ or the PAGER environment variable.
|
|
|
414
420
|
*options[:extra_doc_dirs]) do |path, type|
|
|
415
421
|
@doc_dirs << path
|
|
416
422
|
|
|
417
|
-
store = RDoc::RI::Store.new path, type
|
|
423
|
+
store = RDoc::RI::Store.new(RDoc::Options.new, path: path, type: type)
|
|
418
424
|
store.load_cache
|
|
419
425
|
@stores << store
|
|
420
426
|
end
|
|
@@ -426,15 +432,13 @@ or the PAGER environment variable.
|
|
|
426
432
|
@use_stdout = options[:use_stdout]
|
|
427
433
|
@show_all = options[:show_all]
|
|
428
434
|
@width = options[:width]
|
|
429
|
-
|
|
430
|
-
# pager process for jruby
|
|
431
|
-
@jruby_pager_process = nil
|
|
435
|
+
@expand_refs = options[:expand_refs]
|
|
432
436
|
end
|
|
433
437
|
|
|
434
438
|
##
|
|
435
439
|
# Adds paths for undocumented classes +also_in+ to +out+
|
|
436
440
|
|
|
437
|
-
def add_also_in
|
|
441
|
+
def add_also_in(out, also_in)
|
|
438
442
|
return if also_in.empty?
|
|
439
443
|
|
|
440
444
|
out << RDoc::Markup::Rule.new(1)
|
|
@@ -451,7 +455,7 @@ or the PAGER environment variable.
|
|
|
451
455
|
# Adds a class header to +out+ for class +name+ which is described in
|
|
452
456
|
# +classes+.
|
|
453
457
|
|
|
454
|
-
def add_class
|
|
458
|
+
def add_class(out, name, classes)
|
|
455
459
|
heading = if classes.all? { |klass| klass.module? } then
|
|
456
460
|
name
|
|
457
461
|
else
|
|
@@ -471,14 +475,14 @@ or the PAGER environment variable.
|
|
|
471
475
|
##
|
|
472
476
|
# Adds "(from ...)" to +out+ for +store+
|
|
473
477
|
|
|
474
|
-
def add_from
|
|
478
|
+
def add_from(out, store)
|
|
475
479
|
out << RDoc::Markup::Paragraph.new("(from #{store.friendly_path})")
|
|
476
480
|
end
|
|
477
481
|
|
|
478
482
|
##
|
|
479
483
|
# Adds +extends+ to +out+
|
|
480
484
|
|
|
481
|
-
def add_extends
|
|
485
|
+
def add_extends(out, extends)
|
|
482
486
|
add_extension_modules out, 'Extended by', extends
|
|
483
487
|
end
|
|
484
488
|
|
|
@@ -486,7 +490,7 @@ or the PAGER environment variable.
|
|
|
486
490
|
# Adds a list of +extensions+ to this module of the given +type+ to +out+.
|
|
487
491
|
# add_includes and add_extends call this, so you should use those directly.
|
|
488
492
|
|
|
489
|
-
def add_extension_modules
|
|
493
|
+
def add_extension_modules(out, type, extensions)
|
|
490
494
|
return if extensions.empty?
|
|
491
495
|
|
|
492
496
|
out << RDoc::Markup::Rule.new(1)
|
|
@@ -504,7 +508,7 @@ or the PAGER environment variable.
|
|
|
504
508
|
##
|
|
505
509
|
# Renders multiple included +modules+ from +store+ to +out+.
|
|
506
510
|
|
|
507
|
-
def add_extension_modules_multiple
|
|
511
|
+
def add_extension_modules_multiple(out, store, modules) # :nodoc:
|
|
508
512
|
out << RDoc::Markup::Paragraph.new("(from #{store.friendly_path})")
|
|
509
513
|
|
|
510
514
|
wout, with = modules.partition { |incl| incl.comment.empty? }
|
|
@@ -514,7 +518,7 @@ or the PAGER environment variable.
|
|
|
514
518
|
with.each do |incl|
|
|
515
519
|
out << RDoc::Markup::Paragraph.new(incl.name)
|
|
516
520
|
out << RDoc::Markup::BlankLine.new
|
|
517
|
-
out << incl.comment
|
|
521
|
+
out << incl.comment.parse
|
|
518
522
|
end
|
|
519
523
|
|
|
520
524
|
unless wout.empty? then
|
|
@@ -531,39 +535,36 @@ or the PAGER environment variable.
|
|
|
531
535
|
##
|
|
532
536
|
# Adds a single extension module +include+ from +store+ to +out+
|
|
533
537
|
|
|
534
|
-
def add_extension_modules_single
|
|
538
|
+
def add_extension_modules_single(out, store, include) # :nodoc:
|
|
535
539
|
name = include.name
|
|
536
540
|
path = store.friendly_path
|
|
537
541
|
out << RDoc::Markup::Paragraph.new("#{name} (from #{path})")
|
|
538
542
|
|
|
539
543
|
if include.comment then
|
|
540
544
|
out << RDoc::Markup::BlankLine.new
|
|
541
|
-
out << include.comment
|
|
545
|
+
out << include.comment.parse
|
|
542
546
|
end
|
|
543
547
|
end
|
|
544
548
|
|
|
545
549
|
##
|
|
546
550
|
# Adds +includes+ to +out+
|
|
547
551
|
|
|
548
|
-
def add_includes
|
|
552
|
+
def add_includes(out, includes)
|
|
549
553
|
add_extension_modules out, 'Includes', includes
|
|
550
554
|
end
|
|
551
555
|
|
|
552
556
|
##
|
|
553
557
|
# Looks up the method +name+ and adds it to +out+
|
|
554
558
|
|
|
555
|
-
def add_method
|
|
556
|
-
filtered
|
|
557
|
-
|
|
558
|
-
method_out = method_document name, filtered
|
|
559
|
-
|
|
560
|
-
out.concat method_out.parts
|
|
559
|
+
def add_method(out, name)
|
|
560
|
+
filtered = lookup_method name
|
|
561
|
+
method_document out, name, filtered
|
|
561
562
|
end
|
|
562
563
|
|
|
563
564
|
##
|
|
564
565
|
# Adds documentation for all methods in +klass+ to +out+
|
|
565
566
|
|
|
566
|
-
def add_method_documentation
|
|
567
|
+
def add_method_documentation(out, klass)
|
|
567
568
|
klass.method_list.each do |method|
|
|
568
569
|
begin
|
|
569
570
|
add_method out, method.full_name
|
|
@@ -576,7 +577,7 @@ or the PAGER environment variable.
|
|
|
576
577
|
##
|
|
577
578
|
# Adds a list of +methods+ to +out+ with a heading of +name+
|
|
578
579
|
|
|
579
|
-
def add_method_list
|
|
580
|
+
def add_method_list(out, methods, name)
|
|
580
581
|
return if methods.empty?
|
|
581
582
|
|
|
582
583
|
out << RDoc::Markup::Heading.new(1, "#{name}:")
|
|
@@ -596,7 +597,7 @@ or the PAGER environment variable.
|
|
|
596
597
|
##
|
|
597
598
|
# Returns ancestor classes of +klass+
|
|
598
599
|
|
|
599
|
-
def ancestors_of
|
|
600
|
+
def ancestors_of(klass)
|
|
600
601
|
ancestors = []
|
|
601
602
|
|
|
602
603
|
unexamined = [klass]
|
|
@@ -609,11 +610,11 @@ or the PAGER environment variable.
|
|
|
609
610
|
|
|
610
611
|
stores = classes[current]
|
|
611
612
|
|
|
612
|
-
|
|
613
|
+
next unless stores and not stores.empty?
|
|
613
614
|
|
|
614
|
-
klasses = stores.
|
|
615
|
-
store.ancestors[current]
|
|
616
|
-
end.
|
|
615
|
+
klasses = stores.flat_map do |store|
|
|
616
|
+
store.ancestors[current] || []
|
|
617
|
+
end.uniq
|
|
617
618
|
|
|
618
619
|
klasses = klasses - seen
|
|
619
620
|
|
|
@@ -633,7 +634,7 @@ or the PAGER environment variable.
|
|
|
633
634
|
##
|
|
634
635
|
# Builds a RDoc::Markup::Document from +found+, +klasess+ and +includes+
|
|
635
636
|
|
|
636
|
-
def class_document
|
|
637
|
+
def class_document(name, found, klasses, includes, extends)
|
|
637
638
|
also_in = []
|
|
638
639
|
|
|
639
640
|
out = RDoc::Markup::Document.new
|
|
@@ -649,18 +650,19 @@ or the PAGER environment variable.
|
|
|
649
650
|
|
|
650
651
|
add_also_in out, also_in
|
|
651
652
|
|
|
653
|
+
expand_rdoc_refs_at_the_bottom(out)
|
|
652
654
|
out
|
|
653
655
|
end
|
|
654
656
|
|
|
655
657
|
##
|
|
656
658
|
# Adds the class +comment+ to +out+.
|
|
657
659
|
|
|
658
|
-
def class_document_comment
|
|
659
|
-
unless
|
|
660
|
+
def class_document_comment(out, document) # :nodoc:
|
|
661
|
+
unless document.empty? then
|
|
660
662
|
out << RDoc::Markup::Rule.new(1)
|
|
661
663
|
|
|
662
|
-
if
|
|
663
|
-
parts =
|
|
664
|
+
if document.merged? then
|
|
665
|
+
parts = document.parts
|
|
664
666
|
parts = parts.zip [RDoc::Markup::BlankLine.new] * parts.length
|
|
665
667
|
parts.flatten!
|
|
666
668
|
parts.pop
|
|
@@ -675,7 +677,7 @@ or the PAGER environment variable.
|
|
|
675
677
|
##
|
|
676
678
|
# Adds the constants from +klass+ to the Document +out+.
|
|
677
679
|
|
|
678
|
-
def class_document_constants
|
|
680
|
+
def class_document_constants(out, klass) # :nodoc:
|
|
679
681
|
return if klass.constants.empty?
|
|
680
682
|
|
|
681
683
|
out << RDoc::Markup::Heading.new(1, "Constants:")
|
|
@@ -685,7 +687,7 @@ or the PAGER environment variable.
|
|
|
685
687
|
constants = klass.constants.sort_by { |constant| constant.name }
|
|
686
688
|
|
|
687
689
|
list.items.concat constants.map { |constant|
|
|
688
|
-
parts = constant.comment.parts
|
|
690
|
+
parts = constant.comment.parse.parts
|
|
689
691
|
parts << RDoc::Markup::Paragraph.new('[not documented]') if
|
|
690
692
|
parts.empty?
|
|
691
693
|
|
|
@@ -719,7 +721,7 @@ or the PAGER environment variable.
|
|
|
719
721
|
# Returns the stores wherein +name+ is found along with the classes,
|
|
720
722
|
# extends and includes that match it
|
|
721
723
|
|
|
722
|
-
def classes_and_includes_and_extends_for
|
|
724
|
+
def classes_and_includes_and_extends_for(name)
|
|
723
725
|
klasses = []
|
|
724
726
|
extends = []
|
|
725
727
|
includes = []
|
|
@@ -744,7 +746,7 @@ or the PAGER environment variable.
|
|
|
744
746
|
##
|
|
745
747
|
# Completes +name+ based on the caches. For Readline
|
|
746
748
|
|
|
747
|
-
def complete
|
|
749
|
+
def complete(name)
|
|
748
750
|
completions = []
|
|
749
751
|
|
|
750
752
|
klass, selector, method = parse_name name
|
|
@@ -752,10 +754,10 @@ or the PAGER environment variable.
|
|
|
752
754
|
complete_klass name, klass, selector, method, completions
|
|
753
755
|
complete_method name, klass, selector, completions
|
|
754
756
|
|
|
755
|
-
completions.sort
|
|
757
|
+
completions.uniq.select {|s| s.start_with? name }.sort
|
|
756
758
|
end
|
|
757
759
|
|
|
758
|
-
def complete_klass
|
|
760
|
+
def complete_klass(name, klass, selector, method, completions) # :nodoc:
|
|
759
761
|
klasses = classes.keys
|
|
760
762
|
|
|
761
763
|
# may need to include Foo when given Foo::
|
|
@@ -774,7 +776,7 @@ or the PAGER environment variable.
|
|
|
774
776
|
end
|
|
775
777
|
end
|
|
776
778
|
|
|
777
|
-
def complete_method
|
|
779
|
+
def complete_method(name, klass, selector, completions) # :nodoc:
|
|
778
780
|
if completions.include? klass and name =~ /#|\.|::/ then
|
|
779
781
|
methods = list_methods_matching name
|
|
780
782
|
|
|
@@ -787,14 +789,22 @@ or the PAGER environment variable.
|
|
|
787
789
|
completions << "#{klass}#{selector}"
|
|
788
790
|
end
|
|
789
791
|
|
|
790
|
-
|
|
792
|
+
methods.each do |klass_sel_method|
|
|
793
|
+
match = klass_sel_method.match(/^(.+)(#|\.|::)([^#.:]+)$/)
|
|
794
|
+
# match[2] is `::` for class method and `#` for instance method.
|
|
795
|
+
# To be consistent with old completion that completes `['Foo#i', 'Foo::c']` for `Foo.`,
|
|
796
|
+
# `.` should be a wildcard for both `#` and `::` here.
|
|
797
|
+
if match && match[2] == selector || selector == '.'
|
|
798
|
+
completions << match[1] + selector + match[3]
|
|
799
|
+
end
|
|
800
|
+
end
|
|
791
801
|
end
|
|
792
802
|
end
|
|
793
803
|
|
|
794
804
|
##
|
|
795
805
|
# Converts +document+ to text and writes it to the pager
|
|
796
806
|
|
|
797
|
-
def display
|
|
807
|
+
def display(document)
|
|
798
808
|
page do |io|
|
|
799
809
|
f = formatter(io)
|
|
800
810
|
f.width = @width if @width and f.respond_to?(:width)
|
|
@@ -807,7 +817,7 @@ or the PAGER environment variable.
|
|
|
807
817
|
##
|
|
808
818
|
# Outputs formatted RI data for class +name+. Groups undocumented classes
|
|
809
819
|
|
|
810
|
-
def display_class
|
|
820
|
+
def display_class(name)
|
|
811
821
|
return if name =~ /#|\./
|
|
812
822
|
|
|
813
823
|
found, klasses, includes, extends =
|
|
@@ -823,11 +833,13 @@ or the PAGER environment variable.
|
|
|
823
833
|
##
|
|
824
834
|
# Outputs formatted RI data for method +name+
|
|
825
835
|
|
|
826
|
-
def display_method
|
|
836
|
+
def display_method(name)
|
|
827
837
|
out = RDoc::Markup::Document.new
|
|
828
838
|
|
|
829
839
|
add_method out, name
|
|
830
840
|
|
|
841
|
+
expand_rdoc_refs_at_the_bottom(out)
|
|
842
|
+
|
|
831
843
|
display out
|
|
832
844
|
end
|
|
833
845
|
|
|
@@ -837,7 +849,7 @@ or the PAGER environment variable.
|
|
|
837
849
|
# Returns true if +name+ was found, false if it was not an alternative could
|
|
838
850
|
# be guessed, raises an error if +name+ couldn't be guessed.
|
|
839
851
|
|
|
840
|
-
def display_name
|
|
852
|
+
def display_name(name)
|
|
841
853
|
if name =~ /\w:(\w|$)/ then
|
|
842
854
|
display_page name
|
|
843
855
|
return true
|
|
@@ -866,7 +878,7 @@ or the PAGER environment variable.
|
|
|
866
878
|
##
|
|
867
879
|
# Displays each name in +name+
|
|
868
880
|
|
|
869
|
-
def display_names
|
|
881
|
+
def display_names(names)
|
|
870
882
|
names.each do |name|
|
|
871
883
|
name = expand_name name
|
|
872
884
|
|
|
@@ -877,7 +889,7 @@ or the PAGER environment variable.
|
|
|
877
889
|
##
|
|
878
890
|
# Outputs formatted RI data for page +name+.
|
|
879
891
|
|
|
880
|
-
def display_page
|
|
892
|
+
def display_page(name)
|
|
881
893
|
store_name, page_name = name.split ':', 2
|
|
882
894
|
|
|
883
895
|
store = @stores.find { |s| s.source == store_name }
|
|
@@ -902,13 +914,13 @@ or the PAGER environment variable.
|
|
|
902
914
|
|
|
903
915
|
page = store.load_page page_name
|
|
904
916
|
|
|
905
|
-
display page.comment
|
|
917
|
+
display page.comment.parse
|
|
906
918
|
end
|
|
907
919
|
|
|
908
920
|
##
|
|
909
921
|
# Outputs a formatted RI page list for the pages in +store+.
|
|
910
922
|
|
|
911
|
-
def display_page_list
|
|
923
|
+
def display_page_list(store, pages = store.cache[:pages], search = nil)
|
|
912
924
|
out = RDoc::Markup::Document.new
|
|
913
925
|
|
|
914
926
|
title = if search then
|
|
@@ -952,13 +964,13 @@ or the PAGER environment variable.
|
|
|
952
964
|
# Expands abbreviated klass +klass+ into a fully-qualified class. "Zl::Da"
|
|
953
965
|
# will be expanded to Zlib::DataError.
|
|
954
966
|
|
|
955
|
-
def expand_class
|
|
967
|
+
def expand_class(klass)
|
|
956
968
|
class_names = classes.keys
|
|
957
969
|
ary = class_names.grep(Regexp.new("\\A#{klass.gsub(/(?=::|\z)/, '[^:]*')}\\z"))
|
|
958
970
|
if ary.length != 1 && ary.first != klass
|
|
959
971
|
if check_did_you_mean
|
|
960
|
-
|
|
961
|
-
raise NotFoundError.new(klass,
|
|
972
|
+
suggestion_proc = -> { DidYouMean::SpellChecker.new(dictionary: class_names).correct(klass) }
|
|
973
|
+
raise NotFoundError.new(klass, suggestion_proc)
|
|
962
974
|
else
|
|
963
975
|
raise NotFoundError, klass
|
|
964
976
|
end
|
|
@@ -970,7 +982,7 @@ or the PAGER environment variable.
|
|
|
970
982
|
# Expands the class portion of +name+ into a fully-qualified class. See
|
|
971
983
|
# #expand_class.
|
|
972
984
|
|
|
973
|
-
def expand_name
|
|
985
|
+
def expand_name(name)
|
|
974
986
|
klass, selector, method = parse_name name
|
|
975
987
|
|
|
976
988
|
return [selector, method].join if klass.empty?
|
|
@@ -986,7 +998,7 @@ or the PAGER environment variable.
|
|
|
986
998
|
##
|
|
987
999
|
# Filters the methods in +found+ trying to find a match for +name+.
|
|
988
1000
|
|
|
989
|
-
def filter_methods
|
|
1001
|
+
def filter_methods(found, name)
|
|
990
1002
|
regexp = name_regexp name
|
|
991
1003
|
|
|
992
1004
|
filtered = found.find_all do |store, methods|
|
|
@@ -1004,7 +1016,7 @@ or the PAGER environment variable.
|
|
|
1004
1016
|
# types of methods to look up (from #method_type), and the method name being
|
|
1005
1017
|
# searched for
|
|
1006
1018
|
|
|
1007
|
-
def find_methods
|
|
1019
|
+
def find_methods(name)
|
|
1008
1020
|
klass, selector, method = parse_name name
|
|
1009
1021
|
|
|
1010
1022
|
types = method_type selector
|
|
@@ -1044,43 +1056,13 @@ or the PAGER environment variable.
|
|
|
1044
1056
|
self
|
|
1045
1057
|
end
|
|
1046
1058
|
|
|
1047
|
-
##
|
|
1048
|
-
# Finds the given +pager+ for jruby. Returns an IO if +pager+ was found.
|
|
1049
|
-
#
|
|
1050
|
-
# Returns false if +pager+ does not exist.
|
|
1051
|
-
#
|
|
1052
|
-
# Returns nil if the jruby JVM doesn't support ProcessBuilder redirection
|
|
1053
|
-
# (1.6 and older).
|
|
1054
|
-
|
|
1055
|
-
def find_pager_jruby pager
|
|
1056
|
-
require 'java'
|
|
1057
|
-
require 'shellwords'
|
|
1058
|
-
|
|
1059
|
-
return nil unless java.lang.ProcessBuilder.constants.include? :Redirect
|
|
1060
|
-
|
|
1061
|
-
pager = Shellwords.split pager
|
|
1062
|
-
|
|
1063
|
-
pb = java.lang.ProcessBuilder.new(*pager)
|
|
1064
|
-
pb = pb.redirect_output java.lang.ProcessBuilder::Redirect::INHERIT
|
|
1065
|
-
|
|
1066
|
-
@jruby_pager_process = pb.start
|
|
1067
|
-
|
|
1068
|
-
input = @jruby_pager_process.output_stream
|
|
1069
|
-
|
|
1070
|
-
io = input.to_io
|
|
1071
|
-
io.sync = true
|
|
1072
|
-
io
|
|
1073
|
-
rescue java.io.IOException
|
|
1074
|
-
false
|
|
1075
|
-
end
|
|
1076
|
-
|
|
1077
1059
|
##
|
|
1078
1060
|
# Finds a store that matches +name+ which can be the name of a gem, "ruby",
|
|
1079
1061
|
# "home" or "site".
|
|
1080
1062
|
#
|
|
1081
1063
|
# See also RDoc::Store#source
|
|
1082
1064
|
|
|
1083
|
-
def find_store
|
|
1065
|
+
def find_store(name)
|
|
1084
1066
|
@stores.each do |store|
|
|
1085
1067
|
source = store.source
|
|
1086
1068
|
|
|
@@ -1113,6 +1095,10 @@ or the PAGER environment variable.
|
|
|
1113
1095
|
def interactive
|
|
1114
1096
|
puts "\nEnter the method name you want to look up."
|
|
1115
1097
|
|
|
1098
|
+
begin
|
|
1099
|
+
require 'readline'
|
|
1100
|
+
rescue LoadError
|
|
1101
|
+
end
|
|
1116
1102
|
if defined? Readline then
|
|
1117
1103
|
Readline.completion_proc = method :complete
|
|
1118
1104
|
puts "You can use tab to autocomplete."
|
|
@@ -1122,7 +1108,7 @@ or the PAGER environment variable.
|
|
|
1122
1108
|
|
|
1123
1109
|
loop do
|
|
1124
1110
|
name = if defined? Readline then
|
|
1125
|
-
Readline.readline ">> "
|
|
1111
|
+
Readline.readline ">> ", true
|
|
1126
1112
|
else
|
|
1127
1113
|
print ">> "
|
|
1128
1114
|
$stdin.gets
|
|
@@ -1141,22 +1127,11 @@ or the PAGER environment variable.
|
|
|
1141
1127
|
exit
|
|
1142
1128
|
end
|
|
1143
1129
|
|
|
1144
|
-
##
|
|
1145
|
-
# Is +file+ in ENV['PATH']?
|
|
1146
|
-
|
|
1147
|
-
def in_path? file
|
|
1148
|
-
return true if file =~ %r%\A/% and File.exist? file
|
|
1149
|
-
|
|
1150
|
-
ENV['PATH'].split(File::PATH_SEPARATOR).any? do |path|
|
|
1151
|
-
File.exist? File.join(path, file)
|
|
1152
|
-
end
|
|
1153
|
-
end
|
|
1154
|
-
|
|
1155
1130
|
##
|
|
1156
1131
|
# Lists classes known to ri starting with +names+. If +names+ is empty all
|
|
1157
1132
|
# known classes are shown.
|
|
1158
1133
|
|
|
1159
|
-
def list_known_classes
|
|
1134
|
+
def list_known_classes(names = [])
|
|
1160
1135
|
classes = []
|
|
1161
1136
|
|
|
1162
1137
|
stores.each do |store|
|
|
@@ -1188,7 +1163,7 @@ or the PAGER environment variable.
|
|
|
1188
1163
|
##
|
|
1189
1164
|
# Returns an Array of methods matching +name+
|
|
1190
1165
|
|
|
1191
|
-
def list_methods_matching
|
|
1166
|
+
def list_methods_matching(name)
|
|
1192
1167
|
found = []
|
|
1193
1168
|
|
|
1194
1169
|
find_methods name do |store, klass, ancestor, types, method|
|
|
@@ -1227,7 +1202,7 @@ or the PAGER environment variable.
|
|
|
1227
1202
|
# Loads RI data for method +name+ on +klass+ from +store+. +type+ and
|
|
1228
1203
|
# +cache+ indicate if it is a class or instance method.
|
|
1229
1204
|
|
|
1230
|
-
def load_method
|
|
1205
|
+
def load_method(store, cache, klass, type, name)
|
|
1231
1206
|
methods = store.public_send(cache)[klass]
|
|
1232
1207
|
|
|
1233
1208
|
return unless methods
|
|
@@ -1240,9 +1215,10 @@ or the PAGER environment variable.
|
|
|
1240
1215
|
|
|
1241
1216
|
store.load_method klass, "#{type}#{method}"
|
|
1242
1217
|
rescue RDoc::Store::MissingFileError => e
|
|
1243
|
-
comment = RDoc::Comment.new("missing documentation at #{e.file}")
|
|
1218
|
+
comment = RDoc::Comment.new("missing documentation at #{e.file}")
|
|
1219
|
+
comment.parse
|
|
1244
1220
|
|
|
1245
|
-
method = RDoc::AnyMethod.new
|
|
1221
|
+
method = RDoc::AnyMethod.new name
|
|
1246
1222
|
method.comment = comment
|
|
1247
1223
|
method
|
|
1248
1224
|
end
|
|
@@ -1250,7 +1226,7 @@ or the PAGER environment variable.
|
|
|
1250
1226
|
##
|
|
1251
1227
|
# Returns an Array of RI data for methods matching +name+
|
|
1252
1228
|
|
|
1253
|
-
def load_methods_matching
|
|
1229
|
+
def load_methods_matching(name)
|
|
1254
1230
|
found = []
|
|
1255
1231
|
|
|
1256
1232
|
find_methods name do |store, klass, ancestor, types, method|
|
|
@@ -1271,7 +1247,7 @@ or the PAGER environment variable.
|
|
|
1271
1247
|
##
|
|
1272
1248
|
# Returns a filtered list of methods matching +name+
|
|
1273
1249
|
|
|
1274
|
-
def lookup_method
|
|
1250
|
+
def lookup_method(name)
|
|
1275
1251
|
found = load_methods_matching name
|
|
1276
1252
|
|
|
1277
1253
|
if found.empty?
|
|
@@ -1283,8 +1259,8 @@ or the PAGER environment variable.
|
|
|
1283
1259
|
methods.push(*store.instance_methods[klass]) if [:instance, :both].include? types
|
|
1284
1260
|
end
|
|
1285
1261
|
methods = methods.uniq
|
|
1286
|
-
|
|
1287
|
-
raise NotFoundError.new(name,
|
|
1262
|
+
suggestion_proc = -> { DidYouMean::SpellChecker.new(dictionary: methods).correct(method_name) }
|
|
1263
|
+
raise NotFoundError.new(name, suggestion_proc)
|
|
1288
1264
|
else
|
|
1289
1265
|
raise NotFoundError, name
|
|
1290
1266
|
end
|
|
@@ -1296,9 +1272,7 @@ or the PAGER environment variable.
|
|
|
1296
1272
|
##
|
|
1297
1273
|
# Builds a RDoc::Markup::Document from +found+, +klasses+ and +includes+
|
|
1298
1274
|
|
|
1299
|
-
def method_document name, filtered
|
|
1300
|
-
out = RDoc::Markup::Document.new
|
|
1301
|
-
|
|
1275
|
+
def method_document(out, name, filtered)
|
|
1302
1276
|
out << RDoc::Markup::Heading.new(1, name)
|
|
1303
1277
|
out << RDoc::Markup::BlankLine.new
|
|
1304
1278
|
|
|
@@ -1314,7 +1288,7 @@ or the PAGER environment variable.
|
|
|
1314
1288
|
##
|
|
1315
1289
|
# Returns the type of method (:both, :instance, :class) for +selector+
|
|
1316
1290
|
|
|
1317
|
-
def method_type
|
|
1291
|
+
def method_type(selector)
|
|
1318
1292
|
case selector
|
|
1319
1293
|
when '.', nil then :both
|
|
1320
1294
|
when '#' then :instance
|
|
@@ -1326,7 +1300,7 @@ or the PAGER environment variable.
|
|
|
1326
1300
|
# Returns a regular expression for +name+ that will match an
|
|
1327
1301
|
# RDoc::AnyMethod's name.
|
|
1328
1302
|
|
|
1329
|
-
def name_regexp
|
|
1303
|
+
def name_regexp(name)
|
|
1330
1304
|
klass, type, name = parse_name name
|
|
1331
1305
|
|
|
1332
1306
|
case type
|
|
@@ -1346,7 +1320,6 @@ or the PAGER environment variable.
|
|
|
1346
1320
|
yield pager
|
|
1347
1321
|
ensure
|
|
1348
1322
|
pager.close
|
|
1349
|
-
@jruby_pager_process.wait_for if @jruby_pager_process
|
|
1350
1323
|
end
|
|
1351
1324
|
else
|
|
1352
1325
|
yield $stdout
|
|
@@ -1370,7 +1343,7 @@ or the PAGER environment variable.
|
|
|
1370
1343
|
# NOTE: Given Foo::Bar, Bar is considered a class even though it may be a
|
|
1371
1344
|
# method
|
|
1372
1345
|
|
|
1373
|
-
def parse_name
|
|
1346
|
+
def parse_name(name)
|
|
1374
1347
|
parts = name.split(/(::?|#|\.)/)
|
|
1375
1348
|
|
|
1376
1349
|
if parts.length == 1 then
|
|
@@ -1402,14 +1375,14 @@ or the PAGER environment variable.
|
|
|
1402
1375
|
# Renders the +klass+ from +store+ to +out+. If the klass has no
|
|
1403
1376
|
# documentable items the class is added to +also_in+ instead.
|
|
1404
1377
|
|
|
1405
|
-
def render_class
|
|
1406
|
-
|
|
1378
|
+
def render_class(out, store, klass, also_in) # :nodoc:
|
|
1379
|
+
document = klass.comment.parse
|
|
1407
1380
|
# TODO the store's cache should always return an empty Array
|
|
1408
1381
|
class_methods = store.class_methods[klass.full_name] || []
|
|
1409
1382
|
instance_methods = store.instance_methods[klass.full_name] || []
|
|
1410
1383
|
attributes = store.attributes[klass.full_name] || []
|
|
1411
1384
|
|
|
1412
|
-
if
|
|
1385
|
+
if document.empty? and
|
|
1413
1386
|
instance_methods.empty? and class_methods.empty? then
|
|
1414
1387
|
also_in << store
|
|
1415
1388
|
return
|
|
@@ -1417,7 +1390,7 @@ or the PAGER environment variable.
|
|
|
1417
1390
|
|
|
1418
1391
|
add_from out, store
|
|
1419
1392
|
|
|
1420
|
-
class_document_comment out,
|
|
1393
|
+
class_document_comment out, document
|
|
1421
1394
|
|
|
1422
1395
|
if class_methods or instance_methods or not klass.constants.empty? then
|
|
1423
1396
|
out << RDoc::Markup::Rule.new(1)
|
|
@@ -1432,7 +1405,7 @@ or the PAGER environment variable.
|
|
|
1432
1405
|
add_method_documentation out, klass if @show_all
|
|
1433
1406
|
end
|
|
1434
1407
|
|
|
1435
|
-
def render_method
|
|
1408
|
+
def render_method(out, store, method, name) # :nodoc:
|
|
1436
1409
|
out << RDoc::Markup::Paragraph.new("(from #{store.friendly_path})")
|
|
1437
1410
|
|
|
1438
1411
|
unless name =~ /^#{Regexp.escape method.parent_name}/ then
|
|
@@ -1442,6 +1415,8 @@ or the PAGER environment variable.
|
|
|
1442
1415
|
out << RDoc::Markup::Rule.new(1)
|
|
1443
1416
|
|
|
1444
1417
|
render_method_arguments out, method.arglists
|
|
1418
|
+
sig = method.type_signature_lines || store.rbs_signature_for(method)
|
|
1419
|
+
render_method_type_signature out, sig if sig
|
|
1445
1420
|
render_method_superclass out, method
|
|
1446
1421
|
if method.is_alias_for
|
|
1447
1422
|
al = method.is_alias_for
|
|
@@ -1452,7 +1427,7 @@ or the PAGER environment variable.
|
|
|
1452
1427
|
end
|
|
1453
1428
|
end
|
|
1454
1429
|
|
|
1455
|
-
def render_method_arguments
|
|
1430
|
+
def render_method_arguments(out, arglists) # :nodoc:
|
|
1456
1431
|
return unless arglists
|
|
1457
1432
|
|
|
1458
1433
|
arglists = arglists.chomp.split "\n"
|
|
@@ -1461,25 +1436,29 @@ or the PAGER environment variable.
|
|
|
1461
1436
|
out << RDoc::Markup::Rule.new(1)
|
|
1462
1437
|
end
|
|
1463
1438
|
|
|
1464
|
-
def render_method_comment
|
|
1439
|
+
def render_method_comment(out, method, alias_for = nil)# :nodoc:
|
|
1465
1440
|
if alias_for
|
|
1466
1441
|
unless method.comment.nil? or method.comment.empty?
|
|
1467
1442
|
out << RDoc::Markup::BlankLine.new
|
|
1468
|
-
out << method.comment
|
|
1443
|
+
out << method.comment.parse
|
|
1469
1444
|
end
|
|
1470
1445
|
out << RDoc::Markup::BlankLine.new
|
|
1471
1446
|
out << RDoc::Markup::Paragraph.new("(This method is an alias for #{alias_for.full_name}.)")
|
|
1472
1447
|
out << RDoc::Markup::BlankLine.new
|
|
1473
|
-
out << alias_for.comment
|
|
1448
|
+
out << alias_for.comment.parse
|
|
1474
1449
|
out << RDoc::Markup::BlankLine.new
|
|
1475
1450
|
else
|
|
1476
1451
|
out << RDoc::Markup::BlankLine.new
|
|
1477
|
-
out << method.comment
|
|
1452
|
+
out << method.comment.parse
|
|
1478
1453
|
out << RDoc::Markup::BlankLine.new
|
|
1479
1454
|
end
|
|
1480
1455
|
end
|
|
1481
1456
|
|
|
1482
|
-
def
|
|
1457
|
+
def render_method_type_signature(out, lines) # :nodoc:
|
|
1458
|
+
out << RDoc::Markup::Verbatim.new(*lines.map { |s| s + "\n" })
|
|
1459
|
+
end
|
|
1460
|
+
|
|
1461
|
+
def render_method_superclass(out, method) # :nodoc:
|
|
1483
1462
|
return unless
|
|
1484
1463
|
method.respond_to?(:superclass_method) and method.superclass_method
|
|
1485
1464
|
|
|
@@ -1514,27 +1493,14 @@ or the PAGER environment variable.
|
|
|
1514
1493
|
def setup_pager
|
|
1515
1494
|
return if @use_stdout
|
|
1516
1495
|
|
|
1517
|
-
jruby = RUBY_ENGINE == 'jruby'
|
|
1518
|
-
|
|
1519
1496
|
pagers = [ENV['RI_PAGER'], ENV['PAGER'], 'pager', 'less', 'more']
|
|
1520
1497
|
|
|
1498
|
+
require 'shellwords'
|
|
1521
1499
|
pagers.compact.uniq.each do |pager|
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
pager_cmd = pager.split(' ').first
|
|
1525
|
-
|
|
1526
|
-
next unless in_path? pager_cmd
|
|
1527
|
-
|
|
1528
|
-
if jruby then
|
|
1529
|
-
case io = find_pager_jruby(pager)
|
|
1530
|
-
when nil then break
|
|
1531
|
-
when false then next
|
|
1532
|
-
else io
|
|
1533
|
-
end
|
|
1534
|
-
else
|
|
1535
|
-
io = IO.popen(pager, 'w') rescue next
|
|
1536
|
-
end
|
|
1500
|
+
pager = Shellwords.split(pager)
|
|
1501
|
+
next if pager.empty?
|
|
1537
1502
|
|
|
1503
|
+
io = IO.popen(pager, 'w') rescue next
|
|
1538
1504
|
next if $? and $?.pid == io.pid and $?.exited? # pager didn't work
|
|
1539
1505
|
|
|
1540
1506
|
@paging = true
|
|
@@ -1561,7 +1527,7 @@ or the PAGER environment variable.
|
|
|
1561
1527
|
|
|
1562
1528
|
extra_doc_dirs = @stores.map {|s| s.type == :extra ? s.path : nil}.compact
|
|
1563
1529
|
|
|
1564
|
-
server.mount '/', RDoc::Servlet, nil, extra_doc_dirs
|
|
1530
|
+
server.mount '/', RDoc::RI::Servlet, nil, extra_doc_dirs
|
|
1565
1531
|
|
|
1566
1532
|
trap 'INT' do server.shutdown end
|
|
1567
1533
|
trap 'TERM' do server.shutdown end
|
|
@@ -1569,4 +1535,38 @@ or the PAGER environment variable.
|
|
|
1569
1535
|
server.start
|
|
1570
1536
|
end
|
|
1571
1537
|
|
|
1538
|
+
RDOC_REFS_REGEXP = /\[rdoc-ref:([\w.]+)(@.*)?\]/
|
|
1539
|
+
|
|
1540
|
+
def expand_rdoc_refs_at_the_bottom(out)
|
|
1541
|
+
return unless @expand_refs
|
|
1542
|
+
|
|
1543
|
+
extracted_rdoc_refs = []
|
|
1544
|
+
|
|
1545
|
+
out.each do |part|
|
|
1546
|
+
content = if part.respond_to?(:text)
|
|
1547
|
+
part.text
|
|
1548
|
+
else
|
|
1549
|
+
next
|
|
1550
|
+
end
|
|
1551
|
+
|
|
1552
|
+
rdoc_refs = content.scan(RDOC_REFS_REGEXP).uniq.map do |file_name, _anchor|
|
|
1553
|
+
file_name
|
|
1554
|
+
end
|
|
1555
|
+
|
|
1556
|
+
extracted_rdoc_refs.concat(rdoc_refs)
|
|
1557
|
+
end
|
|
1558
|
+
|
|
1559
|
+
found_pages = extracted_rdoc_refs.map do |ref|
|
|
1560
|
+
begin
|
|
1561
|
+
@stores.first.load_page(ref)
|
|
1562
|
+
rescue RDoc::Store::MissingFileError
|
|
1563
|
+
end
|
|
1564
|
+
end.compact
|
|
1565
|
+
|
|
1566
|
+
found_pages.each do |page|
|
|
1567
|
+
out << RDoc::Markup::Heading.new(4, "Expanded from #{page.full_name}")
|
|
1568
|
+
out << RDoc::Markup::BlankLine.new
|
|
1569
|
+
out << page.comment.parse
|
|
1570
|
+
end
|
|
1571
|
+
end
|
|
1572
1572
|
end
|