-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Rustdoc: Visual indentation of function return type looks funky #40687
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
Comments
pub fn extract_code_blocks<'md, I: Iterator<Item=Event<'md>>>(
md_events: I)
-> Result<Vec<CodeBlock>, Error> I propose this one (because I don't like when |
After some discussion in #rust-docs, I noticed that the first style mentioned is pretty close to how the fmt-rfcs issue about function signatures wound up. It's also suspiciously close to my initial implementation when I first put that indentation code in. I'll see about sketching out this change. |
That first alternative is in fact block indentation which is what that rustfmt RFC agreed on. As a result, rustdoc should reflect that decision and switch to block indentation for all function definitions in generated documentation. |
@QuietMisdreavus: Since you're already on it, try to catch up the format RFC. :) |
I'd say go for it, the currently agreed upon style is described out here, or in this example. |
…cxv,GuillaumeGomez rustdoc: update formatting of fn signatures and where clauses to match style rfcs Recent updates to style RFCs ([where clauses](rust-lang/style-team#38), [function definitions](rust-lang/style-team#39)) changed the "canonical" style for these items, so this is a rustdoc update to make it emit that style where necessary. This is mainly a conversion from visual indent to block indent, which helps out in situations where there was excessive indent causing lines to wrap regardless. Samples:        fixes #41025 and #40687 r? @rust-lang/docs
I have a function with this signature:
So far so good. In the original source, it's all on one line, but Rustdoc uses quite a large font, so it makes sense to split it up. The problem is with the way it tries to reformat the signature, i.e., by putting the return type directly beneath the opening bracket of the arguments:
And while it doesn't look great on a wide screen, resizing the window makes it look just broken:
To get a good idea how to format functions it might be wise to check the discussion of the fmt team in rust-lang/style-team#39, but I don't think Rustdoc has the same constraints as rustfmt.
In particular, I would render the function signature quoted above as:
alternatively,
or even (introducing where clauses):
The text was updated successfully, but these errors were encountered: