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

Rustdoc: odd wrapping in code blocks #41025

Closed
ghost opened this issue Apr 2, 2017 · 4 comments · Fixed by #41084
Closed

Rustdoc: odd wrapping in code blocks #41025

ghost opened this issue Apr 2, 2017 · 4 comments · Fixed by #41084
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@ghost
Copy link

ghost commented Apr 2, 2017

Link to docs: https://doc.rust-lang.org/nightly/std/borrow/trait.Borrow.html
How it looks on my machine:

Notice the space before {. Also, that indentation: where is seemingly indented by two spaces, while fn is indented by four. However, if I copy the code and paste here, it looks normal:

pub trait Borrow<Borrowed> where Borrowed: ?Sized {
    fn borrow(&self) -> &Borrowed;
}
@steveklabnik
Copy link
Member

/cc @QuietMisdreavus

@steveklabnik steveklabnik added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Apr 3, 2017
@QuietMisdreavus
Copy link
Member

I'm in the process of modifying rustdoc's formatting to match the fmt-rfcs for where clauses and function definitions. The indentation of the top-level where clause should be modified by this change, but it looks like I still need to look into why that's getting an extra space before that one curly braace. For reference, here's what it looks like on my local rustdoc:

rustdoc new borrow format

@QuietMisdreavus
Copy link
Member

Note to self: This is because item_trait in src/librustdoc/html/render.rs prints a space after the leading where clause, regardless of whether it exists. But if it exists, then the where clause itself prints a newline. The space is there so that traits without where clauses can put their opening brace on the same line as the trait name.

@bluss
Copy link
Member

bluss commented Apr 3, 2017

It looks like the pre blocks on top of struct/trait pages now use where with display: block; which I think was an unintended change (intended only for method items).

bors added a commit that referenced this issue Apr 9, 2017
…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:

![std::iter::IntoIterator](https://cloud.githubusercontent.com/assets/5217170/24712947/e586604c-19e9-11e7-87ae-4fe64d689dc3.png)

![excerpt from std::iter::Iterator](https://cloud.githubusercontent.com/assets/5217170/24713209/91e65112-19ea-11e7-9ff8-d4cf6b31aae1.png)

![std::iter::FromIterator](https://cloud.githubusercontent.com/assets/5217170/24713138/59f36114-19ea-11e7-9dbb-5f5ba7126e2e.png)

![std::cmp::min](https://cloud.githubusercontent.com/assets/5217170/24713038/1bab88b4-19ea-11e7-935d-defed5648de4.png)

![some trait impls on std::collections::HashMap](https://cloud.githubusercontent.com/assets/5217170/24713251/b7ef69e8-19ea-11e7-94a7-e01fbf89fa31.png)

![`fn extract_code_blocks`, an example given in #40687](https://cloud.githubusercontent.com/assets/5217170/24713159/672717cc-19ea-11e7-9acb-6ac278b90339.png)

![excerpt from itertools::Itertools](https://cloud.githubusercontent.com/assets/5217170/24713323/f06716ea-19ea-11e7-94cc-6ef68d9980ec.png)

fixes #41025 and #40687

r? @rust-lang/docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
3 participants