# manrs

A command-line viewer for documentation generated by `rustdoc`. Modernized fork of [rusty-man](https://git.sr.ht/~ireas/rusty-man).

## Example Usage

Look up any item by name (manrs finds your project's `target/doc` automatically):

```
$ manrs std::collections::HashMap
$ manrs serde::Serialize
$ manrs anyhow::Error
```

Partial names work too:

```
$ manrs HashMap
```

**No keyword? Get an interactive TUI crate picker.** Run `manrs` with no arguments inside any Cargo project — it will run `cargo doc` if needed, then open a full-screen picker where you can type to filter and press Enter to open:

```
$ manrs
```

The picker shows all available crates. Type any substring to narrow the list, use ↑/↓ to navigate, and press Enter to open.

If there are multiple matches for a keyword, manrs prompts you to pick one in the same way:

```
$ manrs u8
```

To read docs from a non-default location use `-s`/`--source`:

```
$ manrs --source path/to/target/doc io::Error
```

For all options:

```
$ manrs --help
```

## Viewers

Select a viewer with `--viewer`:

- `plain` — plain text output, no formatting. Default for non-interactive use (pipes, scripts).
- `rich` — formatted output with ANSI colors and syntax highlighting.
- `tui` — interactive terminal UI with keyboard navigation. **Default on interactive terminals.**

```
$ manrs --viewer rich std::vec::Vec   # force rich text
$ manrs --viewer plain std::vec::Vec  # force plain text
```

### TUI key bindings

| Key | Action |
|-----|--------|
| `j` / `k` | Scroll down / up one line |
| `J` / `K` | Jump to next / previous link (highlighted in blue when focused) |
| `Ctrl-F` / `Ctrl-B` | Page down / up |
| `PageDown` / `PageUp` | Page down / up |
| `g` / `G` | Jump to top / bottom |
| `Enter` | Follow focused link |
| `o` | Open any item by name |
| `Backspace` | Go back |
| `q` | Quit |

### TUI module page layout

Each module or item page is structured as:

1. **LINKS** — navigable doc links extracted from the description (e.g. `→ tower::Service`), shown at the top so the first `j` keypress reaches them immediately.
2. **SYNOPSIS** — the item's type signature.
3. **DESCRIPTION** — full documentation text with rich formatting:
   - Linked identifiers (e.g. `axum`, `tower::Service`) rendered in **cyan + underline**.
   - Inline code rendered in **light yellow**.
   - Code blocks with full **syntax highlighting** (via syntect).
   - Bold, italic, and emphasis text styled accordingly.
4. **Member sections** — structs, functions, traits, etc., each heading a focusable link.

## Installation

### From source

```
$ git clone https://github.com/Feeco-Li/manrs
$ cd manrs
$ cargo install --path .
```

### System docs

To browse standard library docs without running `cargo doc` first, install the Rust documentation component:

```
$ rustup component add rust-docs
$ manrs std::fs::File
```

## Editor Integration

### Neovim / Vim

Set manrs as the keyword lookup program for Rust files:

```vim
autocmd FileType rust setlocal keywordprg=manrs
```

Then press `K` over any identifier to open its documentation.

## License

MIT. Originally based on [rusty-man](https://git.sr.ht/~ireas/rusty-man) by Robin Krahl.
