rustdoc: Only include a stability span if needed.
This patch gets rid of the empty stability boxes in docs by only including the span that creates it when the item actually has a stability class.
Here are images of the issue on `std::process::Output`:
Before:
<img width="340" alt="before" src="ff88d1b2-f010-11e6-90d6-bf3d10e2fffa.png">
After:
<img width="333" alt="after" src="06bfe7cc-f011-11e6-9892-f0ea2cc6ec90.png">
This is my first non-trivial patch to Rust, so I'm sure some of my approach is not idiomatic. Let me know how you'd like me to adjust!
rustdoc: Show attributes on all item types
Currently attributes are only shown for structs, unions and enums but
they should be shown for all items. For example it is useful to know if a
function is `#[no_mangle]`.
Currently attributes are only shown for structs, unions and enums but
they should be shown for all items. For example it is useful to know if a
function is `#[no_mangle]`.
* Don't disambiguate if there are multiple impls for the same type.
* Disambiguate for impls of &Foo and &mut Foo.
* Don't try to disambiguate generic types.
rustdoc: escape the deprecated and unstable reason text
Fix#38220.
Instead of the [current output](https://doc.rust-lang.org/std/boxed/trait.FnBox.html):
<img width="967" alt="incorrect unescaped unstable reason in docs" src="73121d42-bd2f-11e6-8076-8a5127dbc010.png">
display:
<img width="979" alt="escaped unstable reason in docs" src="52eb0f88-bd2f-11e6-9088-58bdc7d92328.png">
When an item is defined in an external macro it doesn't get a real
filename so we need to filter out these when generating src links for
reexported items.
rustdoc: Sort lines in search index and implementors js
This means the files are generated deterministically even with rustdoc running in parallel.
Fixes the first part of #30220.
rustdoc: get back missing crate-name when --playground-url is used
follow up PR #37763
r? @alexcrichton (since you r+ed to #37763 )
----
Edit: When `#![doc(html_playground_url="")]` is used, the current crate name is saved to `PLAYGROUND`, so rustdoc may generate `extern crate NAME;` into code snips automatically. But when `--playground-url` was introduced in PR #37763, I forgot saving crate name to `PLAYGROUND`. This PR fix that.
----
Update:
- add test
- unstable `--playground-url`
rustdoc: Remove unnecessary stability versions
For some reason only on enum and macro pages, the stability version is
rendered after the summary unlike all other pages. As it is already
displayed at the top of the page for all items, this removes it for
consistency and to prevent it from overlapping the summary text.
Fixes#36093
For some reason only on enum and macro pages, the stability version is
rendered after the summary unlike all other pages. As it is already
displayed at the top of the page for all items, this removes it for
consistency and to prevent it from overlapping the summary text.
rustdoc: add cli argument `--playground-url`
Add a new cli argument `--playground-url` for rustdoc:
`rustdoc lib.rs --playground-url="https://play.rust-lang.org/"`
`rustdoc book.md --playground-url="https://play.rust-lang.org/"`
This makes it possible for tools like https://docs.rs to generate crate docs that can submit samples code to run at https://play.rust-lang.org, even if the crate's author *forgot* putting `#![doc(html_playground_url = "https://play.rust-lang.org/")]` to crate root. By the way, I'd like to say, many crate authors are not aware of existing of `#![doc(html_playground_url = "https://play.rust-lang.org/")]`.
`--playground-url` may be reset by `--markdown-playground-url` or `#![doc(html_playground_url=...)]`, so it's backward compatible.
@alexcrichton since you implemented playground-url related features.
rustdoc: Fix some local inlining issues
* Only inline public items when inlining glob imports.
* Never inline while in a private module or a child of a private module.
* Never inline impls. This allowed the removal of a workaround in the
rendering code.
* Only inline public items when inlining glob imports.
* Never inline while in a private module or a child of a private module.
* Never inline impls. This allowed the removal of a workaround in the
rendering code.
rustdoc: fold fields for enum struct variants into a docblock
Per discussion in #37500, this PR updates the enum rendering code to wrap variants with named struct fields in a `docblock` span that is hidden automatically upon load of the page. This gives struct variant fields a clean separation from other enum variants, giving a boost to the readability of such documentation. Preview output is available [on the issue page](https://github.com/rust-lang/rust/issues/37500#issuecomment-260069269), but for the sake of completeness I'll include the images here again.

When you initially load the page, there's a line under variants with struct fields letting you know you can click to expand the listing.

If you click to expand, the header and table unfold into a nicely-indented listing.
If you want to take a look in your own browser and screen size, [I've got this version hosted on my server](https://shiva.icesoldier.me/doctest/doctest/enum.OldTopicRemoval.html).
Fixes#37500
r? @GuillaumeGomez