orium / cargo-rdme

Cargo command to create the README.md from your crate's documentation
Mozilla Public License 2.0
126 stars 5 forks source link

Support `document-features`? #231

Open virtualritz opened 5 months ago

virtualritz commented 5 months ago

The document-features crate achieves a similar result as cargo-rdme.

A typical lib.rs doc block using this looks like:

//! Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
//! eiusmod tempor incididunt ut labore et dolore magna aliqua.  
//!
//! # Cargo Features
//!
#![doc = document_features::document_features!()]

The last part creates Markdown from ##-prefixed comments in the [features] section of Cargo.toml. I.e. it makes it easy to keep comments in Cargo.toml and docs in sync.

However, it can be mixed with additional (feature) docs and so the header, # Cargo Features, is not coming from document-features) but must be added manually. It then ends up at the bottom of the cargo-rdme-generated README.md, w/o anything under it.

It would be great if this feature-generation stuff could somehow be included/supported in cargo-rdme.

Alternatively a cargo-rdme option that removes the last header if it doesn't have text under it could be a workaround. E.g. --strip-terminal-empty-header.

orium commented 4 months ago

177 might allow this to be possible in the future.