Crates.io | readme-rustdocifier |
lib.rs | readme-rustdocifier |
version | 0.1.1 |
source | src |
created_at | 2022-01-01 12:14:12.033214 |
updated_at | 2022-02-17 12:54:28.391695 |
description | A library for rustdocifying `README.md` for inclusion in `lib.rs` |
homepage | |
repository | https://github.com/malaire/readme-rustdocifier |
max_upload_size | |
id | 506117 |
size | 33,212 |
A library for rustdocifying README.md
for inclusion in lib.rs
.
docs.rs
links to rustdoc format.unsafe
.Cargo.toml
:[build-dependencies]
readme-rustdocifier = "0.1.0"
README.md
.build.rs
with following content:use std::{env, error::Error, fs, path::PathBuf};
const CRATE_NAME: &str = "your_crate_name_here";
fn main() -> Result<(), Box<dyn Error>> {
println!("cargo:rerun-if-changed=README.md");
fs::write(
PathBuf::from(env::var("OUT_DIR")?).join("README-rustdocified.md"),
readme_rustdocifier::rustdocify(
&fs::read_to_string("README.md")?,
&env::var("CARGO_PKG_NAME")?,
Some(&env::var("CARGO_PKG_VERSION")?),
Some(CRATE_NAME),
)?,
)?;
Ok(())
}
lib.rs
:#![doc = include_str!(concat!(env!("OUT_DIR"), "/README-rustdocified.md"))]
cargo doc
and see the generated documentation of your library.README.md
## foo
A foo library.
### Usage
Create [`Foo::new`].
[`Foo::new`]: https://docs.rs/foo/*/foo/struct.Foo.html#method.new
Above README.md
is rustdocified to:
A foo library.
## Usage
Create [`Foo::new`].
[`Foo::new`]: crate::Foo::new
Lines like [...]: https://docs.rs/PACKAGE/...
are converted to rustdoc format.
Following conversions are done:
https://docs.rs/PACKAGE
(1)
crate
https://docs.rs/PACKAGE#fragment
(1)
crate#fragment
https://docs.rs/PACKAGE/VERSION
(2)
crate
https://docs.rs/PACKAGE/VERSION#fragment
(2)
crate#fragment
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES
(2)
crate::MODULES
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES#fragment
(2)
crate::MODULES#fragment
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/enum.ENUM.html
crate::MODULES::ENUM
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/enum.ENUM.html#method.METHOD
crate::MODULES::ENUM::METHOD
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/enum.ENUM.html#variant.VARIANT
crate::MODULES::ENUM::VARIANT
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/enum.ENUM.html#fragment
crate::MODULES::ENUM#fragment
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/fn.FUNCTION.html
crate::MODULES::FUNCTION
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/fn.FUNCTION.html#fragment
crate::MODULES::FUNCTION#fragment
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/macro.MACRO.html
crate::MODULES::MACRO
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/macro.MACRO.html#fragment
crate::MODULES::MACRO#fragment
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/struct.STRUCT.html
crate::MODULES::STRUCT
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/struct.STRUCT.html#method.METHOD
crate::MODULES::STRUCT::METHOD
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/struct.STRUCT.html#fragment
crate::MODULES::STRUCT#fragment
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/trait.TRAIT.html
crate::MODULES::TRAIT
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/trait.TRAIT.html#tymethod.METHOD
crate::MODULES::TRAIT::METHOD
https://docs.rs/PACKAGE/VERSION/CRATE/MODULES/trait.TRAIT.html#fragment
crate::MODULES::TRAIT#fragment
Notes:
/
at path end./
or /index.html
at path end./MODULES
and corresponding ::MODULES
can be empty.This crate doesn't use any unsafe
code.
This is enforced by #![forbid(unsafe_code)]
.