Crates.io | rustdoc-prettier |
lib.rs | rustdoc-prettier |
version | |
source | src |
created_at | 2024-06-30 11:11:59.89163 |
updated_at | 2024-12-12 09:36:00.479134 |
description | Format //! and /// comments with prettier |
homepage | |
repository | https://github.com/smoelius/rustdoc-prettier |
max_upload_size | |
id | 1287919 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
Format //!
and ///
comments with prettier
cargo install rustdoc-prettier
rustdoc-prettier
requires prettier
to be installed independently, e.g.:
npm install -g prettier
rustdoc-prettier [ARGS]
Arguments ending with .rs
are considered source files and are
formatted. All other arguments are forwarded to prettier
, with
one exception. An option of the form:
---max-width <N>
is converted to options of the form:
--prose-wrap always --print-width <M>
where M
is N
minus the sum of the widths of the indentation,
the //!
or ///
syntax, and the space that might follow that
syntax. If the current directory contains a rustfmt.toml file
with a max_width
key, the --max-width
option is applied
automatically.
rustdoc-prettier supports glob patterns. Example:
rustdoc-prettier '**/*.rs'
References
rustdoc-prettier
parses source code manually. It does not use rustdoc-json
. There are two reasons for this:
rustdoc-json
provides the span of the commented code, but not of the comment itself. To the best of my knowledge, there is no easy way to extract rustdoc
comments using rustdoc-json
's output.rustdoc-json
does not output spans for items that come from macro expansions or inline assembly. However, there are legitimate reasons to want to format such comments.