rdoc 6.6.3.1 → 6.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CONTRIBUTING.rdoc +1 -1
- data/ExampleMarkdown.md +2 -0
- data/ExampleRDoc.rdoc +2 -0
- data/History.rdoc +64 -62
- data/LICENSE.rdoc +2 -0
- data/README.rdoc +13 -0
- data/RI.md +842 -0
- data/TODO.rdoc +8 -7
- data/lib/rdoc/{alias.rb → code_object/alias.rb} +1 -1
- data/lib/rdoc/{class_module.rb → code_object/class_module.rb} +54 -0
- data/lib/rdoc/{context.rb → code_object/context.rb} +1 -1
- data/lib/rdoc/{method_attr.rb → code_object/method_attr.rb} +3 -3
- data/lib/rdoc/{top_level.rb → code_object/top_level.rb} +4 -4
- data/lib/rdoc/code_object.rb +6 -0
- data/lib/rdoc/generator/darkfish.rb +45 -3
- data/lib/rdoc/generator/pot/message_extractor.rb +1 -1
- data/lib/rdoc/generator/pot/po_entry.rb +1 -1
- data/lib/rdoc/generator/template/darkfish/_head.rhtml +23 -0
- data/lib/rdoc/generator/template/darkfish/_sidebar_methods.rhtml +20 -11
- data/lib/rdoc/generator/template/darkfish/_sidebar_parent.rhtml +3 -8
- data/lib/rdoc/generator/template/darkfish/class.rhtml +69 -43
- data/lib/rdoc/generator/template/darkfish/css/rdoc.css +367 -392
- data/lib/rdoc/generator/template/darkfish/index.rhtml +7 -6
- data/lib/rdoc/generator/template/darkfish/js/darkfish.js +18 -1
- data/lib/rdoc/generator/template/darkfish/page.rhtml +5 -5
- data/lib/rdoc/generator/template/darkfish/servlet_not_found.rhtml +10 -8
- data/lib/rdoc/generator/template/darkfish/servlet_root.rhtml +5 -2
- data/lib/rdoc/generator/template/darkfish/table_of_contents.rhtml +11 -0
- data/lib/rdoc/markdown.kpeg +3 -3
- data/lib/rdoc/markdown.rb +25 -15
- data/lib/rdoc/markup/attribute_manager.rb +2 -2
- data/lib/rdoc/markup/pre_process.rb +9 -6
- data/lib/rdoc/markup/to_bs.rb +26 -1
- data/lib/rdoc/markup/to_html_crossref.rb +12 -13
- data/lib/rdoc/markup/to_markdown.rb +4 -4
- data/lib/rdoc/markup/to_rdoc.rb +15 -7
- data/lib/rdoc/markup.rb +18 -13
- data/lib/rdoc/options.rb +23 -5
- data/lib/rdoc/parser/c.rb +19 -9
- data/lib/rdoc/parser/changelog.rb +2 -2
- data/lib/rdoc/parser/ripper_state_lex.rb +7 -305
- data/lib/rdoc/parser/ruby.rb +26 -8
- data/lib/rdoc/parser.rb +6 -3
- data/lib/rdoc/rd/block_parser.rb +3 -7
- data/lib/rdoc/rd/inline_parser.rb +3 -7
- data/lib/rdoc/rdoc.rb +3 -2
- data/lib/rdoc/ri/driver.rb +11 -7
- data/lib/rdoc/task.rb +2 -3
- data/lib/rdoc/tom_doc.rb +1 -7
- data/lib/rdoc/version.rb +1 -1
- data/lib/rdoc.rb +23 -23
- metadata +27 -24
- data/RI.rdoc +0 -57
- /data/lib/rdoc/{anon_class.rb → code_object/anon_class.rb} +0 -0
- /data/lib/rdoc/{any_method.rb → code_object/any_method.rb} +0 -0
- /data/lib/rdoc/{attr.rb → code_object/attr.rb} +0 -0
- /data/lib/rdoc/{constant.rb → code_object/constant.rb} +0 -0
- /data/lib/rdoc/{context → code_object/context}/section.rb +0 -0
- /data/lib/rdoc/{extend.rb → code_object/extend.rb} +0 -0
- /data/lib/rdoc/{ghost_method.rb → code_object/ghost_method.rb} +0 -0
- /data/lib/rdoc/{include.rb → code_object/include.rb} +0 -0
- /data/lib/rdoc/{meta_method.rb → code_object/meta_method.rb} +0 -0
- /data/lib/rdoc/{mixin.rb → code_object/mixin.rb} +0 -0
- /data/lib/rdoc/{normal_class.rb → code_object/normal_class.rb} +0 -0
- /data/lib/rdoc/{normal_module.rb → code_object/normal_module.rb} +0 -0
- /data/lib/rdoc/{require.rb → code_object/require.rb} +0 -0
- /data/lib/rdoc/{single_class.rb → code_object/single_class.rb} +0 -0
data/RI.md
ADDED
@@ -0,0 +1,842 @@
|
|
1
|
+
# `ri`: Ruby Information
|
2
|
+
|
3
|
+
`ri` (<b>r</b>uby <b>i</b>nformation) is the Ruby command-line utility
|
4
|
+
that gives fast and easy on-line access to Ruby documentation.
|
5
|
+
|
6
|
+
`ri` can show documentation for Ruby itself and for its installed gems:
|
7
|
+
|
8
|
+
- A **class** or **module**:
|
9
|
+
text associated with the class or module definition
|
10
|
+
in a source file (`.rb` or `.c`).
|
11
|
+
- One or more **methods**:
|
12
|
+
text associated with method definitions
|
13
|
+
in source files (`.rb` and `.c`).
|
14
|
+
- A **page**:
|
15
|
+
text from a stand-alone documentation file
|
16
|
+
(`.rdoc` or `.md`, or sometimes other).
|
17
|
+
|
18
|
+
Examples (output omitted):
|
19
|
+
|
20
|
+
```sh
|
21
|
+
$ ri Hash # Document for class Hash.
|
22
|
+
$ ri Array#sort # Document for instance method sort in class Array.
|
23
|
+
$ ri read # Documents for methods ::read and #read in all classes and modules.
|
24
|
+
$ ri ruby:dig_methods # Document for page dig_methods.
|
25
|
+
```
|
26
|
+
|
27
|
+
`ri` can also show lists of:
|
28
|
+
|
29
|
+
- **classes** and **modules**:
|
30
|
+
full or partial list.
|
31
|
+
- **pages**:
|
32
|
+
for Ruby or for an installed gem.
|
33
|
+
|
34
|
+
Examples (output omitted):
|
35
|
+
|
36
|
+
```sh
|
37
|
+
$ ri --list # List of classes and modules.
|
38
|
+
$ ri ruby: # List of Ruby pages.
|
39
|
+
```
|
40
|
+
|
41
|
+
## Why `ri`?
|
42
|
+
|
43
|
+
Using `ri` may have advantages over using
|
44
|
+
the [Ruby online documentation](https://docs.ruby-lang.org/en/master):
|
45
|
+
|
46
|
+
- The `ri` documentation is always available, even when you do not have internet access
|
47
|
+
(think: airplane mode).
|
48
|
+
- If you are working in a terminal window, typing `ri _whatever_` (or just `ri`)
|
49
|
+
may be faster than navigating to a browser window and searching for documentation.
|
50
|
+
- If you are working in an
|
51
|
+
[irb \(interactive Ruby\)](https://docs.ruby-lang.org/en/master/IRB.html)
|
52
|
+
session, you _already_ have immediate access to `ri`:
|
53
|
+
just type `'show_doc'`.
|
54
|
+
|
55
|
+
## Modes
|
56
|
+
|
57
|
+
There are two `ri` modes:
|
58
|
+
|
59
|
+
- <i>Static mode</i>:
|
60
|
+
In general, `ri` responds in its static mode
|
61
|
+
if a _name_ is given;
|
62
|
+
it shows results and exits (as in the examples above).
|
63
|
+
See [Static Mode][1].
|
64
|
+
- <i>Interactive mode</i>:
|
65
|
+
In general, `ri` enters its interactive mode
|
66
|
+
if no _name_ is given;
|
67
|
+
in interactive mode, `ri` shows results and waits for another command:
|
68
|
+
|
69
|
+
```sh
|
70
|
+
$ ri
|
71
|
+
Enter the method name you want to look up.
|
72
|
+
You can use tab to autocomplete.
|
73
|
+
Enter a blank line to exit.
|
74
|
+
>>
|
75
|
+
```
|
76
|
+
|
77
|
+
See [Interactive Mode][2].
|
78
|
+
|
79
|
+
## Names
|
80
|
+
|
81
|
+
In both modes, static and interactive,
|
82
|
+
`ri` responds to an input _name_ that specifies what is to be displayed:
|
83
|
+
a document, multiple documents, or other information:
|
84
|
+
|
85
|
+
- Static mode (in the shell): type `'ri _name_'`;
|
86
|
+
examples (output omitted):
|
87
|
+
|
88
|
+
```sh
|
89
|
+
$ ri File
|
90
|
+
$ ri IO#readlines
|
91
|
+
$ ri ruby:
|
92
|
+
```
|
93
|
+
|
94
|
+
- Interactive mode (already in `ri`): just type the _name_;
|
95
|
+
examples (output omitted):
|
96
|
+
|
97
|
+
```sh
|
98
|
+
$ ri
|
99
|
+
Enter the method name you want to look up.
|
100
|
+
You can use tab to autocomplete.
|
101
|
+
Enter a blank line to exit.
|
102
|
+
>> File
|
103
|
+
>> IO#readlines
|
104
|
+
>> ruby:
|
105
|
+
```
|
106
|
+
|
107
|
+
### Names for Class and Module Documents
|
108
|
+
|
109
|
+
These example `ri` commands cite names for class and module documents
|
110
|
+
(see [details and examples][3]):
|
111
|
+
|
112
|
+
| Command | Shows |
|
113
|
+
|------------------------------|------------------------------------------------------------|
|
114
|
+
| ri File | Document for Ruby class File. |
|
115
|
+
| ri File::Stat | Document for Ruby nested class File::Stat. |
|
116
|
+
| ri Enumerable | Document for Ruby module Enumerable. |
|
117
|
+
| ri Arr | Document for Ruby class Array (unique initial characters). |
|
118
|
+
| ri Nokogiri::HTML4::Document | Document for gem class Nokogiri::HTML4::Document. |
|
119
|
+
| ri Nokogiri | Document for gem module Nokogiri. |
|
120
|
+
<br>
|
121
|
+
|
122
|
+
If [option \\--all][4]
|
123
|
+
is in effect, documents for the methods in the named class or module
|
124
|
+
are included in the display.
|
125
|
+
|
126
|
+
### Names for Method Documents
|
127
|
+
|
128
|
+
These example `ri` commands cite names for method documents
|
129
|
+
(see [details and examples][5]):
|
130
|
+
|
131
|
+
| Command | Shows |
|
132
|
+
|--------------------------------------|----------------------------------------------------------------------------------|
|
133
|
+
| ri IO::readlines | Document for Ruby class method IO::readlines. |
|
134
|
+
| ri IO#readlines | Document for Ruby instance method IO::readlines. |
|
135
|
+
| ri IO.readlines | Documents for Ruby instance method IO::readlines and class method IO::readlines. |
|
136
|
+
| ri ::readlines | Documents for all class methods ::readlines. |
|
137
|
+
| ri #readlines | Documents for all instance methods #readlines. |
|
138
|
+
| ri .readlines, ri readlines | Documents for class methods ::readlines and instance methods #readlines. |
|
139
|
+
| ri Nokogiri::HTML4::Document::parse | Document for gem class method Nokogiri::HTML4::Document::parse. |
|
140
|
+
| ri Nokogiri::HTML4::Document#fragment | Document for gem instance method Nokogiri::HTML4::Document#fragment. |
|
141
|
+
<br>
|
142
|
+
|
143
|
+
### Names for Page Documents
|
144
|
+
|
145
|
+
These example `ri` commands cite names for page documents
|
146
|
+
(see [details and examples][6]):
|
147
|
+
|
148
|
+
| Command | Shows |
|
149
|
+
|--------------------------------|--------------------------------------------------|
|
150
|
+
| ri ruby:syntax/assignment.rdoc | Document for Ruby page assignment. |
|
151
|
+
| ri ruby:syntax/assignment | Same document, if no other syntax/assignment.*. |
|
152
|
+
| ri ruby:assignment | Same document, if no other */assignment.*. |
|
153
|
+
| ri nokogiri:README.md | Document for page README.md. |
|
154
|
+
<br>
|
155
|
+
|
156
|
+
### Names for Lists
|
157
|
+
|
158
|
+
These example `ri` commands cite names for lists
|
159
|
+
(see [details and examples][7]):
|
160
|
+
|
161
|
+
| Command | Shows |
|
162
|
+
|---------------|-------------------------|
|
163
|
+
| ri ruby: | List of Ruby pages. |
|
164
|
+
| ri nokogiri: | List of Nokogiri pages. |
|
165
|
+
<br>
|
166
|
+
|
167
|
+
There are more lists available;
|
168
|
+
see [option \\--list][8].
|
169
|
+
|
170
|
+
## Pro Tips
|
171
|
+
|
172
|
+
### `ri` at the Ready
|
173
|
+
|
174
|
+
If you are a frequent `ri` user,
|
175
|
+
you can save time by keeping open a dedicated command window
|
176
|
+
with either of:
|
177
|
+
|
178
|
+
- A running [interactive ri][2] session.
|
179
|
+
- A running [irb session][9];
|
180
|
+
type `'show_doc'` to enter `ri`, newline to exit.
|
181
|
+
|
182
|
+
When you switch to that window, `ri` is ready to respond quickly,
|
183
|
+
without the performance overhead of re-reading `ri` sources.
|
184
|
+
|
185
|
+
### Output Filters
|
186
|
+
|
187
|
+
The `pager` value actually need not be simply the path to an executable;
|
188
|
+
it's actually a full-fledged command line,
|
189
|
+
and so may include not only the executable path,
|
190
|
+
but also whatever options and arguments that executable accepts.
|
191
|
+
|
192
|
+
You can, for example, set the pager value to `'grep . | less'`,
|
193
|
+
which will exclude blank lines (thus saving screen space)
|
194
|
+
before piping the result to `less`;
|
195
|
+
example (output omitted):
|
196
|
+
|
197
|
+
```sh
|
198
|
+
$ RI_PAGER="grep . | less" ri Array
|
199
|
+
```
|
200
|
+
|
201
|
+
See the documentation for your chosen pager programs
|
202
|
+
(e.g, type `'grep --help'`, `'less --help'`).
|
203
|
+
|
204
|
+
### Links in `ri` Output
|
205
|
+
|
206
|
+
#### Implicit Link
|
207
|
+
|
208
|
+
When you see:
|
209
|
+
|
210
|
+
- `'IO::readlines'`, `'IO#readlines'`, `'IO.readlines'`:
|
211
|
+
use that same text as the _name_ in an `ri` command.
|
212
|
+
|
213
|
+
Examples (output omitted):
|
214
|
+
|
215
|
+
```sh
|
216
|
+
$ ri IO::readlines
|
217
|
+
$ ri IO#readlines
|
218
|
+
$ ri IO.readlines
|
219
|
+
```
|
220
|
+
|
221
|
+
- `'#read'`, `'::read'`, `'.read'`:
|
222
|
+
you're likely already in the `ri` document for a class or module,
|
223
|
+
or for a method in a class or module;
|
224
|
+
use that same text with the name of the class or module (such as `'File'`)
|
225
|
+
as the _name_ in an `ri` command.
|
226
|
+
|
227
|
+
Examples (output omitted):
|
228
|
+
|
229
|
+
```sh
|
230
|
+
$ ri File::read
|
231
|
+
$ ri File#read
|
232
|
+
$ ri File.read
|
233
|
+
```
|
234
|
+
|
235
|
+
#### Explicit Link
|
236
|
+
|
237
|
+
When you see:
|
238
|
+
|
239
|
+
- `'{Dig Methods}[rdoc-ref:doc/dig_methods.rdoc]'`:
|
240
|
+
use the trailing part of the `'[rdoc-ref:doc/'` in an `ri` command
|
241
|
+
for a Ruby document.
|
242
|
+
|
243
|
+
Example (output omitted):
|
244
|
+
|
245
|
+
```sh
|
246
|
+
$ ri ruby:dig_methods.rdoc
|
247
|
+
```
|
248
|
+
|
249
|
+
- `'{Table (information)}[https://en.wikipedia.org/wiki/Table_(information)]'`:
|
250
|
+
go to the given URL in your browser.
|
251
|
+
|
252
|
+
## About the Examples
|
253
|
+
|
254
|
+
- `ri` output can be large;
|
255
|
+
to save space, an example may pipe it to one of these:
|
256
|
+
|
257
|
+
- [head](https://www.man7.org/linux/man-pages/man1/head.1.html): leading lines only.
|
258
|
+
- [tail](https://www.man7.org/linux/man-pages/man1/tail.1.html): trailing lines only.
|
259
|
+
- [wc -l](https://www.man7.org/linux/man-pages/man1/wc.1.html): line count only.
|
260
|
+
- [grep](https://www.man7.org/linux/man-pages/man1/grep.1.html): selected lines only.
|
261
|
+
|
262
|
+
- An example that involves a gem assumes that gems `nokogiri` and `minitest` are installed.
|
263
|
+
|
264
|
+
## `ri` Documents
|
265
|
+
|
266
|
+
This section outlines what you can expect to find
|
267
|
+
in the `ri` document for a class, module, method, or page.
|
268
|
+
|
269
|
+
See also:
|
270
|
+
|
271
|
+
- [Pager][10].
|
272
|
+
- [Links in ri Output][11].
|
273
|
+
|
274
|
+
### Class and Module Documents
|
275
|
+
|
276
|
+
The document for a class or module shows:
|
277
|
+
|
278
|
+
- The class or module name, along with its parent class if any.
|
279
|
+
- Where it's defined (Ruby core or gem).
|
280
|
+
- When each exists:
|
281
|
+
|
282
|
+
- The names of its included modules.
|
283
|
+
- The text of its embedded documentation.
|
284
|
+
- Its constants.
|
285
|
+
- Its class methods.
|
286
|
+
- Its instance methods.
|
287
|
+
|
288
|
+
Examples:
|
289
|
+
|
290
|
+
- Ruby class `Array`:
|
291
|
+
|
292
|
+
```sh
|
293
|
+
$ ri Array | head
|
294
|
+
= Array < Object
|
295
|
+
|
296
|
+
------------------------------------------------------------------------
|
297
|
+
= Includes:
|
298
|
+
Enumerable (from ruby core)
|
299
|
+
|
300
|
+
(from ruby core)
|
301
|
+
------------------------------------------------------------------------
|
302
|
+
An Array is an ordered, integer-indexed collection of objects, called
|
303
|
+
elements. Any object may be an Array element.
|
304
|
+
```
|
305
|
+
|
306
|
+
- Gem module `Nokogiri`:
|
307
|
+
|
308
|
+
```sh
|
309
|
+
$ ri Nokogiri | head
|
310
|
+
= Nokogiri
|
311
|
+
|
312
|
+
(from gem nokogiri-1.16.2-x86_64-linux)
|
313
|
+
------------------------------------------------------------------------
|
314
|
+
|
315
|
+
Nokogiri parses and searches XML/HTML very quickly, and also has
|
316
|
+
correctly implemented CSS3 selector support as well as XPath 1.0
|
317
|
+
support.
|
318
|
+
|
319
|
+
Parsing a document returns either a Nokogiri::XML::Document, or a
|
320
|
+
```
|
321
|
+
|
322
|
+
The document typically includes certain headings,
|
323
|
+
which may be useful for searching:
|
324
|
+
|
325
|
+
```sh
|
326
|
+
$ ri IO | grep "^= "
|
327
|
+
= IO < Object
|
328
|
+
= Includes:
|
329
|
+
= Constants:
|
330
|
+
= Class methods:
|
331
|
+
= Instance methods:
|
332
|
+
```
|
333
|
+
|
334
|
+
### Method Documents
|
335
|
+
|
336
|
+
The document for a method includes:
|
337
|
+
|
338
|
+
- The source of the method: `'(from ruby core)'` or `'(from gem _gem_)'`.
|
339
|
+
- The calling sequence(s) for the method.
|
340
|
+
- The text of its embedded documentation (if it exists).
|
341
|
+
|
342
|
+
Examples:
|
343
|
+
|
344
|
+
```sh
|
345
|
+
$ ri IO#read | head
|
346
|
+
= IO#read
|
347
|
+
|
348
|
+
(from ruby core)
|
349
|
+
------------------------------------------------------------------------
|
350
|
+
ios.read([length [, outbuf]]) -> string, outbuf, or nil
|
351
|
+
|
352
|
+
------------------------------------------------------------------------
|
353
|
+
|
354
|
+
Reads length bytes from the I/O stream.
|
355
|
+
```
|
356
|
+
|
357
|
+
```sh
|
358
|
+
$ ri Nokogiri::parse | head
|
359
|
+
= Nokogiri::parse
|
360
|
+
|
361
|
+
(from gem nokogiri-1.16.2-x86_64-linux)
|
362
|
+
------------------------------------------------------------------------
|
363
|
+
parse(string, url = nil, encoding = nil, options = nil) { |doc| ... }
|
364
|
+
|
365
|
+
------------------------------------------------------------------------
|
366
|
+
|
367
|
+
Parse an HTML or XML document. string contains the document.
|
368
|
+
```
|
369
|
+
|
370
|
+
The output for a _name_ that cites methods includes the document
|
371
|
+
for each found implementation;
|
372
|
+
the number of such implementations depends on the _name_:
|
373
|
+
|
374
|
+
- Within a class:
|
375
|
+
|
376
|
+
Each of these commands shows documents
|
377
|
+
for methods in Ruby class `IO` (output omitted):
|
378
|
+
|
379
|
+
```sh
|
380
|
+
$ ri IO::readlines # Class method ::readlines.
|
381
|
+
$ ri IO#readlines # Instance method #readlines.
|
382
|
+
$ ri IO.readlines # Both of above.
|
383
|
+
```
|
384
|
+
|
385
|
+
- In all classes:
|
386
|
+
|
387
|
+
Each of these commands shows documents
|
388
|
+
for methods in all classes (output omitted):
|
389
|
+
|
390
|
+
```sh
|
391
|
+
$ ri ::readlines # Class method ::readlines.
|
392
|
+
$ ri \#readlines # Instance method #readlines.
|
393
|
+
$ ri .readlines # Both of above.
|
394
|
+
```
|
395
|
+
|
396
|
+
For these all-classes commands,
|
397
|
+
the output is organized into sections,
|
398
|
+
one for each found method (output filtered to show sections):
|
399
|
+
|
400
|
+
```sh
|
401
|
+
$ ri ::readlines | grep "= Implementation"
|
402
|
+
=== Implementation from CSV
|
403
|
+
=== Implementation from IO
|
404
|
+
```
|
405
|
+
|
406
|
+
```sh
|
407
|
+
$ ri \#readlines | grep "= Implementation"
|
408
|
+
=== Implementation from ARGF
|
409
|
+
=== Implementation from CSV
|
410
|
+
=== Implementation from IO
|
411
|
+
=== Implementation from Kernel
|
412
|
+
=== Implementation from Buffering
|
413
|
+
=== Implementation from Pathname
|
414
|
+
=== Implementation from StringIO
|
415
|
+
=== Implementation from GzipReader
|
416
|
+
```
|
417
|
+
|
418
|
+
```sh
|
419
|
+
$ ri .readlines | grep "= Implementation"
|
420
|
+
=== Implementation from ARGF
|
421
|
+
=== Implementation from CSV
|
422
|
+
=== Implementation from CSV
|
423
|
+
=== Implementation from IO
|
424
|
+
=== Implementation from IO
|
425
|
+
=== Implementation from Kernel
|
426
|
+
=== Implementation from Buffering
|
427
|
+
=== Implementation from Pathname
|
428
|
+
=== Implementation from StringIO
|
429
|
+
=== Implementation from GzipReader
|
430
|
+
```
|
431
|
+
|
432
|
+
### Page Documents
|
433
|
+
|
434
|
+
The document for a Ruby page is the text from the `.rdoc` or `.md` source
|
435
|
+
for that page:
|
436
|
+
|
437
|
+
```sh
|
438
|
+
$ ri ruby:dig_methods | head
|
439
|
+
= Dig Methods
|
440
|
+
|
441
|
+
Ruby's dig methods are useful for accessing nested data structures.
|
442
|
+
|
443
|
+
Consider this data:
|
444
|
+
item = {
|
445
|
+
id: "0001",
|
446
|
+
type: "donut",
|
447
|
+
name: "Cake",
|
448
|
+
ppu: 0.55,
|
449
|
+
```
|
450
|
+
|
451
|
+
The document for a gem page is whatever the gem has generated
|
452
|
+
for the page:
|
453
|
+
|
454
|
+
```sh
|
455
|
+
$ ri minitest:README | head
|
456
|
+
= minitest/{test,spec,mock,benchmark}
|
457
|
+
|
458
|
+
home:
|
459
|
+
https://github.com/minitest/minitest
|
460
|
+
|
461
|
+
bugs:
|
462
|
+
https://github.com/minitest/minitest/issues
|
463
|
+
|
464
|
+
rdoc:
|
465
|
+
https://docs.seattlerb.org/minitest
|
466
|
+
```
|
467
|
+
|
468
|
+
## `ri` Lists
|
469
|
+
|
470
|
+
The list of Ruby pages is available via _name_ `'ruby:'`:
|
471
|
+
|
472
|
+
```sh
|
473
|
+
$ ri ruby: | head
|
474
|
+
= Pages in ruby core
|
475
|
+
|
476
|
+
CONTRIBUTING.md
|
477
|
+
COPYING
|
478
|
+
COPYING.ja
|
479
|
+
LEGAL
|
480
|
+
NEWS-1.8.7
|
481
|
+
NEWS-1.9.1
|
482
|
+
NEWS-1.9.2
|
483
|
+
NEWS-1.9.3
|
484
|
+
```
|
485
|
+
|
486
|
+
```sh
|
487
|
+
$ ri ruby: | tail
|
488
|
+
syntax/control_expressions.rdoc
|
489
|
+
syntax/exceptions.rdoc
|
490
|
+
syntax/literals.rdoc
|
491
|
+
syntax/methods.rdoc
|
492
|
+
syntax/miscellaneous.rdoc
|
493
|
+
syntax/modules_and_classes.rdoc
|
494
|
+
syntax/pattern_matching.rdoc
|
495
|
+
syntax/precedence.rdoc
|
496
|
+
syntax/refinements.rdoc
|
497
|
+
win32/README.win32
|
498
|
+
```
|
499
|
+
|
500
|
+
The list of gem pages is available via _name_ `'_gem_name_'`:
|
501
|
+
|
502
|
+
```sh
|
503
|
+
$ ri nokogiri: | head
|
504
|
+
= Pages in gem nokogiri-1.16.2-x86_64-linux
|
505
|
+
|
506
|
+
README.md
|
507
|
+
lib/nokogiri/css/tokenizer.rex
|
508
|
+
```
|
509
|
+
|
510
|
+
See also:
|
511
|
+
|
512
|
+
- [Option \\--list][8]:
|
513
|
+
lists classes and modules.
|
514
|
+
- [Option \\--list-doc-dirs][12]:
|
515
|
+
lists `ri` source directories.
|
516
|
+
|
517
|
+
## `ri` Information
|
518
|
+
|
519
|
+
With certain options,
|
520
|
+
an `ri` command may display information other than documents or lists:
|
521
|
+
|
522
|
+
- [Option \\--help or -h][13]:
|
523
|
+
Shows `ri` help text.
|
524
|
+
- [option \\--version or -v][14]:
|
525
|
+
Shows `ri` version.
|
526
|
+
- [Option \\--dump=FILEPATH][15]:
|
527
|
+
Shows dump of `ri` cache file at the given filepath.
|
528
|
+
|
529
|
+
## Static Mode
|
530
|
+
|
531
|
+
In static mode, `ri` shows a response and exits.
|
532
|
+
|
533
|
+
In general, `ri` responds in static mode
|
534
|
+
if the command gives a _name_:
|
535
|
+
|
536
|
+
```sh
|
537
|
+
$ ri Array | head
|
538
|
+
= Array < Object
|
539
|
+
|
540
|
+
------------------------------------------------------------------------
|
541
|
+
= Includes:
|
542
|
+
Enumerable (from ruby core)
|
543
|
+
|
544
|
+
(from ruby core)
|
545
|
+
------------------------------------------------------------------------
|
546
|
+
An Array is an ordered, integer-indexed collection of objects, called
|
547
|
+
elements. Any object may be an Array element.
|
548
|
+
```
|
549
|
+
|
550
|
+
`ri` also responds in static mode when certain options are given,
|
551
|
+
even when no _name_ is given;
|
552
|
+
see [ri Information][16].
|
553
|
+
|
554
|
+
## Interactive Mode
|
555
|
+
|
556
|
+
In general, `ri` responds to a command in interactive mode
|
557
|
+
if the command has no arguments:
|
558
|
+
|
559
|
+
```sh
|
560
|
+
$ ri
|
561
|
+
Enter the method name you want to look up.
|
562
|
+
You can use tab to autocomplete.
|
563
|
+
Enter a blank line to exit.
|
564
|
+
>>
|
565
|
+
|
566
|
+
```
|
567
|
+
|
568
|
+
A command in interactive mode are similar to one in static mode,
|
569
|
+
except that it:
|
570
|
+
|
571
|
+
- Omits command word `ri`; you just type the _name_.
|
572
|
+
- Omits options; in interactive mode the only options in effect
|
573
|
+
are those taken from environment variable `RI`.
|
574
|
+
See [Options][17].
|
575
|
+
- Supports tab auto-completion for the name of a class, module, or method;
|
576
|
+
when, for example, you type `"Arr\t"` (here `"\t` represents the tab character),
|
577
|
+
`ri` "completes" the text as `'Array '`.
|
578
|
+
|
579
|
+
See also [ri at the Ready][18].
|
580
|
+
|
581
|
+
## Pager
|
582
|
+
|
583
|
+
Because `ri` output is often large,
|
584
|
+
`ri` by default pipes it to a _pager_,
|
585
|
+
which is the program whose name is the first-found among:
|
586
|
+
|
587
|
+
- The value of `ENV['RI_PAGER']`.
|
588
|
+
- The value of `ENV['PAGER']`.
|
589
|
+
- `'pager'`.
|
590
|
+
- `'less'`.
|
591
|
+
- `'more'`.
|
592
|
+
|
593
|
+
If none is found, the output goes directly to `$stdout`, with no pager.
|
594
|
+
|
595
|
+
If you set environment variable `RI_PAGER` or `PAGER`,
|
596
|
+
its value should be the name of an executable program
|
597
|
+
that will accept the `ri` output (such as `'pager'`, `'less'`, or `'more'`).
|
598
|
+
|
599
|
+
See also [Output Filters][19].
|
600
|
+
|
601
|
+
## Options
|
602
|
+
|
603
|
+
Options may be given on the `ri` command line;
|
604
|
+
those should be whitespace-separated, and must precede the given _name_, if any.
|
605
|
+
|
606
|
+
Options may also be specified in environment variable `RI`;
|
607
|
+
those should also be whitespace-separated.
|
608
|
+
|
609
|
+
An option specified in environment variable `RI`
|
610
|
+
may be overridden by an option on the `ri` command line:
|
611
|
+
|
612
|
+
```sh
|
613
|
+
$ RI="--all" ri Array | wc -l
|
614
|
+
4224
|
615
|
+
$ RI="--all" ri --no-all Array | wc -l
|
616
|
+
390
|
617
|
+
```
|
618
|
+
|
619
|
+
### Source Directories Options
|
620
|
+
|
621
|
+
#### Options `--doc-dir=DIRPATH`, `-d DIRPATH`
|
622
|
+
|
623
|
+
Option `--doc-dir=DIRPATH` (aliased as `-d`) adds the given directory path
|
624
|
+
to the beginning of the array of `ri` source directory paths:
|
625
|
+
|
626
|
+
```sh
|
627
|
+
$ ri --doc-dir=/tmp --list-doc-dirs | head -1
|
628
|
+
/tmp
|
629
|
+
```
|
630
|
+
|
631
|
+
#### Options `--gems`, `--no-gems`
|
632
|
+
|
633
|
+
Option `--gems` (the default) specifies that documents from installed gems
|
634
|
+
may be included;
|
635
|
+
option `--no-gems` may be used to exclude them:
|
636
|
+
|
637
|
+
```sh
|
638
|
+
$ ri --list | wc -l
|
639
|
+
1417
|
640
|
+
$ ri --list --no-gems| wc -l
|
641
|
+
1262
|
642
|
+
```
|
643
|
+
|
644
|
+
#### Options `--home`, `--no-home`
|
645
|
+
|
646
|
+
Option `--home` (the default) specifies that `ri` is to include source directory
|
647
|
+
in `~/.rdoc` if it exists;
|
648
|
+
option `--no-home` may be used to exclude them.
|
649
|
+
|
650
|
+
#### Options `--list-doc-dirs`, `--no-list-doc-dirs`
|
651
|
+
|
652
|
+
Option `--list-doc-dirs` specifies that a list of the `ri` source directories
|
653
|
+
is to be displayed;
|
654
|
+
default is `--no-list-doc-dirs`.
|
655
|
+
|
656
|
+
#### Option `--no-standard`
|
657
|
+
|
658
|
+
Option `--no-standard` specifies that documents from the standard libraries
|
659
|
+
are not to be included;
|
660
|
+
default is to include documents from the standard libraries.
|
661
|
+
|
662
|
+
#### Options `--site`, `--no-site`
|
663
|
+
|
664
|
+
Option `--site` (the default) specifies that documents from the site libraries
|
665
|
+
may be included;
|
666
|
+
option `--no-site` may be used to exclude them.
|
667
|
+
|
668
|
+
#### Options `--system`, `--no-system`
|
669
|
+
|
670
|
+
Option `--system` (the default) specifies that documents from the system libraries
|
671
|
+
may be included;
|
672
|
+
option `--no-system` may be used to exclude them.
|
673
|
+
|
674
|
+
### Mode Options
|
675
|
+
|
676
|
+
#### Options `--interactive`, `-i`, `--no-interactive`
|
677
|
+
|
678
|
+
Option `--interactive` (aliased as `-i`)
|
679
|
+
specifies that `ri` is to enter interactive mode (ignoring the _name_ if given);
|
680
|
+
the option is the default when no _name_ is given;
|
681
|
+
option `--no-interactive` (the default)
|
682
|
+
specifies that `ri` is not to enter interactive mode,
|
683
|
+
regardless of whether _name_ is given.
|
684
|
+
|
685
|
+
### Information Options
|
686
|
+
|
687
|
+
#### Options `--help`, `-h`
|
688
|
+
|
689
|
+
Option `--help` (aliased as `-h`) specifies that `ri` is to show
|
690
|
+
its help text and exit.
|
691
|
+
|
692
|
+
#### Options `--version`, `-v`
|
693
|
+
|
694
|
+
Option `--version` (aliased as `-v`) specifies that `ri` is to show its version and exit.
|
695
|
+
|
696
|
+
### Debugging Options
|
697
|
+
|
698
|
+
#### Options `--dump=FILEPATH`, `--no-dump`
|
699
|
+
|
700
|
+
Option `--dump=FILEPATH` specifies that `ri` is to dump the content
|
701
|
+
of the `.ri` file at the given file path;
|
702
|
+
option`--no-dump` (the default) specifies that `ri` is not to dump content.
|
703
|
+
|
704
|
+
The file path may point to any `.ri` file,
|
705
|
+
but typically would point to one named `cache.ri`:
|
706
|
+
|
707
|
+
```sh
|
708
|
+
$ ri --dump=/usr/share/ri/3.0.0/system/cache.ri | wc -l
|
709
|
+
14487
|
710
|
+
$ ri --dump=/usr/share/ri/3.0.0/system/cache.ri | head
|
711
|
+
{:ancestors=>
|
712
|
+
{"Array"=>["Enumerable", "Object"],
|
713
|
+
"RubyVM"=>["Object"],
|
714
|
+
"RubyVM::AbstractSyntaxTree::Node"=>["Object"],
|
715
|
+
"Object"=>["BasicObject", "Kernel"],
|
716
|
+
"Integer"=>["Numeric"],
|
717
|
+
"Module"=>["Object"],
|
718
|
+
"Class"=>["Module"],
|
719
|
+
"Complex"=>["Numeric"],
|
720
|
+
"NilClass"=>["Object"],
|
721
|
+
```
|
722
|
+
|
723
|
+
#### Options `--profile`, `--no-profile`
|
724
|
+
|
725
|
+
Option `--profile` specifies that the program is to be run with the Ruby profiler;
|
726
|
+
option `no-profile` (the default) specifies that the program is not to be run
|
727
|
+
with the Ruby profiler.
|
728
|
+
|
729
|
+
### Output Options
|
730
|
+
|
731
|
+
#### Options `--format=FORMAT`, `-f FORMAT`
|
732
|
+
|
733
|
+
Option `--format=FORMAT` (aliased as `-f`) specifies the formatter for the output,
|
734
|
+
which must be `ansi`, `bs`, `markdown`, or `rdoc`;
|
735
|
+
the default is `bs` for paged output, `ansi` otherwise.
|
736
|
+
|
737
|
+
#### Options `--pager`, `--no-pager`
|
738
|
+
|
739
|
+
Option `--pager` (the default) specifies that the output is to be piped
|
740
|
+
to a pager;
|
741
|
+
option `--no-pager` specifies that the output is not to be piped.
|
742
|
+
|
743
|
+
#### Options `--width=NUMBER`, `-w NUMBER`
|
744
|
+
|
745
|
+
Option `--width` (aliased as `-w`) specifies that the lengths of the displayed lines
|
746
|
+
should be restricted to the given _NUMBER_ of characters;
|
747
|
+
this is to be accomplished by line-wrapping, not truncation.
|
748
|
+
The default width is `80`:
|
749
|
+
|
750
|
+
```sh
|
751
|
+
$ ri --width=40 Array | head
|
752
|
+
= Array < Object
|
753
|
+
|
754
|
+
----------------------------------------
|
755
|
+
= Includes:
|
756
|
+
Enumerable (from ruby core)
|
757
|
+
|
758
|
+
(from ruby core)
|
759
|
+
----------------------------------------
|
760
|
+
An Array is an ordered, integer-indexed
|
761
|
+
collection of objects, called
|
762
|
+
```
|
763
|
+
|
764
|
+
|
765
|
+
### List Options
|
766
|
+
|
767
|
+
#### Options `--list`, `-l`, `--no-list`
|
768
|
+
|
769
|
+
Option `--list` (aliased as `-l`) specifies that all class and module names
|
770
|
+
whose initial characters match the given _name_ are to be displayed:
|
771
|
+
whose initial characters match the given _name_ are to be displayed:
|
772
|
+
|
773
|
+
```sh
|
774
|
+
$ ri --list Ar | head
|
775
|
+
ArgumentError
|
776
|
+
Array
|
777
|
+
```
|
778
|
+
|
779
|
+
If no _name_ is given, all class and module names are displayed.
|
780
|
+
|
781
|
+
Option `--no-list` (the default) specifies that a list of class and module names
|
782
|
+
is not to be displayed.
|
783
|
+
|
784
|
+
### Methods Options (for Class or Module)
|
785
|
+
|
786
|
+
#### Options `--all`, `-a`, `--no-all`
|
787
|
+
|
788
|
+
Option `--all` (aliased as `-a`) specifies that when _name_ identifies a class or module,
|
789
|
+
the documents for all its methods are included;
|
790
|
+
option `--no-all` (the default) specifies that the method documents are not to be included:
|
791
|
+
|
792
|
+
```shell
|
793
|
+
$ ri Array | wc -l
|
794
|
+
390
|
795
|
+
$ ri --all Array | wc -l
|
796
|
+
4224
|
797
|
+
```
|
798
|
+
|
799
|
+
### Server Option
|
800
|
+
|
801
|
+
#### Option `--server=NUMBER`
|
802
|
+
|
803
|
+
Option `--server` specifies that the \RDoc server is to be run on the port
|
804
|
+
given as _NUMBER_;
|
805
|
+
the default port is `8214`.
|
806
|
+
|
807
|
+
## Generating `ri` Source Files
|
808
|
+
|
809
|
+
`ri` by default reads data from directories installed by Ruby and gems.
|
810
|
+
|
811
|
+
You can create your own `ri` source files.
|
812
|
+
This command creates `ri` source files in local directory `my_ri`,
|
813
|
+
from Ruby source files in local directory `my_sources`:
|
814
|
+
|
815
|
+
```sh
|
816
|
+
$ rdoc --op my_ri --format=ri my_sources
|
817
|
+
```
|
818
|
+
|
819
|
+
Those files may then be considered for any `ri` command
|
820
|
+
by specifying option `--doc-dir=my_ri`;
|
821
|
+
see [option \\--doc-dir][20].
|
822
|
+
|
823
|
+
[1]: rdoc-ref:RI.md@Static+Mode
|
824
|
+
[2]: rdoc-ref:RI.md@Interactive+Mode
|
825
|
+
[3]: rdoc-ref:RI.md@Class+and+Module+Documents
|
826
|
+
[4]: rdoc-ref:RI.md@Options+--all-2C+-a-2C+--no-all
|
827
|
+
[5]: rdoc-ref:RI.md@Method+Documents
|
828
|
+
[6]: rdoc-ref:RI.md@Page+Documents
|
829
|
+
[7]: rdoc-ref:RI.md@ri+Lists
|
830
|
+
[8]: rdoc-ref:RI.md@Options+--list-2C+-l-2C+--no-list
|
831
|
+
[9]: https://docs.ruby-lang.org/en/master/IRB.html
|
832
|
+
[10]: rdoc-ref:RI.md@Pager
|
833
|
+
[11]: rdoc-ref:RI.md@Links+in+ri+Output
|
834
|
+
[12]: rdoc-ref:RI.md@Options+--list-doc-dirs-2C+--no-list-doc-dirs
|
835
|
+
[13]: rdoc-ref:RI.md@Options+--help-2C+-h
|
836
|
+
[14]: rdoc-ref:RI.md@Options+--version-2C+-v
|
837
|
+
[15]: rdoc-ref:RI.md@Options+--dump-3DFILEPATH-2C+--no-dump
|
838
|
+
[16]: rdoc-ref:RI.md@ri+Information
|
839
|
+
[17]: rdoc-ref:RI.md@Options
|
840
|
+
[18]: rdoc-ref:RI.md@ri+at+the+Ready
|
841
|
+
[19]: rdoc-ref:RI.md@Output+Filters
|
842
|
+
[20]: rdoc-ref:RI.md@Options+--doc-dir-3DDIRPATH-2C+-d+DIRPATH
|