rich-ri 0.1.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 +7 -0
- data/CHANGELOG.md +57 -0
- data/LICENSE.txt +21 -0
- data/README.md +85 -0
- data/SECURITY.md +55 -0
- data/completions/rich-ri.bash +23 -0
- data/completions/rich-ri.fish +9 -0
- data/completions/rich-ri.zsh +18 -0
- data/docs/compatibility.md +40 -0
- data/docs/config.example.yml +49 -0
- data/docs/configuration.md +254 -0
- data/docs/development.md +110 -0
- data/docs/images/README.md +29 -0
- data/docs/maintenance.md +105 -0
- data/docs/shell-completion.md +51 -0
- data/docs/troubleshooting.md +95 -0
- data/docs/usage.md +147 -0
- data/exe/rich-ri +6 -0
- data/lib/rich_ri/ansi.rb +35 -0
- data/lib/rich_ri/bat.rb +73 -0
- data/lib/rich_ri/cli.rb +112 -0
- data/lib/rich_ri/color.rb +54 -0
- data/lib/rich_ri/completion.rb +135 -0
- data/lib/rich_ri/configuration.rb +177 -0
- data/lib/rich_ri/configuration_options.rb +95 -0
- data/lib/rich_ri/driver.rb +111 -0
- data/lib/rich_ri/formatter.rb +169 -0
- data/lib/rich_ri/highlighter.rb +195 -0
- data/lib/rich_ri/manual.rb +74 -0
- data/lib/rich_ri/options.rb +160 -0
- data/lib/rich_ri/style.rb +48 -0
- data/lib/rich_ri/theme.rb +88 -0
- data/lib/rich_ri/version.rb +5 -0
- data/lib/rich_ri.rb +23 -0
- data/man/man1/rich-ri.1 +419 -0
- metadata +209 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "ansi"
|
|
4
|
+
require_relative "style"
|
|
5
|
+
|
|
6
|
+
module RichRI
|
|
7
|
+
class Theme
|
|
8
|
+
NAMES = %w[terminal dark light].freeze
|
|
9
|
+
DEPTHS = %w[auto basic 256 truecolor].freeze
|
|
10
|
+
ROLES = COLORS.keys.freeze
|
|
11
|
+
PALETTES = {
|
|
12
|
+
"dark" => {
|
|
13
|
+
title: "fg=#80d4ff:bold", heading: "fg=#82aaff:bold", subheading: "fg=#c792ea:bold",
|
|
14
|
+
code: "#89ddff", reference: "#89ddff", link: "fg=#89ddff:underline", label: "fg=#ffcb6b:bold",
|
|
15
|
+
muted: "#a6accd", keyword: "#c792ea", string: "#c3e88d", number: "#f78c6c", constant: "#ffcb6b",
|
|
16
|
+
symbol: "#ffcb6b", method: "#82aaff", comment: "#a6accd", operator: "#c792ea"
|
|
17
|
+
}.freeze,
|
|
18
|
+
"light" => {
|
|
19
|
+
title: "fg=#005a8b:bold", heading: "fg=#244fbd:bold", subheading: "fg=#7634a2:bold",
|
|
20
|
+
code: "#006b75", reference: "#006b75", link: "fg=#005a8b:underline", label: "fg=#885b00:bold",
|
|
21
|
+
muted: "#606060", keyword: "#7634a2", string: "#226b2f", number: "#a14300", constant: "#885b00",
|
|
22
|
+
symbol: "#885b00", method: "#005a8b", comment: "#606060", operator: "#7634a2"
|
|
23
|
+
}.freeze
|
|
24
|
+
}.freeze
|
|
25
|
+
|
|
26
|
+
attr_reader :name, :depth
|
|
27
|
+
|
|
28
|
+
def initialize(name: "terminal", styles: {}, depth: "auto", env: ENV)
|
|
29
|
+
raise ArgumentError, "unknown theme #{name.inspect}; choose #{NAMES.join(', ')}" unless NAMES.include?(name)
|
|
30
|
+
unless DEPTHS.include?(depth)
|
|
31
|
+
raise ArgumentError, "unknown color depth #{depth.inspect}; choose #{DEPTHS.join(', ')}"
|
|
32
|
+
end
|
|
33
|
+
raise ArgumentError, "styles must be a mapping of roles to style strings" unless styles.is_a?(Hash)
|
|
34
|
+
|
|
35
|
+
@name = name.dup.freeze
|
|
36
|
+
@depth = (depth == "auto" ? self.class.detect_depth(env) : depth).dup.freeze
|
|
37
|
+
@styles = COLORS.dup
|
|
38
|
+
apply_styles(PALETTES.fetch(name, {}))
|
|
39
|
+
apply_styles(styles)
|
|
40
|
+
@styles.transform_values!(&:freeze)
|
|
41
|
+
@styles.freeze
|
|
42
|
+
freeze
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def self.detect_depth(env)
|
|
46
|
+
return "truecolor" if %w[truecolor 24bit].include?(env["COLORTERM"].to_s.downcase)
|
|
47
|
+
return "256" if env["TERM"].to_s.include?("256color")
|
|
48
|
+
|
|
49
|
+
"basic"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def sgr(role)
|
|
53
|
+
unless (role.is_a?(String) || role.is_a?(Symbol)) && @styles.key?(role.to_sym)
|
|
54
|
+
raise ArgumentError, "unknown style role #{role.inspect}; choose #{ROLES.join(', ')}"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
@styles.fetch(role.to_sym)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def paint(text, *roles, enabled: true)
|
|
61
|
+
return text unless enabled && !roles.empty?
|
|
62
|
+
|
|
63
|
+
codes = roles.map { |role| sgr(role) }.reject(&:empty?).join(";")
|
|
64
|
+
return text if codes.empty?
|
|
65
|
+
|
|
66
|
+
text.gsub(/\S+/) { |word| "\e[#{codes}m#{word}#{RESET}" }
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
private
|
|
70
|
+
|
|
71
|
+
def apply_styles(styles)
|
|
72
|
+
seen = {}
|
|
73
|
+
styles.each do |role, value|
|
|
74
|
+
unless (role.is_a?(String) || role.is_a?(Symbol)) && ROLES.include?(role.to_sym)
|
|
75
|
+
raise ArgumentError, "unknown style role #{role.inspect}; choose #{ROLES.join(', ')}"
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
key = role.to_sym
|
|
79
|
+
raise ArgumentError, "duplicate style role #{role.inspect}" if seen[key]
|
|
80
|
+
|
|
81
|
+
seen[key] = true
|
|
82
|
+
@styles[key] = Style.new(value).sgr(@depth)
|
|
83
|
+
rescue ArgumentError => e
|
|
84
|
+
raise ArgumentError, "style #{role.inspect}: #{e.message}"
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
data/lib/rich_ri.rb
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rdoc/ri/driver"
|
|
4
|
+
require "prism"
|
|
5
|
+
require "reline"
|
|
6
|
+
require "io/console"
|
|
7
|
+
require "open3"
|
|
8
|
+
require "shellwords"
|
|
9
|
+
require "timeout"
|
|
10
|
+
require "psych"
|
|
11
|
+
|
|
12
|
+
require_relative "rich_ri/version"
|
|
13
|
+
require_relative "rich_ri/ansi"
|
|
14
|
+
require_relative "rich_ri/theme"
|
|
15
|
+
require_relative "rich_ri/configuration"
|
|
16
|
+
require_relative "rich_ri/configuration_options"
|
|
17
|
+
require_relative "rich_ri/bat"
|
|
18
|
+
require_relative "rich_ri/highlighter"
|
|
19
|
+
require_relative "rich_ri/formatter"
|
|
20
|
+
require_relative "rich_ri/driver"
|
|
21
|
+
require_relative "rich_ri/options"
|
|
22
|
+
require_relative "rich_ri/completion"
|
|
23
|
+
require_relative "rich_ri/cli"
|
data/man/man1/rich-ri.1
ADDED
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
.TH RICH-RI 1 "" "rich-ri 0.1.0" "User Commands"
|
|
2
|
+
.SH NAME
|
|
3
|
+
rich-ri - readable, colorful Ruby documentation
|
|
4
|
+
.SH SYNOPSIS
|
|
5
|
+
.B rich-ri
|
|
6
|
+
[options] [name ...]
|
|
7
|
+
.SH DESCRIPTION
|
|
8
|
+
Read the RI documentation installed for the active Ruby and its gems.
|
|
9
|
+
rich-ri wraps RDoc's RI library, adding colors, syntax highlighting,
|
|
10
|
+
documentation-page completion and shell completion for names and options.
|
|
11
|
+
It does not invoke the ri executable, which need not be on PATH.
|
|
12
|
+
Headings, references, signatures and Ruby examples use the selected theme.
|
|
13
|
+
The default theme follows the terminal palette.
|
|
14
|
+
With no name, start interactive lookup with Tab completion.
|
|
15
|
+
Submit an empty line to leave interactive lookup.
|
|
16
|
+
Use Class#method for instance methods, Class::method for class methods,
|
|
17
|
+
and Class.method to search both. Quote shell punctuation such as 'Array.[]'.
|
|
18
|
+
.PP
|
|
19
|
+
In less, use / to search, n for the next match, Space for the next page,
|
|
20
|
+
and q to return. Use --no-pager to write directly to stdout.
|
|
21
|
+
Headings retain their level markers (= through ======) in the heading style.
|
|
22
|
+
Horizontal separators use hyphens in a muted style.
|
|
23
|
+
Search for ^=== followed by a space to find level-three headings,
|
|
24
|
+
or ^--- to find separators. These markers also appear without colors.
|
|
25
|
+
.PP
|
|
26
|
+
Ruby highlighting works without external programs.
|
|
27
|
+
The optional bat program highlights shell transcripts and tagged languages;
|
|
28
|
+
without it, their original text is preserved. less is an optional pager.
|
|
29
|
+
man(1) is needed only for --man; --man-path and --install-man work without it.
|
|
30
|
+
.PP
|
|
31
|
+
--server requires the optional webrick gem (gem install webrick).
|
|
32
|
+
It serves RDoc's web interface on port 8214 by default, listening on all
|
|
33
|
+
interfaces; --server=PORT chooses another port. Stop it with Ctrl-C.
|
|
34
|
+
Terminal themes do not apply to web pages.
|
|
35
|
+
--profile requires the optional profile gem (gem install profile) and
|
|
36
|
+
prints profiling information when the command exits.
|
|
37
|
+
Install these gems for the active Ruby; with bundle exec, include them in
|
|
38
|
+
that bundle. Missing optional gems produce an installation hint and status 1.
|
|
39
|
+
.SH OPTIONS
|
|
40
|
+
Write long options in full; abbreviations are not accepted.
|
|
41
|
+
.SS Configuration and themes
|
|
42
|
+
.TP
|
|
43
|
+
.B \-\-config=FILE
|
|
44
|
+
Read a YAML configuration file instead of the user default.
|
|
45
|
+
.TP
|
|
46
|
+
.B \-\-no\-config
|
|
47
|
+
Skip the configuration file; environment options still apply.
|
|
48
|
+
.TP
|
|
49
|
+
.B \-\-config\-path
|
|
50
|
+
Print the selected configuration path; blank when disabled.
|
|
51
|
+
.TP
|
|
52
|
+
.B \-\-show\-config
|
|
53
|
+
Print effective preferences as YAML without opening documentation.
|
|
54
|
+
.TP
|
|
55
|
+
.B \-\-theme=NAME
|
|
56
|
+
Palette: terminal (default), dark or light.
|
|
57
|
+
.TP
|
|
58
|
+
.B \-\-color\-depth=DEPTH
|
|
59
|
+
Color depth: auto (default), basic, 256 or truecolor.
|
|
60
|
+
.TP
|
|
61
|
+
.B \-\-style=ROLE=STYLE
|
|
62
|
+
Override a style role; repeat for several roles. Example: method=green:bold.
|
|
63
|
+
.TP
|
|
64
|
+
.B \-\-bat\-theme=NAME
|
|
65
|
+
bat theme for tagged non\-Ruby, non\-shell code (default: base16).
|
|
66
|
+
.TP
|
|
67
|
+
.B \-\-shell\-theme=NAME
|
|
68
|
+
bat theme for shell input (default: ansi).
|
|
69
|
+
.TP
|
|
70
|
+
.B \-\-pager\-command=COMMAND
|
|
71
|
+
Choose a trusted pager command, overriding RI_PAGER/PAGER.
|
|
72
|
+
.SS Presentation
|
|
73
|
+
.TP
|
|
74
|
+
.B \-\-color[=MODE]
|
|
75
|
+
Color: auto (TTY, respects NO_COLOR), always or never.
|
|
76
|
+
.TP
|
|
77
|
+
.B \-\-no\-color
|
|
78
|
+
Plain text with the same page layout.
|
|
79
|
+
.TP
|
|
80
|
+
.B \-\-[no\-]pager
|
|
81
|
+
Display through a pager (automatically disabled in pipes).
|
|
82
|
+
.TP
|
|
83
|
+
.B \-T
|
|
84
|
+
Write directly to stdout.
|
|
85
|
+
.TP
|
|
86
|
+
.B \-w, \-\-width=WIDTH
|
|
87
|
+
Text width in terminal columns (at least 20).
|
|
88
|
+
.TP
|
|
89
|
+
.B \-f, \-\-format=NAME
|
|
90
|
+
Select an original RDoc formatter: ansi, bs, markdown, rdoc.
|
|
91
|
+
.SS Lookup
|
|
92
|
+
.TP
|
|
93
|
+
.B \-i, \-\-[no\-]interactive
|
|
94
|
+
Repeated lookup with Tab completion.
|
|
95
|
+
.TP
|
|
96
|
+
.B \-a, \-\-[no\-]all
|
|
97
|
+
Include all methods in a class page.
|
|
98
|
+
.TP
|
|
99
|
+
.B \-l, \-\-[no\-]list
|
|
100
|
+
List known classes and modules.
|
|
101
|
+
.TP
|
|
102
|
+
.B \-\-[no\-]expand\-refs
|
|
103
|
+
Expand RDoc references at the end of a page.
|
|
104
|
+
.TP
|
|
105
|
+
.B \-\-server[=PORT]
|
|
106
|
+
Serve RDoc in a browser (port: 8214; requires webrick).
|
|
107
|
+
.SS Documentation sources
|
|
108
|
+
.TP
|
|
109
|
+
.B \-d, \-\-doc\-dir=DIRS
|
|
110
|
+
Read RI stores from these directories; repeatable.
|
|
111
|
+
.TP
|
|
112
|
+
.B \-\-no\-standard\-docs
|
|
113
|
+
Use only directories provided with \-\-doc\-dir.
|
|
114
|
+
.TP
|
|
115
|
+
.B \-\-[no\-]system
|
|
116
|
+
Include system documentation (default: enabled).
|
|
117
|
+
.TP
|
|
118
|
+
.B \-\-[no\-]site
|
|
119
|
+
Include site documentation (default: enabled).
|
|
120
|
+
.TP
|
|
121
|
+
.B \-\-[no\-]home
|
|
122
|
+
Include home documentation (default: enabled).
|
|
123
|
+
.TP
|
|
124
|
+
.B \-\-[no\-]gems
|
|
125
|
+
Include gems documentation (default: enabled).
|
|
126
|
+
.TP
|
|
127
|
+
.B \-\-[no\-]list\-doc\-dirs
|
|
128
|
+
List the directories searched for RI documentation.
|
|
129
|
+
.SS Tools
|
|
130
|
+
.TP
|
|
131
|
+
.B \-\-completion=SHELL
|
|
132
|
+
Print a completion script for bash, zsh or fish.
|
|
133
|
+
.TP
|
|
134
|
+
.B \-\-man
|
|
135
|
+
Open the bundled manual with man.
|
|
136
|
+
.TP
|
|
137
|
+
.B \-\-man\-path
|
|
138
|
+
Print the path to the bundled manual.
|
|
139
|
+
.TP
|
|
140
|
+
.B \-\-install\-man[=DIR]
|
|
141
|
+
Install or update the manual in a user man1 directory.
|
|
142
|
+
.TP
|
|
143
|
+
.B \-\-dump=CACHE
|
|
144
|
+
Inspect a trusted RI cache file.
|
|
145
|
+
.TP
|
|
146
|
+
.B \-\-[no\-]profile
|
|
147
|
+
Run Ruby's profiler (requires the profile gem).
|
|
148
|
+
.TP
|
|
149
|
+
.B \-h, \-\-help
|
|
150
|
+
Show this help.
|
|
151
|
+
.TP
|
|
152
|
+
.B \-v, \-\-version
|
|
153
|
+
Show the rich\-ri version.
|
|
154
|
+
.SS Style roles
|
|
155
|
+
.SH EXAMPLES
|
|
156
|
+
.nf
|
|
157
|
+
rich\-ri Array#map
|
|
158
|
+
rich\-ri \(aqArray.[]\(aq
|
|
159
|
+
rich\-ri ruby:syntax/pattern_matching
|
|
160
|
+
rich\-ri \-\-color=always Hash | less \-R
|
|
161
|
+
rich\-ri \-\-no\-standard\-docs \-\-doc\-dir ./doc/ri MyClass
|
|
162
|
+
.fi
|
|
163
|
+
.SH CONFIGURATION
|
|
164
|
+
The optional user file is $XDG_CONFIG_HOME/rich-ri/config.yml when
|
|
165
|
+
XDG_CONFIG_HOME is absolute and nonempty; otherwise use
|
|
166
|
+
~/.config/rich-ri/config.yml. No project file is loaded automatically.
|
|
167
|
+
The file is specific to rich-ri; the original ri does not read it.
|
|
168
|
+
.PP
|
|
169
|
+
RICH_RI_CONFIG or --config FILE selects another file, which must exist.
|
|
170
|
+
--no-config disables file loading. The last command-line file selector wins.
|
|
171
|
+
--config-path prints the selected path without reading it.
|
|
172
|
+
--show-config prints the effective settings as YAML without editing a file.
|
|
173
|
+
Review its paths and command arguments before sharing the output.
|
|
174
|
+
.PP
|
|
175
|
+
Precedence, from lowest to highest: built-in defaults, RI default options,
|
|
176
|
+
the selected YAML file, dedicated environment variables, command-line flags.
|
|
177
|
+
Styles merge by role; each override replaces that role's complete style.
|
|
178
|
+
Documentation directories accumulate from RI, the file and the command line.
|
|
179
|
+
Relative doc_dirs in YAML resolve from the file's own directory.
|
|
180
|
+
.PP
|
|
181
|
+
Use a single YAML mapping; an empty file means no overrides. Files over
|
|
182
|
+
64 KiB, nesting over 20 levels, duplicate or unknown keys, wrong types,
|
|
183
|
+
invalid values, aliases and object tags are errors. No Ruby or shell evaluation occurs.
|
|
184
|
+
--help, --version, --config-path and --completion=SHELL still work with a
|
|
185
|
+
broken file. Use --no-config to bypass it for other commands.
|
|
186
|
+
.SS File keys
|
|
187
|
+
.TP
|
|
188
|
+
.B theme
|
|
189
|
+
terminal (default), dark or light. Presets change foreground colors;
|
|
190
|
+
they do not detect or set the terminal background.
|
|
191
|
+
.TP
|
|
192
|
+
.B color
|
|
193
|
+
auto (default), always or never. Auto colors only terminal output, unless
|
|
194
|
+
NO_COLOR is nonempty or TERM is dumb. --color means always.
|
|
195
|
+
--color=always overrides NO_COLOR and TERM=dumb, including in pipes.
|
|
196
|
+
.TP
|
|
197
|
+
.B color_depth
|
|
198
|
+
auto (default), basic, "256" or truecolor. Auto uses COLORTERM=truecolor
|
|
199
|
+
or 24bit first, then TERM containing 256color, then basic ANSI colors.
|
|
200
|
+
Colors are approximated when the selected depth cannot represent them.
|
|
201
|
+
This setting applies to built-in styles; bat handles its own color depth.
|
|
202
|
+
.TP
|
|
203
|
+
.B width
|
|
204
|
+
Integer of at least 20 terminal columns. The default follows terminal width
|
|
205
|
+
minus two, bounded between 30 and 96. Redirected output normally uses 78.
|
|
206
|
+
Code blocks preserve their original content and indentation.
|
|
207
|
+
.TP
|
|
208
|
+
.B pager
|
|
209
|
+
true (default), false, or a trusted command string such as "less -R".
|
|
210
|
+
RI_PAGER overrides a file command; --pager-command overrides both.
|
|
211
|
+
PAGER is a fallback. --no-pager disables paging; redirected output is not paged.
|
|
212
|
+
.TP
|
|
213
|
+
.B bat_theme, shell_theme
|
|
214
|
+
bat themes for non-Ruby, non-shell examples (default base16) and shell examples or
|
|
215
|
+
transcript commands (default ansi). Run bat --list-themes for installed themes.
|
|
216
|
+
Role overrides do not recolor bat output. Missing or failing bat leaves plain code.
|
|
217
|
+
.TP
|
|
218
|
+
.B all, expand_refs
|
|
219
|
+
Booleans: all defaults to false; expand_refs defaults to true. Include all
|
|
220
|
+
methods on class pages, or ask RDoc to expand references at the end of a page.
|
|
221
|
+
.TP
|
|
222
|
+
.B doc_dirs
|
|
223
|
+
List of additional existing, trusted RI directories. Default: empty list.
|
|
224
|
+
.TP
|
|
225
|
+
.B sources
|
|
226
|
+
Mapping of system, site, home and gems to booleans. All default to true.
|
|
227
|
+
These select standard RI stores; --no-standard-docs disables all four.
|
|
228
|
+
.TP
|
|
229
|
+
.B styles
|
|
230
|
+
Mapping of semantic role names to style strings. See STYLES below.
|
|
231
|
+
.SS Example
|
|
232
|
+
.nf
|
|
233
|
+
theme: terminal
|
|
234
|
+
color: auto
|
|
235
|
+
color_depth: auto
|
|
236
|
+
pager: true
|
|
237
|
+
styles:
|
|
238
|
+
heading: "blue:bold"
|
|
239
|
+
comment: "bright_black"
|
|
240
|
+
.fi
|
|
241
|
+
.PP
|
|
242
|
+
Original RDoc formatters selected with --format do not use rich-ri themes,
|
|
243
|
+
semantic styles or page layout. Ruby highlighting needs no external program.
|
|
244
|
+
The repository includes docs/configuration.md and an annotated
|
|
245
|
+
docs/config.example.yml with every key and role.
|
|
246
|
+
.SH STYLES
|
|
247
|
+
Set styles in YAML, with RICH_RI_STYLE_<ROLE> environment variables,
|
|
248
|
+
or repeatable --style=ROLE=STYLE flags. Example:
|
|
249
|
+
.nf
|
|
250
|
+
rich\-ri \-\-style=\(aqcomment=#9ca3af\(aq Regexp
|
|
251
|
+
.fi
|
|
252
|
+
.PP
|
|
253
|
+
Separate components with colons. A bare color sets the foreground.
|
|
254
|
+
Use fg=COLOR and bg=COLOR for explicit foreground and background.
|
|
255
|
+
Colors are black, red, green, yellow, blue, magenta, cyan, white,
|
|
256
|
+
their bright_ variants, an index from 0 through 255, or #RRGGBB.
|
|
257
|
+
Use default, fg=default or bg=default to restore the terminal's
|
|
258
|
+
default foreground or background color.
|
|
259
|
+
Attributes are bold, italic, underline, dim, strike and reverse.
|
|
260
|
+
Names are lowercase. Use none by itself to disable a role.
|
|
261
|
+
Raw ANSI escapes and unknown values are rejected.
|
|
262
|
+
Quote numeric and hex styles in YAML so they remain strings.
|
|
263
|
+
.nf
|
|
264
|
+
heading: "fg=#7aa2f7:bold"
|
|
265
|
+
method: "cyan"
|
|
266
|
+
link: "blue:underline"
|
|
267
|
+
muted: "none"
|
|
268
|
+
.fi
|
|
269
|
+
.SS Semantic roles
|
|
270
|
+
title: page title and help usage heading; heading: main sections;
|
|
271
|
+
subheading: nested sections; code: inline code, Ruby variables and literals,
|
|
272
|
+
interpolation and shell prompts; reference: names and method lists;
|
|
273
|
+
link: labeled documentation and external links; label: labeled content;
|
|
274
|
+
muted: secondary metadata and separators; emphasis: emphasized prose;
|
|
275
|
+
bold: strong prose; strike: struck-through prose.
|
|
276
|
+
.PP
|
|
277
|
+
Ruby roles: keyword, string (including regular expressions), number,
|
|
278
|
+
constant, symbol, method (definitions, calls and signatures), comment and operator.
|
|
279
|
+
All 19 roles accept the same style grammar. Theme presets can be
|
|
280
|
+
overridden one role at a time. Terminal support determines attribute appearance.
|
|
281
|
+
.SH ENVIRONMENT
|
|
282
|
+
Empty dedicated RICH_RI_* variables are ignored.
|
|
283
|
+
.TP
|
|
284
|
+
.B RICH_RI_CONFIG, XDG_CONFIG_HOME
|
|
285
|
+
Explicit file path and default configuration parent. See CONFIGURATION.
|
|
286
|
+
.TP
|
|
287
|
+
.B RICH_RI_THEME, RICH_RI_COLOR, RICH_RI_COLOR_DEPTH
|
|
288
|
+
Override the corresponding file keys. Explicit flags take precedence.
|
|
289
|
+
.TP
|
|
290
|
+
.B RICH_RI_WIDTH
|
|
291
|
+
Override prose width; an integer of at least 20.
|
|
292
|
+
.TP
|
|
293
|
+
.B RICH_RI_STYLE_<ROLE>
|
|
294
|
+
Override one style, using its uppercase role name, for example
|
|
295
|
+
RICH_RI_STYLE_COMMENT=cyan. Explicit --style flags take precedence.
|
|
296
|
+
.TP
|
|
297
|
+
.B RICH_RI_BAT_THEME, BAT_THEME
|
|
298
|
+
Override bat_theme in that order, below --bat-theme. Default: base16.
|
|
299
|
+
.TP
|
|
300
|
+
.B RICH_RI_SHELL_THEME
|
|
301
|
+
Override shell_theme, below --shell-theme. Default: ansi.
|
|
302
|
+
.TP
|
|
303
|
+
.B RI
|
|
304
|
+
Default options, parsed as shell words without shell evaluation.
|
|
305
|
+
File settings, dedicated environment variables and explicit flags override them.
|
|
306
|
+
Completion uses documentation-source options but never utility actions.
|
|
307
|
+
.TP
|
|
308
|
+
.B RI_PAGER, PAGER
|
|
309
|
+
Trusted documentation pager commands. RI_PAGER overrides a file command;
|
|
310
|
+
PAGER is the fallback. --pager-command takes precedence over both.
|
|
311
|
+
.TP
|
|
312
|
+
.B LESS
|
|
313
|
+
Options for less. rich-ri adds -R for its documentation pager only.
|
|
314
|
+
.TP
|
|
315
|
+
.B NO_COLOR, TERM
|
|
316
|
+
A nonempty NO_COLOR or TERM=dumb disables automatic colors.
|
|
317
|
+
--color=always overrides them; --no-color disables rich-ri's colors.
|
|
318
|
+
.TP
|
|
319
|
+
.B COLORTERM, TERM
|
|
320
|
+
Automatic color depth: truecolor or 24bit in COLORTERM, then 256color
|
|
321
|
+
in TERM, then the basic ANSI palette.
|
|
322
|
+
.TP
|
|
323
|
+
.B MANPAGER, PAGER
|
|
324
|
+
Select the manual viewer's pager, as supported by man(1).
|
|
325
|
+
.TP
|
|
326
|
+
.B MANROFFOPT, GROFF_NO_SGR, LESS_TERMCAP_*
|
|
327
|
+
Existing man formatting and pager settings are respected.
|
|
328
|
+
When colors are enabled and no pager settings exist, rich-ri supplies
|
|
329
|
+
a less palette using the selected heading and link styles.
|
|
330
|
+
Parent environment settings are not changed.
|
|
331
|
+
.TP
|
|
332
|
+
.B MANPATH, XDG_DATA_HOME
|
|
333
|
+
Manual search paths and the user data directory used by --install-man.
|
|
334
|
+
.TP
|
|
335
|
+
.B GEM_HOME, GEM_PATH, HOME, PATH
|
|
336
|
+
RubyGems documentation locations, home RI store and external program lookup.
|
|
337
|
+
HOME also supplies the fallback user configuration location.
|
|
338
|
+
.SH COMPLETION
|
|
339
|
+
Completion suggests installed classes, methods, pages, options and values.
|
|
340
|
+
It follows documentation sources from RI, the configuration file and explicit
|
|
341
|
+
arguments. It suggests theme names and semantic style roles as well as RI names.
|
|
342
|
+
It makes no network requests. Invalid configuration or broken stores prevent
|
|
343
|
+
documentation-name suggestions; options and theme values remain available.
|
|
344
|
+
Use --show-config and --list-doc-dirs to diagnose missing names.
|
|
345
|
+
.SS Bash
|
|
346
|
+
Load bash-completion 2.x, then run these commands:
|
|
347
|
+
.nf
|
|
348
|
+
data=${XDG_DATA_HOME:\-"$HOME/.local/share"}
|
|
349
|
+
dir="$data/bash\-completion/completions"
|
|
350
|
+
mkdir \-p "$dir"
|
|
351
|
+
rich\-ri \-\-completion=bash > "$dir/rich\-ri"
|
|
352
|
+
.fi
|
|
353
|
+
.PP
|
|
354
|
+
For the current shell, run source <(rich-ri --completion=bash).
|
|
355
|
+
.SS Zsh
|
|
356
|
+
Add these lines to .zshrc, after any existing completion setup:
|
|
357
|
+
.nf
|
|
358
|
+
autoload \-Uz compinit && compinit
|
|
359
|
+
source <(rich\-ri \-\-completion=zsh)
|
|
360
|
+
.fi
|
|
361
|
+
.SS Fish
|
|
362
|
+
Run these commands in Fish:
|
|
363
|
+
.nf
|
|
364
|
+
set \-l dir "$__fish_config_dir/completions"
|
|
365
|
+
mkdir \-p "$dir"
|
|
366
|
+
rich\-ri \-\-completion=fish > "$dir/rich\-ri.fish"
|
|
367
|
+
.fi
|
|
368
|
+
.SS Optional alias
|
|
369
|
+
To use ri as the short name in Bash, add these lines after loading
|
|
370
|
+
bash-completion:
|
|
371
|
+
.nf
|
|
372
|
+
alias ri=\(aqrich\-ri\(aq
|
|
373
|
+
source <(rich\-ri \-\-completion=bash)
|
|
374
|
+
complete \-o filenames \-F _rich_ri ri
|
|
375
|
+
.fi
|
|
376
|
+
.PP
|
|
377
|
+
In Zsh, add alias ri='rich-ri' after the completion setup.
|
|
378
|
+
In Fish, add alias ri rich-ri to your configuration.
|
|
379
|
+
command ri still invokes the original RI executable.
|
|
380
|
+
.PP
|
|
381
|
+
Reinstall copied Bash and Fish scripts after upgrading rich-ri.
|
|
382
|
+
Zsh's source command reads the current installed script on shell startup.
|
|
383
|
+
.SH MANUAL INSTALLATION
|
|
384
|
+
RubyGems keeps this page inside the installed gem.
|
|
385
|
+
rich-ri --man opens it directly; rich-ri --man-path prints its location.
|
|
386
|
+
.PP
|
|
387
|
+
Run rich-ri --install-man to copy or update the page in
|
|
388
|
+
$XDG_DATA_HOME/man/man1, or ~/.local/share/man/man1 if XDG_DATA_HOME
|
|
389
|
+
is unset, empty or relative. Use --install-man=DIR for another man1 directory.
|
|
390
|
+
The command prints a MANPATH setting for Bash, Zsh and Fish.
|
|
391
|
+
Its trailing empty entry preserves the system manual search paths.
|
|
392
|
+
Add the setting to your shell configuration if man rich-ri cannot find the page.
|
|
393
|
+
.PP
|
|
394
|
+
Re-run the installation command after upgrading the gem.
|
|
395
|
+
To uninstall the copied page, remove rich-ri.1 from that directory.
|
|
396
|
+
Nothing is installed or removed automatically by gem install or gem uninstall.
|
|
397
|
+
.SH DOCUMENTATION SOURCES
|
|
398
|
+
Use --list-doc-dirs to inspect the searched locations and --list for known classes.
|
|
399
|
+
If a gem lacks documentation, run gem rdoc GEM_NAME --ri.
|
|
400
|
+
Ruby core documentation comes from your Ruby manager or operating system.
|
|
401
|
+
RI caches can be incompatible across Ruby major versions.
|
|
402
|
+
Regenerate incompatible documentation with the current Ruby and RDoc.
|
|
403
|
+
rich-ri does not download or generate documentation while browsing.
|
|
404
|
+
.SH SECURITY
|
|
405
|
+
RI stores are Ruby Marshal data. Read only documentation you trust,
|
|
406
|
+
including when using completion or --dump.
|
|
407
|
+
Examples are never executed. Configuration uses safe YAML parsing, with no
|
|
408
|
+
object tags, aliases or code evaluation. No project configuration is loaded
|
|
409
|
+
automatically. Pager commands and selected RI stores must still be trusted.
|
|
410
|
+
bat comes from PATH; its configuration file is disabled.
|
|
411
|
+
bat calls have a two-second deadline, a 1 MiB input limit and an 8 MiB output limit.
|
|
412
|
+
Failed or invalid output leaves the original text and disables bat for the rest of the page.
|
|
413
|
+
.SH EXIT STATUS
|
|
414
|
+
0: success (including a closed output pipe); 1: lookup or usage failure;
|
|
415
|
+
130: interrupted.
|
|
416
|
+
.SH SEE ALSO
|
|
417
|
+
ri(1), ruby(1), less(1), bat(1)
|
|
418
|
+
.PP
|
|
419
|
+
Project documentation and support: https://github.com/hvpaiva/rich-ri
|