about summary refs log tree commit diff
path: root/src/librustdoc/html/format.rs
AgeCommit message (Collapse)AuthorLines
2022-08-05rustdoc: reduce the number of intermediate Strings allocatedMichael Howell-1/+1
2022-07-19Improve the function pointer docsMichael Howell-6/+26
* Reduce duplicate impls; show only the `fn (T)` and include a sentence saying that there exists up to twelve of them. * Show `Copy` and `Clone`. * Show auto traits like `Send` and `Sync`, and blanket impls like `Any`.
2022-07-17rustdoc: extend `#[doc(tuple_variadic)]` to fn pointersMichael Howell-1/+14
The attribute is also renamed `fake_variadic`.
2022-07-13Auto merge of #99066 - est31:remove_box_librustdoc, r=jshabors-6/+8
Remove most box syntax from librustdoc This is the second attempt after the librustdoc specific changes have been reverted from #87781 in #89134, due to a minor, but exant regression caused by the changes. ~~There have been some changes to librustdoc in the past and maybe thanks to them there is no regression any more. If there is still a regression, one can investigate further and maybe find ways to fix the regressions. Thus, i request a perf run.~~ Edit: turns out there is still a regression, but it's caused only by a subset of the changes. So I've changed this PR to only contains the changes that don't cause any performance regressions, keeping the regression causing changes for a later PR.
2022-07-11Remove box syntax from Box<dyn Iterator> constructionest31-6/+8
The iterators created should be pretty light weight.
2022-07-07Replace boolean argument for print_where_clause with an enum to make code ↵Guillaume Gomez-4/+10
more clear
2022-07-05Fix invalid add of whitespace when there is where clauseGuillaume Gomez-0/+4
2022-07-02Remove unwanted trailing whitespaces for long declarationsGuillaume Gomez-8/+4
2022-06-20Fix panic by checking if `CStore` has the crate data we want before actually ↵Guillaume Gomez-6/+14
querying it
2022-06-20Integrate `generate_macro_def_id_path` into `href_with_root_path`Guillaume Gomez-1/+70
2022-06-20Add support for macro in "jump to def" featureGuillaume Gomez-0/+1
2022-06-19Rollup merge of #98105 - notriddle:notriddle/tuple-links, r=jshaDylan DPC-10/+34
rustdoc: remove tuple link on round braces This is #98069 but for tuples. The reasoning is the same: * This PR also changes it so that tuples with all-generic elements still link to the primitive.tuple.html page, just like slices. So there still plenty of on-ramps for anybody who doesn't know about it. * It's too hard to see when round braces are a separate link from the type inside of them. * It's too hard to click even if you do notice them. Before: * impl [ToSocketAddrs](https://doc.rust-lang.org/nightly/std/net/trait.ToSocketAddrs.html) for [(](https://doc.rust-lang.org/nightly/std/primitive.tuple.html)[IpAddr](https://doc.rust-lang.org/nightly/std/net/enum.IpAddr.html), [u16](https://doc.rust-lang.org/nightly/std/primitive.u16.html)[)](https://doc.rust-lang.org/nightly/std/primitive.tuple.html) * impl<K, V> [FromIterator](https://notriddle.com/notriddle-rustdoc-test/std/iter/trait.FromIterator.html)<[(](https://notriddle.com/notriddle-rustdoc-test/std/primitive.tuple.html)K, V[)](https://notriddle.com/notriddle-rustdoc-test/std/primitive.tuple.html)> for [BTreeMap](https://notriddle.com/notriddle-rustdoc-test/std/collections/struct.BTreeMap.html)<K, V> After: * impl [ToSocketAddrs](https://doc.rust-lang.org/nightly/std/net/trait.ToSocketAddrs.html) for ([IpAddr](https://doc.rust-lang.org/nightly/std/net/enum.IpAddr.html), [u16](https://doc.rust-lang.org/nightly/std/primitive.u16.html)) * impl<K, V> [FromIterator](https://notriddle.com/notriddle-rustdoc-test/std/iter/trait.FromIterator.html)<[(K, V)](https://notriddle.com/notriddle-rustdoc-test/std/primitive.tuple.html)> for [BTreeMap](https://notriddle.com/notriddle-rustdoc-test/std/collections/struct.BTreeMap.html)<K, V>
2022-06-16Auto merge of #97842 - notriddle:notriddle/tuple-docs, r=jsha,GuillaumeGomezbors-3/+19
Improve the tuple and unit trait docs * Reduce duplicate impls; show only the `(T,)` and include a sentence saying that there exists ones up to twelve of them. * Show `Copy` and `Clone`. * Show auto traits like `Send` and `Sync`, and blanket impls like `Any`. Here's the new version: * <https://notriddle.com/notriddle-rustdoc-test/std/primitive.tuple.html> * <https://notriddle.com/notriddle-rustdoc-test/std/primitive.unit.html>
2022-06-14rustdoc: change "variadic tuple" notation to look less like real syntaxMichael Howell-1/+1
2022-06-14rustdoc: remove tuple link on round bracesMichael Howell-10/+34
This is 682889fb06591c4245422b73b005c5d8ae2d0cad but for tuples. The reasoning is the same: * This commit also changes it so that tuples with all-generic elements still link to the primitive.tuple.html page, just like slices. So there still plenty of on-ramps for anybody who doesn't know about it. * It's too hard to see when round braces are a separate link from the type inside of them. * It's too hard to click even if you do notice them.
2022-06-13rustdoc: remove link on slice bracketsMichael Howell-27/+2
Since #97668 was merged, the slice::get function now looks like this: ![image](https://user-images.githubusercontent.com/1593513/173430685-1dd2b275-2439-4392-b7d4-96bcb355a377.png) That whole thing, `[T]`, is a single link to `primitive.slice.html`. This definitely fixes it for this case, but it's not obvious what we should do for slices of concrete types: ![image](https://user-images.githubusercontent.com/1593513/173430968-7eed1aec-b688-4f84-a492-9210aff0037a.png) There are actually three links in that `[u8]`: the opening brace `[` is a link to `primitive.slice.html`, the `u8` is a link to `primitive.u8.html`, and the final `]` is a link to `primitive.slice.html`. This is a serious [usability bug](https://usability.yale.edu/web-accessibility/articles/links): the square braces are much too small for anyone who doesn't have perfect motor control using mouse or touch, provide an excessive number of tab stops for anyone using keyboard, and no visual indication whatsoever that they're separate links. Now that slices of generic types are linked, it seems reasonable to err on the side of less clutter and stop linking concrete slices to the slice page.
2022-06-11Add test case for #trait-implementations-1 linkMichael Howell-0/+2
2022-06-11Fix incorrectly spelled "variadic"Michael Howell-1/+1
2022-06-08rustdoc: show tuple impls as `impl Trait for (T, ...)`Michael Howell-3/+17
This commit adds a new unstable attribute, `#[doc(tuple_varadic)]`, that shows a 1-tuple as `(T, ...)` instead of just `(T,)`, and links to a section in the tuple primitive docs that talks about these.
2022-06-02rustdoc: clean up primitive.slice.html linksMichael Howell-22/+16
2022-05-24fix clippy perf lintsklensy-10/+13
2022-05-24fix simple clippy lintsklensy-8/+5
2022-05-22Clean up `&args[..]`, use more readable `args.iter()` insteadMichael Howell-3/+3
2022-05-21Shrink GenericArgs/PathSegment with boxed slicesMichael Howell-3/+3
2022-05-21Auto merge of #93963 - GuillaumeGomez:reduce-clean-type-size, r=notriddlebors-5/+1
rustdoc: Reduce clean::Type size There is no need to keep the `DefId` around since it's allow used to compute if we should show a cast or not. As such, we can simply directly store the boolean. I think it's not what you had in mind `@camelid` but I guess it's still an improvement? :wink: It was discussed in https://github.com/rust-lang/rust/pull/93941. r? `@camelid`
2022-05-21Remove `crate` visibility modifier in libs, testsJacob Pratt-47/+55
2022-05-15Reduce clean::Type size by replacing a DefId (only used to check for ↵Guillaume Gomez-5/+1
display) with a boolean
2022-05-02rustc: Panic by default in `DefIdTree::parent`Vadim Petrochenkov-1/+1
Only crate root def-ids don't have a parent, and in majority of cases the argument of `DefIdTree::parent` cannot be a crate root. So we now panic by default in `parent` and introduce a new non-panicing function `opt_parent` for cases where the argument can be a crate root. Same applies to `local_parent`/`opt_local_parent`.
2022-04-25rustdoc: do not write `{{root}}` in `pub use ::foo` docsMichael Howell-1/+2
2022-04-20rustdoc: Clean up `html::format::print_where_clause`Roc Yu-70/+62
2022-04-19Rollup merge of #95813 - Urgau:rustdoc-where-clause-space, r=GuillaumeGomezDylan DPC-1/+2
Remove extra space before a where clause Remove extra space before where clause in the generated documentation. The fix is to move the space before the break-line so that it doesn't appear visually but is still here. Removing it completely would create things like this `impl<D> Delta<D>where D: MyTrait` (missing a space before the where) which I don't think we want. Added two regression test, first one test that the `<br>` is after the space and the second check that the `<br>` is before the spaces. Before: ![image](https://user-images.githubusercontent.com/3616612/162475212-d4bb6727-ed66-4a55-a4a2-4f55189bf8bd.png) After: ![image](https://user-images.githubusercontent.com/3616612/162475467-508fd082-60a7-4a8c-b693-8b188e8843e6.png) r? ``@GuillaumeGomez``
2022-04-17Stop using CRATE_DEF_INDEX.Camille GILLOT-3/+2
`CRATE_DEF_ID` and `CrateNum::as_def_id` are almost always what we want.
2022-04-17Remove extra space before a where clause in the documentationLoïc BRANSTETT-1/+2
2022-04-12rustdoc: discr. required+provided assoc consts+tysLeón Orell Valerian Liehr-0/+15
2022-03-11Auto merge of #94304 - notriddle:notriddle/buffer-args, r=CraftSpiderbors-27/+19
rustdoc: write directly to buffer in `inner_full_print` This change avoids several temporary allocations for every argument.
2022-03-06Rollup merge of #93412 - fee1-dead:improve-rustdoc-const-bounds, ↵Matthias Krüger-72/+85
r=GuillaumeGomez Improve rustdoc const bounds - Rustdoc no longer displays `~const` in trait bounds, because it currently means nothing for stable users, and because we still haven't decided on the final syntax yet. - Rustdoc will hide trait bounds where the trait is `Drop` AND it is `~const`, i.e. `~const Drop` bounds because it has no effect on stable users as well. - Because of additional logic that hides the whole `where` statement where it consists of `~const Drop` bounds (so it doesn't display `struct Foo<T>() where ;` like that), bounds that have no trait e.g. `where [T; N+1]: ;` are also hidden. Cherry-picked from #92433.
2022-03-03make generic projection types print correctlyMichael Goulet-5/+11
2022-02-23rustdoc: write directly to buffer in `inner_full_print`Michael Howell-27/+19
This change avoids several temporary allocations for every argument.
2022-02-22Address review commentsDeadbeef-10/+10
2022-02-22Bless rustdoc testDeadbeef-84/+82
2022-02-22Do not display hidden `~const Drop` boundsDeadbeef-5/+19
2022-02-22Do not display ~const in rustdocDeadbeef-1/+2
2022-02-03rustdoc: clippy::complexity fixesMatthias Krüger-1/+1
clippy::map_flatten clippy::clone_on_copy clippy::useless_conversion clippy::needless_arbitrary_self_type
2022-02-01librustdoc: inline and forward all methods for `impl Write for Buffer`Muhammad Falak R Wani-0/+11
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2022-02-01librustdoc: impl core::fmt::Write for rustdoc::html::render::BufferMuhammad Falak R Wani-0/+6
Signed-off-by: Muhammad Falak R Wani <falakreyaz@gmail.com>
2022-01-17Update term for use in more placeskadmin-3/+15
Replace use of `ty()` on term and use it in more places. This will allow more flexibility in the future, but slightly worried it allows items which are consts which only accept types.
2022-01-14Estimate path length instead of hardcoding 64 bytesNoah Lev-2/+2
2022-01-14Use UrlPartsBuilder and remove `join_with_slash`Noah Lev-22/+0
2022-01-14rustdoc: remove some unnecessary sigils.Nicholas Nethercote-1/+1
2022-01-14rustdoc: avoid many `Symbol` to `String` conversions.Nicholas Nethercote-39/+82
Particularly when constructing file paths and fully qualified paths. This avoids a lot of allocations, speeding things up on almost all examples.