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

Crate page should list the crate's Cargo "features" #465

Open
mbrubeck opened this issue Nov 10, 2016 · 11 comments
Open

Crate page should list the crate's Cargo "features" #465

mbrubeck opened this issue Nov 10, 2016 · 11 comments
Labels
C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works

Comments

@mbrubeck
Copy link
Contributor

It's currently hard to discover optional features for a crate. It would be useful for crates.io to list these along with the dependencies. Unfortunately there's no way to declare docs or other metadata for a feature, so this will just have to be a flat list, but maybe more info can be added in the future.

@carols10cents carols10cents added the C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works label Dec 15, 2016
@dhardy
Copy link

dhardy commented Feb 26, 2018

Crates.io automatically shows README.md contents, so features can be documented there. This is what rand does. Since this is more flexible than a flat list, I'd argue the issue is sufficiently well solved already (or it's just a crate doc issue)?

@Lonami
Copy link

Lonami commented Feb 20, 2019

@dhardy the problem with relying on the README.md is that it may more easily lead to inconsistencies in my opinion (i.e. a new feature was added but they forgot to update the README.md). Perhaps this is overkill, but how about detecting a # Features section in the README.md? Would that be possible/desirable? Anyway, a flat list should be better than nothing.

@dhardy
Copy link

dhardy commented Feb 20, 2019

I actually with you @Lonami, but have one caveat to add: Cargo considers any optional dependency a "feature", though sometimes these are not intended for use by end users.

Ideally there would be some way of annotating features with documentation in the Cargo.toml such that a documented list of features can be generated.

@Lonami
Copy link

Lonami commented Feb 20, 2019

TOML supports comments so perhaps if there's one above a feature it could be used as its description. But I don't think there's any visible standard on this.

@dancojocaru2000
Copy link

I actually with you @Lonami, but have one caveat to add: Cargo considers any optional dependency a "feature", though sometimes these are not intended for use by end users.

There are 2 possible solutions to this:

  1. Just list all of them anyway. There's no real reason not to. Even if they're not intended for end-users, there shouldn't be any problem in seeing that they exist.
  2. Focus on custom features, for example the following line from the example in The Cargo Book: secure-password = ["bcrypt"]

@nvzqz
Copy link

nvzqz commented Feb 14, 2020

I would love this feature! It's frustrating trying to find a crate's feature set and having to hunt down its Cargo.toml.

I believe all features (including optional dependencies) should be listed on a crate's page. There should be a distinction between custom features and dependency features, which would be a good middle ground for @dhardy's concern about "internal" features. This list should also express what features get enabled by other features.

@Lonami
Copy link

Lonami commented Feb 14, 2020

Note that optional dependencies are listed like the rest of dependencies with the "optional" text following the dependency name. See for example https://crates.io/crates/tokio.

@zoechi
Copy link

zoechi commented Mar 25, 2020

I stumbled upon this with refinery, barrel, diesel.
The features change often with new versions and are therefore cumbersome to discover in GitHub.
They should be easily processable automatically instead of maintaining them in the README.md because they are listed in Cargo.toml https://github.com/diesel-rs/diesel/blob/master/diesel/Cargo.toml#L45-L60

@pravic
Copy link

pravic commented Jul 9, 2020

lib.rs shows available features, by the way.

@Ekleog
Copy link

Ekleog commented Jan 16, 2024

This seems to actually already be implemented: on the versions page for a crate (eg. here, if you hover over the "1 feature" text, you can see the list of features exposed. It's missing optional dependencies, but OTOH I guess it makes sense that it wouldn't consider each optional dependency as though it were a feature by default :)

Now I guess the question is, is it discoverable enough.

@kikijiki
Copy link

kikijiki commented May 11, 2024

This seems to actually already be implemented: on the versions page for a crate (eg. here, if you hover over the "1 feature" text, you can see the list of features exposed. It's missing optional dependencies, but OTOH I guess it makes sense that it wouldn't consider each optional dependency as though it were a feature by default :)

Now I guess the question is, is it discoverable enough.

That's how I was doing it too, but when there are lots of features it gets pretty hard to use (e.g. https://crates.io/crates/windows/versions vs https://lib.rs/crates/windows/features).
Also you cannot select the text for copying to the clipboard, which is a bit frustrating. Would be nice if the list was just visible (maybe collapsed by default).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement ✨ Category: Adding new behavior or a change to the way an existing feature works
Projects
None yet
Development

No branches or pull requests

10 participants