Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommend having document-features as an optional dependency #8

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@

This crate provides a macro that extracts documentation comments from Cargo.toml

To use this crate, add `#![doc = document_features::document_features!()]` in your crate documentation.
To use this crate, add `#![cfg_attr(feature = "document-features", doc = document_features::document_features!())]` in your crate documentation.
The `document_features!()` macro reads your `Cargo.toml` file, extracts feature comments and generates
a markdown string for your documentation.

Use `## ` and `#! ` comments in your Cargo.toml to document features, for example:

```toml
[package.metadata.docs.rs]
features = ["document-features"] # ensures that `document-features` is enabled when building docs

[dependencies]
document-features = "0.2"
document-features = { version = "0.2", optional = true }
## ...

[features]
Expand Down
7 changes: 5 additions & 2 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Document your crate's feature flags.

This crates provides a macro that extracts "documentation" comments from Cargo.toml

To use this crate, add `#![doc = document_features::document_features!()]` in your crate documentation.
To use this crate, add `#![cfg_attr(feature = "document-features", doc = document_features::document_features!())]` in your crate documentation.
The `document_features!()` macro reads your `Cargo.toml` file, extracts feature comments and generates
a markdown string for your documentation.

Expand All @@ -16,7 +16,7 @@ Basic example:
//! Normal crate documentation goes here.
//!
//! ## Feature flags
#![doc = document_features::document_features!()]
#![cfg_attr(feature = "document-features", doc = document_features::document_features!())]

// rest of the crate goes here.
```
Expand Down Expand Up @@ -48,6 +48,9 @@ in where they occur. Use them to group features, for example.
name = "..."
## ...

[package.metadata.docs.rs]
all-features = true # ensures that `document-features` is enabled when building docs

[features]
default = ["foo"]
##! This comments goes on top
Expand Down