-
Notifications
You must be signed in to change notification settings - Fork 198
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
frontend: Show feature flags in topbar and separate page #1144
Conversation
From my point of view it's useful to know which feature gets enabled by which flag. Especially for default. On the other hand it would be useful to have at least something to show and the detail can be added later on. |
I also prefer having the features that are enabled shown. |
I think we should show full detail, but on a separate page (placed alongside |
Made a very rough and out of proportion sketch of what I'm thinking, display the available features on the left, clicking on each "maximizes" it to show all the features and dependencies it activates. This allows us to give as much info as possible (ex. saying if the feature is actually a feature or just an optional dependency) without immediately overwhelming the user. |
7d69c80
to
dbbd70b
Compare
I like it! It could be nice to split it into columns like @pietroalbini suggested, but I don't think we need to block on that. |
dbbd70b
to
008a04a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for sticking with this :)
So far features were stored only in database. Add link to the topbar which will lead to the new features page. Features page will show all relevant features with their subfeatures.
008a04a
to
2df55ef
Compare
@almusil it's not a big deal, but in the future it would be nice to add changes as additional commits instead of force-pushing. The diff github shows also includes the changes from master. Fortunately here there weren't many changes, but in a big repo like rust-lang/rust it would be unreadable. (FWIW I consider this a bug in github isaacs/github#1834) |
Ah right, the ugly thing about this is that every repo has different policy. I'll keep it in mind for future changes in this repo, thanks :) |
Show different page for empty feature flags and null feature flags.
acb70af
to
902515f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This already looks really good and I'm happy to merge it as is :) Some improvements I'd like to see at some point:
- Right now the features look like they're unordered:
Could we change it to put features that enable other features first? Or we could get really fancy and do a tree structure, where we putdefault -- [std, perf, unicode]
, then std, then perf, then unicode, then, recursively, features that are enabled by std/perf/unicode. - We don't distinguish between optional dependencies and features. Could we add that?
- @Nemo157 I think you mentioned a while back you wouldn't want this for your crates - do you still want to add an opt-out to
package.metadata.docs.rs
? - Could we add some color? Maybe green for
default
, red for features that enable other features, black otherwise, something like that?
I would, but I wouldn't want to block this on that being added. I did run across a bug in the feature recording while looking at it though, |
templates/crate/features.html
Outdated
{%- if metadata.features -%} | ||
<p>This version has <b>{{ metadata.features | length }}</b> feature flags, <b data-id="default-feature-len"> | ||
{%- if metadata.features[0].name == 'default' -%} | ||
{{ metadata.features[0].subfeatures | length }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This count is wrong when one of the default features activates more features. In bs58 0.4.0
I have default = ["std"]
and std = ["alloc"]
.
Also I think the previous count should be decreased by 1 (if the crate has a default
feature), otherwise a crate which activates all its features by default will still say something like "This version has 5 feature flags, 4 of them enabled by default" because default
is not counted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
async-compression 0.3.6
I was trying it locally and I can see both tokio-02
and tokio-03
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the renamed dependency issue is unrelated to this UI I opened #1175 for it.
@almusil if you can fix the bugs Nemo noticed and address my nit I think this is good to merge. The rest can be fixed in follow-ups. |
Order features that are enabled by default in flat tree structure. At the same time report correct number of features being enabled by default.
33bdd95
to
1937862
Compare
88890a7
to
04e3ce3
Compare
let result = order_features_and_count_default_len(raw); | ||
features = Some(result.0); | ||
default_len = result.1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rust-lang/rust#71156 would help with this :) 'coming soon to rust versions near you'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will be nice :)
By making it more modular it is easier to add unit tests fro current behavior.
04e3ce3
to
6730aa2
Compare
I think further improvements can be done in follow-ups. Thanks so much for working on this, I've wanted this in docs.rs for a while ❤️ |
Happy to help :) Thank you for your patience. If you don't mind I would like to continue with improvements to this feature. |
Sounds great! If you want to talk about ideas we have a discord channel for docs.rs |
This patch changes one detail implemented in rust-lang#1144. The features flag sorting was by "number of subfeatures". Now it by feature alphabetically. It also ensure that the "default" feature stays on top of the list.
As discussed in #1129. Opening the frontend part for discussion.
Current implementation look: