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

Be able to enable --features / --all-features / --no-default-features #100

Closed
repi opened this issue Aug 20, 2022 · 3 comments · Fixed by #115
Closed

Be able to enable --features / --all-features / --no-default-features #100

repi opened this issue Aug 20, 2022 · 3 comments · Fixed by #115
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@repi
Copy link
Contributor

repi commented Aug 20, 2022

Would it be possible to add support for the Cargo --features / --all-features / --no-default-features options? Pipe them through to the underlying Cargo invocation.

We have multiple crates where we are both interested in the public API with --all-features enabled and also some where one wants to check for specific --features.

For example our puffin crate has a mutually exclusive features (not ideal) and fails to analyse:

$ cargo public-api --manifest-path ./puffin/Cargo.toml
    Checking once_cell v1.9.0
    Checking byteorder v1.4.3
 Documenting puffin v0.12.1 (/Users/repi/git/embark/puffin/puffin)
error: Either feature zstd or ruzstd must be enabled
   --> puffin/src/frame_data.rs:491:1
    |
491 | compile_error!("Either feature zstd or ruzstd must be enabled");
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error: Compilation failed, aborting rustdoc

error: could not document `puffin`

Caused by:
  process didn't exit successfully: `rustdoc --edition=2018 --crate-type lib --crate-name puffin puffin/src/lib.rs -o /Users/repi/git/embark/puffin/target/doc --cfg 'feature="default"' --error-format=json --json=diagnostic-rendered-ansi,artifacts,future-incompat -Z unstable-options --output-format json --cap-lints warn -C metadata=00aac93aa62b9ad4 -L dependency=/Users/repi/git/embark/puffin/target/debug/deps --extern byteorder=/Users/repi/git/embark/puffin/target/debug/deps/libbyteorder-922739cc82a0baa2.rmeta --extern once_cell=/Users/repi/git/embark/puffin/target/debug/deps/libonce_cell-b334803526b5c51d.rmeta --crate-version 0.12.1` (exit status: 1)
Error: Failed to build rustdoc JSON. Stderr: See above
@Enselic
Copy link
Member

Enselic commented Aug 20, 2022

Thank you for the feature request! It indeed makes a lot of sense to be able to select features. I have been wondering how long it would take before someone requested that ;)

I think the way forward is to add features of the appropriate type to rustdoc_json::BuildOptions found in this git. Should be pretty straightforward, so also setting as "good first issue".

@Emilgardis
Copy link
Member

Emilgardis commented Aug 26, 2022

I'm trying to implement this, and I'm wondering if the way to go is actually doing something like this

cargo public-api -- <my_cargo_rustdoc_flags> -- <my_rustdoc_flags>

ofc, that makes it possible to have duplicate flags but I think that's fine. BuildOptions could still take it explicitly

@Emilgardis
Copy link
Member

That would mean to enable a feature for your crate, you'd do

cargo public-api -- --features myfeature,otherfeature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants