-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Add --extend-css option to rustdoc #32230
Conversation
I would prefer we not land any new insta-stable options into rustdoc. We've already got infrastructure in the compiler for truly unstable options, and rustdoc should likely adopt a similar strategy. |
"insta-stable"? "truly unstable"? Sorry but I don't understand these two points. Could you explain them please? (Or give me a link?) |
Yes, to clarify I mean:
|
@alexcrichton: I updated the code. Does this check seems enough for you? |
No, the compiler has the ability to specify options with a stability level attached to them. The options are always parsed but any usage of an unstable option is gated. That's functionally what happens here but it's very brittle as it'd be tied to each option specifically. All of this is also with a grain of salt as well, as we still have yet to make a decision at all as to whether to allow custom css like this. I thought that in previous PRs we decided not to? |
@alexcrichton: In the PR you're referring to, I tried to propose alternative style by providing css and to allow readers to switch between themes while reading the docs. This one is very different since it targets docs builders, and allow them to customize the css. I exposed the idea to @brson and he said it was ok (at least to open the PR). The thing I understood rust people didn't want was to change the official doc style. This one doesn't change it. PS: if this PR goes further, where can I find a "gated" option, so I can do the same for this one? |
@GuillaumeGomez it sounds like we need to add feature gating to rustdoc. Here's basically what we need to do:
Here's the equivalent code that deals with command-line feature gating in rustc. This is similar to the code you've previously added to make Sorry for the inconvenience. |
Oh I see, I thought a full code suite was made for it. Thanks @brson! |
f780790
to
f08e4b4
Compare
@@ -187,6 +189,7 @@ pub fn opts() -> Vec<getopts::OptGroup> { | |||
optopt("e", "extend-css", | |||
"to redefine some css rules with a given file to generate doc with your \ | |||
own theme", "PATH"), | |||
optmulti("Z", "", "enable unstable options (only on nightly build)", "FLAG"), |
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.
Could the text here be "internal and debugging options" to more closely match rustc? -Z
isn't just for the unstable-options
flag (in theory).
f08e4b4
to
70d444b
Compare
fn is_unstable_flag_enabled(nightly_build: bool, has_z_unstable_options: bool, | ||
flag_name: &str) { | ||
// check if unstable for --extend-css option | ||
match if !nightly_build { |
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.
nit:
- maybe this could just be a
let
instead ofmatch
and early return in theelse
case? - could this function be named
check_*
? Withis_*
I'd expect a bool return value.
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.
maybe this could just be a let instead of match and early return in the else case?
Good idea.
could this function be named check__? With is__ I'd expect a bool return value.
At first, it was supposed to. I'll rename it.
70d444b
to
52f791e
Compare
@GuillaumeGomez I'm going to have to discuss this with the tools team since I'm getting significant pushback about adding the feature to rustdoc. I'll have to get back to you, but Ill try to it soon. |
From a technical point of view I think that this also needs some refactoring. The compiler has support for directly attaching a stability level to a command line option, and this is just an ad-hoc check whenever a command line option is consumed. Additionally, this is essentially duplicating the infrastructure in the compiler for this feature, and ideally we would not duplicate any of it. |
@alexcrichton: This is frustrating to stop new things to emerge because of such missing mechanisms. However I understand so I can only agree to your opinion. Would you prefer that I create (or extend opts?) a common code for this? |
Do we have a stability policy for tools like rustdoc? I did not think that we offered stability guarantees of any kind for rustdoc. I guess maybe it is wrapped up in the fact that rustdoc is in the main repo, not the nursery or something? I don't think we've ever audited the existing options, maybe we should (quite likely I just missed it if we have though). Anyway, I'm strongly in favour of this PR. I guess it should be unstable, but I don't feel like stability for rustdoc is super-important (c.f., the compiler). |
It's also frustrating to have code duplication within the project which causes subtle bugs to emerge in the future because they're not behaving the same way or because one was fixed without the other. I would recommend refactoring whatever's in rustc so it's usable between both the compiler and rustdoc.
Perhaps not written down, but do we have one written down for rustc? I'm under the assumption that it's basically almost all entirely stable today. We did a brief audit of compiler flags before 1.0, but we just didn't really have the effort or time to do it for rustdoc as well. |
@alexcrichton: Before doing anything, I prefer wait the end of the debate so I don't work for nothing. |
There seems to be enough support for this feature that we probably want to land it in some capacity, so if the unstable gating works robustly as the compiler does then this is likely ready to r+ |
@alexcrichton: Do you want me to directly centralize this "feature" on this PR or do you prefer I open another one? |
Let's do it as part of this PR as it'll just otherwise conflict |
@alexcrichton: Done. Is it what you had in mind? |
Any news? |
☔ The latest upstream changes (presumably #32390) made this pull request unmergeable. Please resolve the merge conflicts. |
d87e307
to
9fe7092
Compare
85f5449
to
dff79e4
Compare
So the code is now the same as the previous one, just moved from another place. |
@bors: r+ dff79e4e3a1e975011f1181e175b4e902c481809 |
🔒 Merge conflict |
dff79e4
to
3665ba0
Compare
@bors: r+ 3665ba08cf38585466b57f696efc434024b8b3f4 |
⌛ Testing commit 3665ba0 with merge 541a166... |
💔 Test failed - auto-mac-64-opt-rustbuild |
3665ba0
to
d0a91a3
Compare
@@ -99,6 +99,9 @@ pub struct Context { | |||
/// publicly reused items to redirect to the right location. | |||
pub render_redirect_pages: bool, | |||
pub shared: Arc<SharedContext>, | |||
/// The given user css file which allow to customize the generated | |||
/// documentation theme. | |||
pub css_file_extension: Option<PathBuf>, |
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.
I think this is redundant now that this is also in SharedContext
?
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.
The issue comes from the fact that this option must be used in both Context
and SharedContext
. I tried to have it only in SharedContext
but the code started to change way too much compared to the "gain".
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.
Can't you do cx.shared.css_file_extension
?
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.
Oh, indeed. Modified too quickly.
d0a91a3
to
669edfa
Compare
Re-updated to last rustdoc version. |
⌛ Testing commit 669edfa with merge a828124... |
💔 Test failed - auto-mac-32-opt |
Why is there a line longer than 100 chars in |
@bors: retry On Wed, Apr 6, 2016 at 1:32 PM, Guillaume Gomez [email protected]
|
Fixes #32223
r? @brson