cargo-readme icon indicating copy to clipboard operation
cargo-readme copied to clipboard

Generate rustdoc from README?

Open seanpianka opened this issue 4 years ago • 1 comments
trafficstars

My project uses #![doc = include_str!("../README.md")] to generate the rustdoc for the crate from its README. However, I noticed a user forked it just to remove this line, ostensibly since they're using a Rust version < 1.54.

Does this crate support this opposite direction for the doc generation? For example, outputting rustdoc comments to stdout, or automatically replacing src/lib.rs rustdoc with the result.

I suppose I can also just convert the markdown to rustdoc manually, but I'm curious about a tool for this. Thanks!

seanpianka avatar Oct 02 '21 23:10 seanpianka

@seanpianka I can't speak of this crate, but what you can do is feature-gat that include_str! of yours:

#![cfg_attr(feature = "better-docs",
    cfg_attr(all(), doc = include_str!("../README.md")),
)]

with some better-docs = [] feature in your crate which can be enabled by docs.rs:

[features]
# ...

better-docs = []  # unstable

[package.metadata.docs.rs]
features = ["better-docs"]

danielhenrymantilla avatar Jan 15 '22 15:01 danielhenrymantilla