slint-ui / document-features

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

document-feature fails with multi-line `default` feature entry #9

Closed dequbed closed 2 years ago

dequbed commented 2 years ago

if the entry for the default feature spans multiple lines trying to run cargo doc will return an error:

error: Parse error while parsing dependency default 
 --> src/main.rs:1:10
  |
1 | #![doc = document_features::document_features!()]
  |          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: this error originates in the macro `document_features::document_features` (in Nightly builds, run with -Z macro-backtrace for more info)

error: Compilation failed, aborting rustdoc

minimal Cargo.toml & main.rs required for this behaviour:

[package]
name = "dt"
version = "0.1.0"
edition = "2021"

[features]
default = [
    "foo"
]

## Doc commment for this feature
foo = []

[dependencies]
document-features = "0.2.1"
#![doc = document_features::document_features!()]

fn main() {
    println!("Hello, world!");
}

if the Cargo.toml is instead changed to the following (default put into a single line), everything works:

[package]
name = "dt"
version = "0.1.0"
edition = "2021"

[features]
default = [ "foo" ]

## Doc commment for this feature
foo = []

[dependencies]
document-features = "0.2.1"
ogoffart commented 2 years ago

Thanks for your bug report!

ogoffart commented 2 years ago

The 0.2.2 version was released on crates.io, that fixes the problem.