Rollup merge of #37190 - QuietMisdreavus:rustdoc-where-newline, r=GuillaumeGomez

rustdoc: add line breaks to where clauses a la rustfmt

Much like my last PR for rustdoc (#36679), this adds line breaks to certain statements based on their line length. Here the focus was on where clauses.

Some examples:
- [Where clause in a trait function](https://shiva.icesoldier.me/custom-std/std/iter/trait.Iterator.html?search=#method.unzip) (also in the trait header block at the top of the page)
- [Where clause on a bare function](https://shiva.icesoldier.me/doc-custom2/petgraph/visit/fn.depth_first_search.html)
- [Where clauses in trait impls on a struct](https://shiva.icesoldier.me/custom-std/std/collections/struct.HashMap.html) (scroll to the bottom) These are regularly not on their own line, but will be given their own line now if their "prefix text" doesn't give them enough room to sensibly print their constraints. HashMap's trait impls provide some examples of both behaviors.

The libstd links above are the whole docs rendered with this, and the "bare function" link above is in another set that pulls some notable crates together. `petgraph` was the one that brought this request up, and that collection also includes [itertools](https://shiva.icesoldier.me/doc-custom2/itertools/trait.Itertools.html) which provided an easy sample to test with.

r? @GuillaumeGomez
This commit is contained in:
Eduard-Mihai Burtescu
2016-11-12 10:38:36 +02:00
committed by GitHub
4 changed files with 156 additions and 52 deletions

View File

@@ -361,9 +361,17 @@ h4 > code, h3 > code, .invisible > code {
position: relative;
}
/* Shift "where ..." part of method or fn definition down a line */
.content .method .where, .content .fn .where { display: block; }
.content .method .where,
.content .fn .where,
.content .where.fmt-newline {
display: block;
}
/* Bit of whitespace to indent it */
.content .method .where::before, .content .fn .where::before { content: ' '; }
.content .method .where::before,
.content .fn .where::before,
.content .where.fmt-newline::before {
content: ' ';
}
.content .methods > div { margin-left: 40px; }