slint-ui / document-features

Extract documentation for the feature flags from comments in Cargo.toml
Apache License 2.0
171 stars 11 forks source link

Docs suggests `document-features` as an optional feature #7

Closed emilk closed 2 years ago

emilk commented 2 years ago

Hi, and thanks for a great crate!

The docs suggests adding this to your Cargo.toml:

## Enable this when building the docs
document-features = { version = "0.2", optional = true }

The problem with this is that it breaks cargo check:

7 | #![doc = document_features::document_features!()]
  |          ^^^^^^^^^^^^^^^^^ use of undeclared crate or module `document_features`

I would suggest updating the docs to instead just have

document-features = "0.2"

unless there is some way to get around the cargo check issue that I'm not aware of

ogoffart commented 2 years ago

The docs suggest also to use cfg_attr in that case.

You could use

#![cfg_attr(feature = "document-features", doc = document_features::document_features!())]

If you think the docs are not clear enough feel free to make a suggestion :-)

emilk commented 2 years ago

Ah, I didn't read the far, just copy-pasted the first thing I saw :P

I made a PR where I suggest we always use the more verbose #![cfg_attr(feature = "document-features", doc = document_features::document_features!())]