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
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: c0ebea7b8adc8c270a62c2f34f0ede696b4440199e801d3126f1c828bd6606f6
|
|
4
|
+
data.tar.gz: 9d01b69cee3ae3f39c045240a67f7559ba9cf511fbd86dc6cb429dc0cfee38c3
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 57e14eb941738b7a3d7850990b777f94ceaa1d1b30cd4b03068cf0dd7047cad15f0d858e66df315b10275d17bf01cebd4e92de5893bc31641fcf23db0ac42ac2
|
|
7
|
+
data.tar.gz: 982792737323335b89e85bd0fffa9f2fbd675d4192f14545ff654a14ac974815f76445758da6e2f4a49b4825029a82585d72748a496cdbda76245da016d22320
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
User-visible changes are recorded here. This project follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and
|
|
5
|
+
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.1.0] - 2026-10-05
|
|
10
|
+
|
|
11
|
+
### Added
|
|
12
|
+
|
|
13
|
+
- Shell integration tests can run in Docker or Podman when local shells are
|
|
14
|
+
unavailable, with the same required checks used in CI.
|
|
15
|
+
- Compatibility checks for minimum runtime dependencies and older RI stores,
|
|
16
|
+
upstream Ruby documentation samples and repeatable CLI performance measurements.
|
|
17
|
+
- Release artifact checksums, build attestations and a protected hotfix workflow.
|
|
18
|
+
- Focused guides for reading, configuration, completion, troubleshooting,
|
|
19
|
+
compatibility, contribution and maintenance.
|
|
20
|
+
- Optional user YAML configuration with RI, environment and command-line
|
|
21
|
+
precedence, effective-settings inspection and safe recovery from invalid files.
|
|
22
|
+
- Terminal, dark and light themes, per-role style overrides, configurable color
|
|
23
|
+
depth and independent bat themes for shell commands and other languages.
|
|
24
|
+
- Theme and style completion, an annotated configuration example and a full
|
|
25
|
+
configuration reference covering behavior, environment variables and trust.
|
|
26
|
+
- A terminal reader for installed Ruby and gem documentation, with semantic
|
|
27
|
+
colors, Ruby syntax highlighting, Unicode-aware wrapping and plain output.
|
|
28
|
+
- Conservative recognition of shell transcripts with optional bat highlighting.
|
|
29
|
+
- Interactive discovery and dynamic completion for Bash, Zsh and Fish.
|
|
30
|
+
- A bundled manual, explicit dependencies and a tested gem installation path.
|
|
31
|
+
- Manual installation and terminal-width-aware formatting, with colors that
|
|
32
|
+
respect the user's pager settings.
|
|
33
|
+
|
|
34
|
+
### Fixed
|
|
35
|
+
|
|
36
|
+
- Long options require their full names so configuration selection and completion
|
|
37
|
+
cannot silently interpret abbreviations differently.
|
|
38
|
+
- Missing optional gems for `--server` and `--profile` explain how to install them;
|
|
39
|
+
help and the manual describe these dependencies.
|
|
40
|
+
- Required shell tests fail when Fish or Zsh is unavailable; test environment
|
|
41
|
+
cleanup preserves the suite's shell requirement flag.
|
|
42
|
+
- Optional bat highlighting has time and size limits, handles invalid encoding
|
|
43
|
+
and falls back to the original text without blocking subsequent examples.
|
|
44
|
+
- Incompatible RI cache formats explain how to regenerate documentation.
|
|
45
|
+
- Preserve heading level markers and ASCII horizontal separators in colored and
|
|
46
|
+
plain output so readers can search for document sections in their pager.
|
|
47
|
+
- Ruby highlighting recognizes predicate, bang, setter and operator methods,
|
|
48
|
+
including definitions and calls without parentheses. Symbols retain their
|
|
49
|
+
style, and modulo operators are distinct from percent literals.
|
|
50
|
+
- Shell completion uses documentation sources configured in `RI`.
|
|
51
|
+
- Interactive Tab completion includes its required Readline adapter.
|
|
52
|
+
- Raw Markdown content cannot send terminal controls through rich rendering.
|
|
53
|
+
- Invalid dump paths and a missing manual viewer produce actionable errors.
|
|
54
|
+
- Contributor checks handle shallow pull request merge histories.
|
|
55
|
+
|
|
56
|
+
[Unreleased]: https://github.com/hvpaiva/rich-ri/compare/v0.1.0...HEAD
|
|
57
|
+
[0.1.0]: https://github.com/hvpaiva/rich-ri/releases/tag/v0.1.0
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Highlander Paiva
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
18
|
+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
|
19
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
|
20
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
21
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# rich-ri
|
|
2
|
+
|
|
3
|
+
Read Ruby documentation with highlighted code, clear headings and colored
|
|
4
|
+
references. rich-ri wraps Ruby's RI reader and uses the documentation already
|
|
5
|
+
installed for your Ruby and gems.
|
|
6
|
+
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
The same page in `ri -f ansi` and rich-ri, using the same terminal palette.
|
|
10
|
+
rich-ri adds Ruby syntax highlighting and keeps heading markers searchable.
|
|
11
|
+
[Image details](docs/images/README.md).
|
|
12
|
+
|
|
13
|
+
## Install and read
|
|
14
|
+
|
|
15
|
+
Requires Ruby 3.4 or later on Linux or macOS.
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
gem install rich-ri
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Read a method:
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
rich-ri Array#map
|
|
25
|
+
rich-ri String#scan
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
RDoc, which provides RI, is installed as a gem dependency. If a page is missing,
|
|
29
|
+
see [documentation sources](docs/usage.md#documentation-sources-and-missing-pages).
|
|
30
|
+
|
|
31
|
+
Run `rich-ri` without a name for interactive lookup. Press Tab to discover
|
|
32
|
+
classes and methods; enter an empty line to leave. You can also
|
|
33
|
+
[enable shell completion](docs/shell-completion.md) for Bash, Zsh or Fish,
|
|
34
|
+
and use `ri` as an alias.
|
|
35
|
+
|
|
36
|
+
## Find your way around
|
|
37
|
+
|
|
38
|
+
Names follow RI conventions: `Array#map` is an instance method;
|
|
39
|
+
`File::open` is a class method. `Class.method` searches both kinds.
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
rich-ri Hash
|
|
43
|
+
rich-ri --all Array
|
|
44
|
+
rich-ri ruby:syntax/pattern_matching
|
|
45
|
+
rich-ri --help
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
In less, use `/` to search, `n` for the next match and `q` to quit.
|
|
49
|
+
Search for `^=== ` to jump between level-three headings.
|
|
50
|
+
`rich-ri --man` opens the full manual.
|
|
51
|
+
|
|
52
|
+
## Choose your colors
|
|
53
|
+
|
|
54
|
+
The default colors follow your terminal palette. Ruby highlighting is built in;
|
|
55
|
+
installing bat also highlights shell examples and other tagged languages.
|
|
56
|
+
|
|
57
|
+
```sh
|
|
58
|
+
rich-ri --theme=light Regexp
|
|
59
|
+
rich-ri --style='comment=bright_black' String#scan
|
|
60
|
+
rich-ri --no-color Array#map
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Save preferences in `~/.config/rich-ri/config.yml`:
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
theme: terminal
|
|
67
|
+
styles:
|
|
68
|
+
method: cyan
|
|
69
|
+
comment: bright_black
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The [configuration reference](docs/configuration.md) covers themes, individual
|
|
73
|
+
styles, pager settings and environment variables. `rich-ri --show-config` prints
|
|
74
|
+
your effective settings.
|
|
75
|
+
|
|
76
|
+
## More
|
|
77
|
+
|
|
78
|
+
- [Reading documentation](docs/usage.md): lookup, pager navigation and your own project's docs.
|
|
79
|
+
- [Shell completion and aliases](docs/shell-completion.md).
|
|
80
|
+
- [Troubleshooting](docs/troubleshooting.md) and [supported versions](docs/compatibility.md).
|
|
81
|
+
- [Contributing](CONTRIBUTING.md): setup, tests and pull requests.
|
|
82
|
+
- [Changelog](CHANGELOG.md) and [security policy](SECURITY.md).
|
|
83
|
+
|
|
84
|
+
Questions and bug reports are welcome in [GitHub issues](https://github.com/hvpaiva/rich-ri/issues).
|
|
85
|
+
Released under the [MIT license](LICENSE.txt).
|
data/SECURITY.md
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
## Report a vulnerability
|
|
4
|
+
|
|
5
|
+
Use [private vulnerability reporting](https://github.com/hvpaiva/rich-ri/security/advisories/new)
|
|
6
|
+
or email [contact@hvpaiva.dev](mailto:contact@hvpaiva.dev) with affected versions,
|
|
7
|
+
reproduction steps and impact. Please do not put exploit details or secrets in
|
|
8
|
+
a public issue. The maintainer will coordinate a fix and disclosure with you;
|
|
9
|
+
response time depends on availability.
|
|
10
|
+
|
|
11
|
+
Security fixes target the latest released version. There is no promise to
|
|
12
|
+
backport fixes to older 0.x releases. Ordinary bugs belong in GitHub issues.
|
|
13
|
+
|
|
14
|
+
## Trust boundaries
|
|
15
|
+
|
|
16
|
+
rich-ri reads the active Ruby's documentation and explicitly selected RI stores.
|
|
17
|
+
RDoc uses Ruby Marshal caches, which can instantiate Ruby objects while loading.
|
|
18
|
+
Do not point `--doc-dir` or `--dump` at untrusted files, or install untrusted
|
|
19
|
+
documentation into a searched directory. Completion reads the same trusted stores.
|
|
20
|
+
|
|
21
|
+
Ruby examples are parsed, never evaluated. Shell examples are tokenized, never
|
|
22
|
+
executed. Optional bat receives source on stdin with separate command arguments.
|
|
23
|
+
Its configuration file is disabled, and output that alters source is discarded.
|
|
24
|
+
Execution time and output size are bounded; failed highlighting leaves plain code.
|
|
25
|
+
Terminal controls in rich rendering are escaped; original RDoc formatters retain
|
|
26
|
+
upstream behavior when explicitly selected with `--format`.
|
|
27
|
+
|
|
28
|
+
Configuration files use safe YAML parsing: aliases, object tags, unknown keys and
|
|
29
|
+
invalid values are rejected. There is no Ruby evaluation, shell interpolation or
|
|
30
|
+
automatic project configuration search. Style strings use a restricted grammar;
|
|
31
|
+
raw terminal escapes are not accepted. A custom file selected with `--config` or
|
|
32
|
+
`RICH_RI_CONFIG` is still trusted input: it may select RI stores and a pager command.
|
|
33
|
+
|
|
34
|
+
`pager` command strings, `--pager-command`, `RI_PAGER` and `PAGER` are trusted
|
|
35
|
+
command settings interpreted by RDoc. `PATH` selects bat and other external
|
|
36
|
+
programs. Do not accept these settings from untrusted input. `--show-config` may
|
|
37
|
+
include command arguments and paths from your environment; review it before
|
|
38
|
+
sharing its output. `--server` deliberately enables RDoc's HTTP server; consult
|
|
39
|
+
RDoc before exposing it on a network.
|
|
40
|
+
|
|
41
|
+
## Supply chain
|
|
42
|
+
|
|
43
|
+
The gem declares runtime dependencies and its supported Ruby range. Development
|
|
44
|
+
uses a committed lockfile, automated dependency updates and a vulnerability audit.
|
|
45
|
+
GitHub Actions use pinned commits and minimal job permissions. Releases verify
|
|
46
|
+
the tag, version, changelog and ancestry on main or the matching hotfix branch,
|
|
47
|
+
then use RubyGems trusted publishing. Publication credentials are short-lived
|
|
48
|
+
and scoped to this gem. Installation tests, publication and GitHub Releases use
|
|
49
|
+
the same gem artifact, with a verified checksum and a GitHub build attestation.
|
|
50
|
+
|
|
51
|
+
Changes to protected branches go through pull requests with signed commits and
|
|
52
|
+
passing checks. Release tags and the publication environment are restricted,
|
|
53
|
+
and published GitHub releases are immutable. Maintainers verify these settings
|
|
54
|
+
before release. RubyGems trust must be configured for the repository, workflow
|
|
55
|
+
and environment described in [Maintenance](docs/maintenance.md).
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# bash completion for rich-ri; requires bash-completion 2.x.
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
|
|
4
|
+
_rich_ri() {
|
|
5
|
+
# _init_completion assigns prev through Bash's dynamic scope.
|
|
6
|
+
# shellcheck disable=SC2034
|
|
7
|
+
local cur prev words cword value _description
|
|
8
|
+
COMPREPLY=()
|
|
9
|
+
_init_completion -n ':=' || return
|
|
10
|
+
while IFS=$'\t' read -r value _description; do
|
|
11
|
+
[[ -n $value ]] && COMPREPLY+=("$value")
|
|
12
|
+
done < <(command rich-ri --complete --shell=bash "${words[@]:1:cword}" 2>/dev/null)
|
|
13
|
+
if ((${#COMPREPLY[@]} == 1)) && [[ ${COMPREPLY[0]} == *[:.#/=] ]]; then
|
|
14
|
+
compopt -o nospace 2>/dev/null || :
|
|
15
|
+
fi
|
|
16
|
+
[[ $cur == *:* ]] && __ltrim_colon_completions "$cur"
|
|
17
|
+
if [[ $cur == *=* && $COMP_WORDBREAKS == *'='* ]]; then
|
|
18
|
+
COMPREPLY=("${COMPREPLY[@]#*=}")
|
|
19
|
+
fi
|
|
20
|
+
return 0
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
complete -o filenames -F _rich_ri rich-ri
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function __rich_ri_complete
|
|
2
|
+
set -l words (commandline -xpc 2>/dev/null)
|
|
3
|
+
or set words (commandline -opc | string unescape)
|
|
4
|
+
set -e words[1]
|
|
5
|
+
set -l current (commandline -ct | string unescape)
|
|
6
|
+
command rich-ri --complete $words "$current" 2>/dev/null
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
complete -c rich-ri -f -a '(__rich_ri_complete)'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#compdef rich-ri
|
|
2
|
+
|
|
3
|
+
_rich_ri() {
|
|
4
|
+
local value description
|
|
5
|
+
local -a values descriptions
|
|
6
|
+
while IFS=$'\t' read -r value description; do
|
|
7
|
+
[[ -n $value ]] || continue
|
|
8
|
+
values+=("$value")
|
|
9
|
+
descriptions+=("$value${description:+ -- $description}")
|
|
10
|
+
done < <(command rich-ri --complete --shell=zsh "${words[@]:1:$((CURRENT - 1))}" 2>/dev/null)
|
|
11
|
+
if (( ${#values} == 1 )) && [[ ${values[1]} == *[:.#/=] ]]; then
|
|
12
|
+
compadd -S '' -d descriptions -- "${values[@]}"
|
|
13
|
+
else
|
|
14
|
+
compadd -d descriptions -- "${values[@]}"
|
|
15
|
+
fi
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
compdef _rich_ri rich-ri
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Compatibility
|
|
2
|
+
|
|
3
|
+
## Supported environments
|
|
4
|
+
|
|
5
|
+
| Component | Support |
|
|
6
|
+
| --- | --- |
|
|
7
|
+
| Ruby | MRI 3.4 and 4.0. The gem requires Ruby 3.4 or later. |
|
|
8
|
+
| Operating system | Linux and macOS. Other systems and Ruby engines are untested. |
|
|
9
|
+
| RDoc | 8.1 or later in the 8.x series. |
|
|
10
|
+
| RI stores | Current RDoc output, plus RDoc 6.14 stores on Ruby 3.4. Regenerate caches when moving between Ruby 3 and 4. |
|
|
11
|
+
| Completion | Bash with bash-completion 2.x, Zsh and Fish. |
|
|
12
|
+
| Terminal | Plain output works without ANSI support. Colors depend on the terminal palette and capabilities. |
|
|
13
|
+
|
|
14
|
+
CI runs Ruby 3.4 and 4.0 on Linux and Ruby 4.0 on macOS. A separate Ruby 3.4 job
|
|
15
|
+
tests the minimum runtime dependency set in [minimum.gemfile](../gemfiles/minimum.gemfile).
|
|
16
|
+
Another job resolves current dependencies. The locked bundle is used for normal
|
|
17
|
+
development and releases. Shell integrations run natively on both platforms;
|
|
18
|
+
CI also checks the [container test environment](development.md#shell-tests)
|
|
19
|
+
available to contributors.
|
|
20
|
+
|
|
21
|
+
## Changes between versions
|
|
22
|
+
|
|
23
|
+
The supported interface consists of the executable, documented options,
|
|
24
|
+
configuration keys, environment variables and shell completion installation.
|
|
25
|
+
The default heading markers remain available for pager searches. Page layout and
|
|
26
|
+
syntax colors may improve in patch releases. Page output is intended for
|
|
27
|
+
interactive reading and has no stable format for parsing by scripts.
|
|
28
|
+
|
|
29
|
+
While rich-ri is below 1.0, patch releases preserve that interface. Incompatible
|
|
30
|
+
changes require a minor release and migration instructions in the changelog.
|
|
31
|
+
From 1.0 onward, incompatible changes require a major release. Ruby classes and
|
|
32
|
+
the internal completion protocol are implementation details.
|
|
33
|
+
|
|
34
|
+
Dropped Ruby, RDoc or platform support follows the same versioning policy. An
|
|
35
|
+
upcoming removal is announced in the changelog at least one minor release ahead,
|
|
36
|
+
except where a security fix requires an earlier change.
|
|
37
|
+
|
|
38
|
+
Only the latest released version receives fixes. See the
|
|
39
|
+
[security policy](../SECURITY.md) for vulnerability reports and
|
|
40
|
+
[maintenance guide](maintenance.md) for urgent releases.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# rich-ri configuration. Copy to ~/.config/rich-ri/config.yml,
|
|
2
|
+
# or $XDG_CONFIG_HOME/rich-ri/config.yml when that variable is absolute.
|
|
3
|
+
# Every key is optional. The active defaults follow your terminal and RI options.
|
|
4
|
+
# CLI > dedicated environment > this file > RI > built-in defaults.
|
|
5
|
+
# See configuration.md for all flags, environment variables and style grammar.
|
|
6
|
+
|
|
7
|
+
theme: terminal # terminal, dark or light
|
|
8
|
+
color: auto # auto, always or never
|
|
9
|
+
color_depth: auto # auto, basic, "256" or truecolor
|
|
10
|
+
width: 80 # Integer >= 20; omit this key to follow terminal width.
|
|
11
|
+
pager: true # true, false, or a trusted command such as "less -R"
|
|
12
|
+
bat_theme: base16 # Non-Ruby, non-shell examples; requires optional bat.
|
|
13
|
+
shell_theme: ansi # Shell examples and commands; requires optional bat.
|
|
14
|
+
all: false # Include all methods on class and module pages.
|
|
15
|
+
expand_refs: true # Expand references at the end of a page.
|
|
16
|
+
|
|
17
|
+
doc_dirs: [] # Extra existing RI stores, added to RI/CLI directories.
|
|
18
|
+
# doc_dirs:
|
|
19
|
+
# - ./ri # Relative to this file's directory, not the shell's cwd.
|
|
20
|
+
sources:
|
|
21
|
+
system: true
|
|
22
|
+
site: true
|
|
23
|
+
home: true
|
|
24
|
+
gems: true
|
|
25
|
+
|
|
26
|
+
# This table reproduces the terminal preset. Delete entries to inherit the
|
|
27
|
+
# selected preset; each entry replaces that role's complete style.
|
|
28
|
+
# Values must be strings: quote "208" and "#7aa2f7". Use "none" to disable a role.
|
|
29
|
+
# Example custom value: "fg=#7aa2f7:bg=#1a1b26:bold:underline"
|
|
30
|
+
styles:
|
|
31
|
+
title: "cyan:bold"
|
|
32
|
+
heading: "blue:bold"
|
|
33
|
+
subheading: "magenta:bold"
|
|
34
|
+
code: "cyan"
|
|
35
|
+
reference: "cyan"
|
|
36
|
+
link: "cyan:underline"
|
|
37
|
+
label: "yellow:bold"
|
|
38
|
+
muted: "bright_black"
|
|
39
|
+
emphasis: "italic"
|
|
40
|
+
bold: "bold"
|
|
41
|
+
strike: "strike"
|
|
42
|
+
keyword: "magenta"
|
|
43
|
+
string: "green"
|
|
44
|
+
number: "yellow"
|
|
45
|
+
constant: "yellow"
|
|
46
|
+
symbol: "yellow"
|
|
47
|
+
method: "cyan"
|
|
48
|
+
comment: "bright_black"
|
|
49
|
+
operator: "magenta"
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
# Configuration
|
|
2
|
+
|
|
3
|
+
rich-ri uses the original RDoc RI reader for documentation lookup. Its `RI`
|
|
4
|
+
environment variable, installed documentation and pager settings still apply.
|
|
5
|
+
The YAML file described here is specific to rich-ri; plain `ri` does not read it.
|
|
6
|
+
All settings are optional.
|
|
7
|
+
|
|
8
|
+
## Select a file
|
|
9
|
+
|
|
10
|
+
The default path is `$XDG_CONFIG_HOME/rich-ri/config.yml` when `XDG_CONFIG_HOME`
|
|
11
|
+
is a nonempty absolute path; otherwise it is `~/.config/rich-ri/config.yml`.
|
|
12
|
+
A missing default file is fine. rich-ri never searches the current project for
|
|
13
|
+
configuration, and installing the gem does not create or edit configuration.
|
|
14
|
+
|
|
15
|
+
Use `RICH_RI_CONFIG` or `--config FILE` to choose a different file. The explicit
|
|
16
|
+
file must exist and be readable. `--config=FILE` is equivalent. `--no-config`
|
|
17
|
+
disables file loading, including `RICH_RI_CONFIG`. If `--config` and `--no-config`
|
|
18
|
+
appear together, the last command-line selector wins.
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
rich-ri --config-path
|
|
22
|
+
rich-ri --config "$HOME/my-rich-ri.yml" --show-config
|
|
23
|
+
rich-ri --no-config --show-config
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`--config-path` prints the selected file path without opening it. `--show-config`
|
|
27
|
+
prints the effective preferences as YAML after validation and merging; it does not
|
|
28
|
+
write a file or load documentation. It includes environment overrides, so check
|
|
29
|
+
its contents before sharing it. It shows the requested color policy and depth;
|
|
30
|
+
`auto` still depends on the terminal when rendering. `pager: true` means paging
|
|
31
|
+
is allowed; redirected output still bypasses the pager. The `styles` map lists
|
|
32
|
+
explicit role overrides; preset styles are selected by `theme`.
|
|
33
|
+
|
|
34
|
+
Use a single YAML document containing a mapping; an empty file means no
|
|
35
|
+
overrides. Files larger than 64 KiB, nesting deeper than 20 levels, duplicate or
|
|
36
|
+
unknown keys, wrong types, invalid values, YAML aliases and object tags are
|
|
37
|
+
rejected with a usage error. Values are not interpolated or evaluated as Ruby
|
|
38
|
+
or shell code. A bad file does not prevent
|
|
39
|
+
`--help`, `--version`, `--config-path` or printing a shell completion script.
|
|
40
|
+
`--no-config` bypasses the bad file to let you continue using the reader.
|
|
41
|
+
|
|
42
|
+
## Precedence and RI compatibility
|
|
43
|
+
|
|
44
|
+
Settings are applied in this order, with later layers taking precedence:
|
|
45
|
+
|
|
46
|
+
1. Built-in defaults.
|
|
47
|
+
2. Default options in `RI`, split into shell words without shell evaluation.
|
|
48
|
+
3. The selected YAML configuration file.
|
|
49
|
+
4. Dedicated environment variables listed below.
|
|
50
|
+
5. Explicit command-line options.
|
|
51
|
+
|
|
52
|
+
The `RI` variable can contain default lookup and presentation options.
|
|
53
|
+
For example, `RI='--no-standard-docs --doc-dir /path/to/ri'` works for both lookup
|
|
54
|
+
and completion. rich-ri uses RDoc directly; the `ri` executable itself need not
|
|
55
|
+
be on `PATH`. rich-ri's extra theme, style and utility flags are not supported
|
|
56
|
+
by plain `ri`.
|
|
57
|
+
|
|
58
|
+
Most values replace earlier values. `styles` merges by role: a later `method`
|
|
59
|
+
style changes that role without dropping a `heading` style from an earlier layer.
|
|
60
|
+
A role override replaces the preset's entire style for that role.
|
|
61
|
+
Documentation directories are additive: `RI`, `doc_dirs` and repeatable
|
|
62
|
+
`--doc-dir` options contribute directories in that order.
|
|
63
|
+
|
|
64
|
+
`RI_PAGER` overrides a pager command from the file. `--pager-command` takes
|
|
65
|
+
precedence over both. `PAGER` is used only when no specific pager command was
|
|
66
|
+
selected. `--no-pager` disables paging even when a command is configured.
|
|
67
|
+
Output redirected to a pipe or file is not paged.
|
|
68
|
+
|
|
69
|
+
## File keys
|
|
70
|
+
|
|
71
|
+
Every key is optional. The [annotated example](config.example.yml) includes all
|
|
72
|
+
supported keys and style roles.
|
|
73
|
+
|
|
74
|
+
| Key | Default | Accepted values and behavior |
|
|
75
|
+
| --- | --- | --- |
|
|
76
|
+
| `theme` | `terminal` | `terminal`, `dark` or `light`. |
|
|
77
|
+
| `color` | `auto` | `auto`, `always` or `never`. |
|
|
78
|
+
| `color_depth` | `auto` | `auto`, `basic`, `"256"` or `truecolor`. |
|
|
79
|
+
| `width` | Terminal-based | Integer of at least 20; prose width in terminal columns. |
|
|
80
|
+
| `pager` | `true` | `true` to allow paging, `false` to disable it, or a trusted command string such as `less -R`. |
|
|
81
|
+
| `bat_theme` | `base16` | bat theme for tagged non-Ruby, non-shell examples. |
|
|
82
|
+
| `shell_theme` | `ansi` | bat theme for shell examples and commands inside transcripts. |
|
|
83
|
+
| `all` | `false` | Boolean; include all methods when reading a class or module. |
|
|
84
|
+
| `expand_refs` | `true` | Boolean; ask RDoc to expand references at the end of a page. |
|
|
85
|
+
| `doc_dirs` | `[]` | List of extra RI directories; relative entries are resolved from the configuration file's directory. |
|
|
86
|
+
| `sources` | All enabled | Mapping of `system`, `site`, `home` and `gems` to booleans. |
|
|
87
|
+
| `styles` | Theme preset | Mapping of semantic roles to style strings, described below. |
|
|
88
|
+
|
|
89
|
+
When width is not specified, the reader uses the terminal width minus two
|
|
90
|
+
columns, bounded between 30 and 96 columns. With redirected output it normally
|
|
91
|
+
uses 78 columns. Code blocks retain their original content and indentation.
|
|
92
|
+
|
|
93
|
+
`doc_dirs` must name existing directories. Use `sources` to disable selected
|
|
94
|
+
standard documentation locations; use `--no-standard-docs` to disable all four
|
|
95
|
+
from the command line. This changes which documentation is read, not which
|
|
96
|
+
packages are installed. `--list-doc-dirs` prints the resulting search paths.
|
|
97
|
+
RI stores contain Ruby Marshal data and must be trusted, even for completion.
|
|
98
|
+
|
|
99
|
+
A pager command is a trusted executable setting: RDoc may execute it through a
|
|
100
|
+
shell. Keep such commands under your own control. Merely reading or inspecting
|
|
101
|
+
configuration does not start a pager.
|
|
102
|
+
|
|
103
|
+
## Themes and styles
|
|
104
|
+
|
|
105
|
+
`terminal` uses your terminal's ANSI palette, preserving rich-ri's default
|
|
106
|
+
appearance. `dark` and `light` supply foreground colors suited to those
|
|
107
|
+
backgrounds. They do not set the terminal background or try to detect it.
|
|
108
|
+
Choose explicitly if your terminal palette needs different contrast.
|
|
109
|
+
|
|
110
|
+
Each style is a colon-separated string. A bare color sets the foreground;
|
|
111
|
+
`fg=COLOR` and `bg=COLOR` set foreground and background explicitly. Attributes
|
|
112
|
+
can be combined with colors. Use `none` by itself to remove a role's styling.
|
|
113
|
+
|
|
114
|
+
| Component | Values or example |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| ANSI foreground | `black`, `red`, `green`, `yellow`, `blue`, `magenta`, `cyan`, `white` |
|
|
117
|
+
| Bright ANSI foreground | `bright_black`, `bright_red`, `bright_green`, `bright_yellow`, `bright_blue`, `bright_magenta`, `bright_cyan`, `bright_white` |
|
|
118
|
+
| Palette index | `"0"` through `"255"`, for example `"208"` |
|
|
119
|
+
| RGB foreground | `"#RRGGBB"`, for example `"#7aa2f7"` |
|
|
120
|
+
| Terminal default | `default`, `fg=default` or `bg=default`; restore the terminal's default foreground or background. |
|
|
121
|
+
| Explicit colors | `"fg=#7aa2f7:bg=#1a1b26"` |
|
|
122
|
+
| Attributes | `bold`, `italic`, `underline`, `dim`, `strike`, `reverse` |
|
|
123
|
+
| Combined style | `"fg=cyan:bg=black:bold:underline"` |
|
|
124
|
+
| Disable role | `"none"` |
|
|
125
|
+
|
|
126
|
+
Names are lowercase. Each color component or attribute may appear only once.
|
|
127
|
+
Quote numeric and hex styles in YAML so that they remain
|
|
128
|
+
strings; an unquoted `#` starts a YAML comment. Raw ANSI escape sequences and
|
|
129
|
+
unknown attributes are rejected. Attribute appearance depends on your terminal.
|
|
130
|
+
|
|
131
|
+
| Role | Applies to |
|
|
132
|
+
| --- | --- |
|
|
133
|
+
| `title` | Page titles and the help usage heading. |
|
|
134
|
+
| `heading` | Main section headings. |
|
|
135
|
+
| `subheading` | Nested section headings. |
|
|
136
|
+
| `code` | Inline code, Ruby variables, boolean literals, `self`, interpolation and shell prompts. |
|
|
137
|
+
| `reference` | Recognized names, method lists, list markers and displayed URLs. |
|
|
138
|
+
| `link` | Labeled documentation and external links. |
|
|
139
|
+
| `label` | List labels and other labeled content. |
|
|
140
|
+
| `muted` | Secondary metadata and separators. |
|
|
141
|
+
| `emphasis` | Emphasized prose. |
|
|
142
|
+
| `bold` | Strong prose. |
|
|
143
|
+
| `strike` | Struck-through prose. |
|
|
144
|
+
| `keyword` | Ruby keywords. |
|
|
145
|
+
| `string` | Ruby strings, regular expressions and string-like literals. |
|
|
146
|
+
| `number` | Ruby numeric literals. |
|
|
147
|
+
| `constant` | Ruby constants. |
|
|
148
|
+
| `symbol` | Ruby symbols. |
|
|
149
|
+
| `method` | Ruby method definitions, calls and signatures. |
|
|
150
|
+
| `comment` | Ruby comments. |
|
|
151
|
+
| `operator` | Ruby operators and related syntax. |
|
|
152
|
+
|
|
153
|
+
```yaml
|
|
154
|
+
styles:
|
|
155
|
+
heading: "fg=#7aa2f7:bold"
|
|
156
|
+
method: "cyan"
|
|
157
|
+
comment: "bright_black"
|
|
158
|
+
link: "blue:underline"
|
|
159
|
+
muted: "none"
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
For a one-off change, use repeatable `--style=ROLE=STYLE` flags:
|
|
163
|
+
|
|
164
|
+
```sh
|
|
165
|
+
rich-ri --theme=dark --style='comment=#9ca3af' --style='method=cyan:bold' Regexp
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
`--format=NAME` selects an original RDoc formatter. Its formatting does not use
|
|
169
|
+
rich-ri's theme, role styles or rich page layout.
|
|
170
|
+
|
|
171
|
+
## Color policy and terminal capability
|
|
172
|
+
|
|
173
|
+
`color: auto` emits colors only when stdout is a terminal, `NO_COLOR` is empty or
|
|
174
|
+
unset, and `TERM` is not `dumb`. `--color` without a value means `always`.
|
|
175
|
+
`--color=always` forces colors even in a pipe or with `NO_COLOR` or `TERM=dumb`.
|
|
176
|
+
`--no-color` and `--color=never` preserve the page layout without ANSI colors.
|
|
177
|
+
|
|
178
|
+
Color depth is separate from whether colors are enabled. `color_depth: auto`
|
|
179
|
+
uses truecolor when `COLORTERM` is `truecolor` or `24bit`, 256 colors when `TERM`
|
|
180
|
+
contains `256color`, and the basic ANSI palette otherwise. Set `basic`, `"256"`
|
|
181
|
+
or `truecolor` explicitly to override detection. RGB and palette colors are
|
|
182
|
+
approximated when the chosen depth cannot represent them directly.
|
|
183
|
+
|
|
184
|
+
Ruby examples are highlighted in process and share these styles. No external
|
|
185
|
+
highlighter is needed for Ruby or for the rest of the page. Optional bat handles
|
|
186
|
+
other explicitly tagged languages and recognized shell commands. Its separate
|
|
187
|
+
`bat_theme` and `shell_theme` settings select bat themes; role overrides do not
|
|
188
|
+
recolor bat's tokens. Run `bat --list-themes` to see installed themes.
|
|
189
|
+
|
|
190
|
+
The selected color depth applies to rich-ri's built-in styles; bat handles its
|
|
191
|
+
own depth. rich-ri disables bat's configuration file and passes its own formatting
|
|
192
|
+
options.
|
|
193
|
+
If bat is missing, fails, exceeds two seconds or returns invalid text, the original
|
|
194
|
+
code is shown without highlighting and bat is disabled for the rest of the page.
|
|
195
|
+
Examples larger than 1 MiB bypass bat; its output is limited to 8 MiB.
|
|
196
|
+
Disabling rich-ri colors also disables bat highlighting.
|
|
197
|
+
|
|
198
|
+
## Environment variables
|
|
199
|
+
|
|
200
|
+
Empty dedicated `RICH_RI_*` variables are ignored. Unset a variable, or set it to
|
|
201
|
+
an empty value, to fall back to the file or an earlier layer.
|
|
202
|
+
|
|
203
|
+
| Variable | Meaning |
|
|
204
|
+
| --- | --- |
|
|
205
|
+
| `RICH_RI_CONFIG` | Explicit configuration file path; overridden by `--config` or `--no-config`. |
|
|
206
|
+
| `RICH_RI_THEME` | `theme` override. |
|
|
207
|
+
| `RICH_RI_COLOR` | `color` override. |
|
|
208
|
+
| `RICH_RI_COLOR_DEPTH` | `color_depth` override. |
|
|
209
|
+
| `RICH_RI_WIDTH` | `width` override. |
|
|
210
|
+
| `RICH_RI_BAT_THEME` | `bat_theme` override; takes precedence over `BAT_THEME`. |
|
|
211
|
+
| `RICH_RI_SHELL_THEME` | `shell_theme` override. |
|
|
212
|
+
| `RICH_RI_STYLE_<ROLE>` | Override a role using its uppercase name, for example `RICH_RI_STYLE_COMMENT=cyan`. |
|
|
213
|
+
| `RI` | Default command-line options, parsed as shell words. |
|
|
214
|
+
| `RI_PAGER` | Documentation pager command; overrides the file, below `--pager-command`. |
|
|
215
|
+
| `PAGER` | Fallback documentation pager; also used by man according to its own rules. |
|
|
216
|
+
| `LESS` | Options for less; rich-ri appends `-R` for its child documentation pager. |
|
|
217
|
+
| `BAT_THEME` | Backward-compatible bat theme override when `RICH_RI_BAT_THEME` is unset. |
|
|
218
|
+
| `NO_COLOR` | Nonempty values disable automatic colors. |
|
|
219
|
+
| `TERM` | `dumb` disables automatic colors; `256color` indicates 256-color capability. |
|
|
220
|
+
| `COLORTERM` | `truecolor` or `24bit` indicates truecolor capability in automatic depth mode. |
|
|
221
|
+
| `XDG_CONFIG_HOME` | Absolute base directory for the default configuration file. |
|
|
222
|
+
| `GEM_HOME`, `GEM_PATH` | RubyGems paths that affect installed documentation stores. |
|
|
223
|
+
| `HOME` | Home configuration and RI documentation locations. |
|
|
224
|
+
| `PATH` | Search path for external programs such as bat, less and man. |
|
|
225
|
+
| `MANPAGER` | Manual viewer's pager, according to man. |
|
|
226
|
+
| `MANROFFOPT`, `GROFF_NO_SGR`, `LESS_TERMCAP_*` | Existing manual rendering and palette settings. |
|
|
227
|
+
| `MANPATH` | Manual search path for `man rich-ri`. |
|
|
228
|
+
| `XDG_DATA_HOME` | Absolute base for `--install-man`; otherwise `~/.local/share` is used. |
|
|
229
|
+
|
|
230
|
+
For Bash or Zsh, export variables with `export RICH_RI_THEME=light`. In Fish, use
|
|
231
|
+
`set -gx RICH_RI_THEME light`. Flags and YAML have the same meaning in all shells.
|
|
232
|
+
|
|
233
|
+
The bundled manual honors existing man pager and palette settings. rich-ri only
|
|
234
|
+
supplies its manual palette when none of those settings are configured. Installing
|
|
235
|
+
the manual copies the current bundled file; rerun `--install-man` after upgrades.
|
|
236
|
+
|
|
237
|
+
## Troubleshooting
|
|
238
|
+
|
|
239
|
+
- **A configuration error prevents lookup:** run `rich-ri --no-config --show-config`
|
|
240
|
+
to bypass the file, then inspect `rich-ri --config-path`. Dedicated environment
|
|
241
|
+
overrides still apply; correct or unset any invalid one named by the error.
|
|
242
|
+
- **A theme appears unchanged:** check `--show-config`, `NO_COLOR`, redirected
|
|
243
|
+
stdout and whether you selected an original RDoc formatter with `--format`.
|
|
244
|
+
- **Colors look different over SSH:** check `TERM` and `COLORTERM` in the remote
|
|
245
|
+
session, or select a color depth supported by the actual terminal.
|
|
246
|
+
- **Only Ruby examples have colors:** install bat for other languages, and verify
|
|
247
|
+
that `bat_theme` and `shell_theme` name themes listed by `bat --list-themes`.
|
|
248
|
+
- **Completion is empty:** run `--show-config` and `--list-doc-dirs`; completion
|
|
249
|
+
uses the same sources and cannot suggest documentation names when configuration
|
|
250
|
+
or stores are invalid. Option and theme suggestions remain available.
|
|
251
|
+
|
|
252
|
+
Lookup, configuration and usage failures exit with status 1. Interrupts exit with
|
|
253
|
+
130; success and a closed output pipe exit with 0. No configuration command edits
|
|
254
|
+
shell files or installs completion scripts automatically.
|