Michael Howell
3a79370367
rustdoc: use better highlighting for *const, *mut, and &mut
...
This generates more consistent HTML for these RefKeyWord combinations.
Before:

After:

2021-10-25 11:13:43 -07:00
Guillaume Gomez
345519baa7
Fix scrollbars appearing on information tooltip on mac when they shouldn't
2021-10-25 11:40:13 +02:00
Matthias Krüger
b837605012
Rollup merge of #90155 - jsha:outdent-methods, r=GuillaumeGomez,camelid
...
Fix alignment of method headings for scannability
We sometimes use indentation to indicate something is a heading: The section that comes after is indented by 24px relative to the heading. However, the relationship between the "Implementations" section heading, the `impl` headings it contains, and the `pub fn` subheadings within each impl, is awkward. It goes **Implementations**, 15px indent, `impl`, 5px indent, `pub fn`, 4px indent, docblock.
I line up `impl` and `pub fn` with the `Implementations` heading, give `impl` a larger font size to indicate it is higher in the hierarchy, and indent the docblock a full 24px relative to their parent, matching the indents we use elsewhere to distinguish section headings. By letting the `pub fn` stick out to the left of the docblock, I think this makes methods significantly more scannable.
Related to #59829
r? `````@camelid`````
[Old](https://doc.rust-lang.org/nightly/std/string/struct.String.html#implementations ):
[](https://doc.rust-lang.org/nightly/std/string/struct.String.html#implementations )
[New](https://jacob.hoffman-andrews.com/rust/outdent-methods/std/string/struct.String.html#implementations ):
[](https://jacob.hoffman-andrews.com/rust/outdent-methods/std/string/struct.String.html#implementations )
2021-10-24 15:48:44 +02:00
Jacob Hoffman-Andrews
542ab2daa6
Outdent method headings so they stand out
...
The makes the heading / documentation distinction clearer.
2021-10-23 11:50:11 -07:00
Matthias Krüger
dcf9242795
Rollup merge of #85833 - willcrichton:example-analyzer, r=jyn514
...
Scrape code examples from examples/ directory for Rustdoc
Adds support for the functionality described in https://github.com/rust-lang/rfcs/pull/3123
Matching changes to Cargo are here: https://github.com/rust-lang/cargo/pull/9525
Live demo here: https://willcrichton.net/example-analyzer/warp/trait.Filter.html#method.and
2021-10-23 14:58:39 +02:00
Will Crichton
fd5d614b77
Move def_id logic into render_call_locations
2021-10-22 13:14:46 -07:00
Will Crichton
d1c29c696e
Revert def_id addition from clean::Function, add test for
...
scrape-examples options
2021-10-22 12:46:45 -07:00
Will Crichton
8f80d86d85
Small scrape-example fixes
2021-10-19 20:08:30 -07:00
Yuki Okushi
570b999c96
Rollup merge of #90036 - jsha:less-rule, r=GuillaumeGomez
...
Remove border-bottom from most docblocks.
Headings in the top-doc docblock still get a border-bottom due to a rule
that covers all h2, h3, and h4. Method docblocks are generally h5, and
so don't get a border-bottom anymore.
This fixes a problem where a sub-sub-heading within a method would have
a line that went all the way across the page, creating a division that
made that sub-sub-heading look much more important than it really is.
Fixes #90033
Demo at https://jacob.hoffman-andrews.com/rust/less-rule/std/string/struct.String.html
r? ``@GuillaumeGomez``
2021-10-20 04:35:17 +09:00
Yuki Okushi
7ceab9ef14
Rollup merge of #90018 - GuillaumeGomez:too-long-item-names, r=jsha
...
Fix rustdoc UI for very long type names
Fixes #89972 .
While working on it, I also discovered that when the item name is too long, it also breaks the flow of the page.
To make things right, I also renamed the `type-decl` CSS class into `item-decl` (because this PR also generates it for more than type declarations).
So here are the before/after screenshots:




r? ``@jsha``
2021-10-20 04:35:15 +09:00
Jacob Hoffman-Andrews
e39934374a
Reduce margin on h5 and h6
2021-10-18 21:04:38 -07:00
Jacob Hoffman-Andrews
9aec3a0e5a
Remove border-bottom from most docblocks.
...
Headings in the top-doc docblock still get a border-bottom due to a rule
that covers all h2, h3, and h4. Method docblocks are generally h5, and
so don't get a border-bottom anymore.
This fixes a problem where a sub-sub-heading within a method would have
a line that went all the way across the page, creating a division that
made that sub-sub-heading look much more important than it really is.
2021-10-18 20:24:41 -07:00
Guillaume Gomez
809330bda6
Prevent documentation page title to grow too big
2021-10-18 15:30:03 +02:00
Guillaume Gomez
8b7a2dd462
* Remove left margin on items declaration at the top of their documentation page
...
* Rename "type-decl" into "item-decl" to reflect the change of usage
2021-10-18 15:06:38 +02:00
Matthias Krüger
c645d3f3b9
clippy::complexity changes
2021-10-16 18:11:16 +02:00
bors
7807a694c2
Auto merge of #89815 - GuillaumeGomez:associated-consts-sidebar, r=notriddle
...
Associated consts sidebar
Fixes #89354 .
A screenshot with `f32`:

2021-10-14 02:24:52 +00:00
Guillaume Gomez
38f6c07b11
Improve code readability for sidebar links
2021-10-13 21:58:55 +02:00
Guillaume Gomez
d6dbff56e4
List associated constants in the sidebar
2021-10-12 15:06:52 +02:00
Shinwoo Park
d2564ce5a9
rustdoc: update noto sans kr
2021-10-12 04:47:34 +09:00
Stefan Schindler
4bd7e965b2
Cleanup .item-table CSS
2021-10-11 10:53:48 +02:00
Matthias Krüger
bf01a59be5
Rollup merge of #89736 - GuillaumeGomez:rm-unused-css-rule, r=dns2utf8
...
Remove unused CSS rule
As you can see in the firefox devtools:

It needs the display to be `grid` or `inline-grid`, which isn't the case.
r? `@dns2utf8`
2021-10-11 00:34:41 +02:00
Matthias Krüger
3fa897df26
Rollup merge of #89632 - GuillaumeGomez:fix-docblock-code, r=jsha
...
Fix docblock code display on mobile
Fixes https://github.com/rust-lang/rust/issues/89618 .
Before:

After:

r? `@jsha`
2021-10-11 00:34:37 +02:00
Guillaume Gomez
5611b43d7f
Remove unused CSS rule
2021-10-10 14:27:36 +02:00
Guillaume Gomez
0bfac7f67f
Fix <code> blocks in doc blocks display on mobile
2021-10-10 13:30:56 +02:00
bors
c1cb97481a
Auto merge of #89695 - jsha:more-templates, r=GuillaumeGomez
...
Move top part of print_item to Tera templates
Part of #84419 .
This moves the first line of each item page (E.g. `Struct foo::Bar .... 1.0.0 [-][src]` into a Tera template.
I also moved template initialization into its own module and added a small macro to reduce duplication and opportunity for errors.
2021-10-10 04:41:03 +00:00
bors
a8f2463c68
Auto merge of #88379 - camelid:cleanup-clean, r=jyn514
...
rustdoc: Cleanup various `clean` types
Cleanup various `clean` types.
2021-10-09 19:05:08 +00:00
Jacob Hoffman-Andrews
d0a33fb175
Remove some stray whitespace.
2021-10-09 08:33:19 -07:00
Guillaume Gomez
3e93472aa5
Rollup merge of #89700 - GuillaumeGomez:fix-rustdoc-higher-bound-html-gen, r=notriddle
...
Fix invalid HTML generation for higher bounds
Considering this is a bug, I cherry-picked the commit from #89676 so it's merged more quickly.
r? ``@notriddle``
2021-10-09 17:08:41 +02:00
Guillaume Gomez
321425386a
Fix invalid HTML generation for higher bounds
2021-10-09 14:41:28 +02:00
Jacob Hoffman-Andrews
586a9cea75
Move template initialization into its own file.
2021-10-08 23:28:42 -07:00
Jacob Hoffman-Andrews
7a938005e1
Add template for print_item
...
Add print_item.html and the code in print_item.rs to use it.
2021-10-08 23:02:12 -07:00
Will Crichton
f10dceeae2
Change handling of spans in scrape examples, add test for highlight decorations
2021-10-08 15:32:22 -07:00
Guillaume Gomez
0cc123cbb3
Rollup merge of #89538 - notriddle:notriddle/arrow-highlight, r=GuillaumeGomez
...
Make rustdoc not highlight `->` and `=>` as operators
It was marking them up as `<span class="op">=</span><span class="op">></span>`,
which is bloaty and wrong (at least, I think `<=` and `=>` should probably be different colors, since they're so different and yet made from the same symbols).
Before:

After:

2021-10-08 22:30:39 +02:00
Will Crichton
e22e858687
Move more scrape-examples logic from JS to rust
...
Fix failing test
Add missing backslash
Fix padding issue with horizontal scrollbar
2021-10-08 11:14:01 -07:00
Will Crichton
bb383edb69
Move some expansion logic into generation-time, fix section header links, remove ID from line numbers, fix horizontal scrolling on non-expanded elements
2021-10-07 09:46:23 -07:00
Guillaume Gomez
e32328bdc5
Rollup merge of #89596 - GuillaumeGomez:implicit-doc-cfg, r=jyn514
...
Make cfg imply doc(cfg)
This is a reopening of #79341 , rebased and modified a bit (we made a lot of refactoring in rustdoc's types so they needed to be reflected in this PR as well):
* `hidden_cfg` is now in the `Cache` instead of `DocContext` because `cfg` information isn't stored anymore on `clean::Attributes` type but instead computed on-demand, so we need this information in later parts of rustdoc.
* I removed the `bool_to_options` feature (which makes the code a bit simpler to read for `SingleExt` trait implementation.
* I updated the version for the feature.
There is only one thing I couldn't figure out: [this comment](https://github.com/rust-lang/rust/pull/79341#discussion_r561855624 )
> I think I'll likely scrap the whole `SingleExt` extension trait as the diagnostics for 0 and >1 items should be different.
How/why should they differ?
EDIT: this part has been solved, the current code was fine, just needed a little simplification.
cc `@Nemo157`
r? `@jyn514`
Original PR description:
This is only active when the `doc_cfg` feature is active.
The implicit cfg can be overridden via `#[doc(cfg(...))]`, so e.g. to hide a `#[cfg]` you can use something like:
```rust
#[cfg(unix)]
#[doc(cfg(all()))]
pub struct Unix;
```
By adding `#![doc(cfg_hide(foobar))]` to the crate attributes the cfg `#[cfg(foobar)]` (and _only_ that _exact_ cfg) will not be implicitly treated as a `doc(cfg)` to render a message in the documentation.
2021-10-07 16:24:53 +02:00
Will Crichton
5584c79597
Update to latest rustc and rustdoc styles
2021-10-06 21:43:40 -07:00
Will Crichton
ed8e12fd24
Unversioned -> InvocationSpecific
2021-10-06 19:45:26 -07:00
Will Crichton
55731bbc7d
Fix lint error, change scrape-examples.js minify call
2021-10-06 19:45:26 -07:00
Will Crichton
25323ec306
Move JS into a standalone file
2021-10-06 19:45:26 -07:00
Will Crichton
df5e3a6e40
Change serialized format to use DefPathHash instead of custom String
...
Move test to rustdoc-ui
Fix test writing to wrong directory
Formatting
Fix test
Add FIXME
Remove raw multiline strings
2021-10-06 19:45:25 -07:00
Will Crichton
829b1a9dd9
Incorporate jyn's feedback
...
* Move call location logic from function constructor to rendering
* Fix issue with macro spans in scraping examples
* Clean up example loading logic
Documentation / newtype for DecorationInfo
Fix line number display
Serialize edition of call site, other small cleanup
2021-10-06 19:45:23 -07:00
Will Crichton
a1cb19444f
Add styles for non-white themes
...
Tweak colors
Tabs
New link heading style
2021-10-06 19:44:51 -07:00
Will Crichton
18edcf86d2
Reduce blur size, fix example width bug, add better error handling for I/O issues
...
Remove repository url
Fix formatting
Fix file_span in print_src
Formatting
2021-10-06 19:44:51 -07:00
Will Crichton
55bb51786e
Move highlighting logic from JS to Rust
...
Continue migrating JS functionality
Cleanup
Fix compile error
Clean up the diff
Set toggle font to sans-serif
2021-10-06 19:44:50 -07:00
Will Crichton
eea8f0a39a
Sort examples by size
...
Improve styling
Start to clean up code, add comments
2021-10-06 19:44:50 -07:00
Will Crichton
b6338e7792
Generate example source files with corresponding links
...
Add display name
Fix remaining merge conflicts
Only embed code for items containing examples
2021-10-06 19:44:50 -07:00
Will Crichton
2855bf039a
Factor scraping and rendering into separate calls to rustdoc
...
Simplify toggle UI logic, add workspace root for URLs
2021-10-06 19:44:50 -07:00
Will Crichton
7831fee9f8
Fix check issue
...
Clean up tidy checks
2021-10-06 19:44:50 -07:00
Will Crichton
4b3f82ad03
Add updated support for example-analyzer
...
Move rendering of examples into
Finalize design
Cleanup, rename found -> scraped
Softer yellow
Clean up dead code
Document scrape_examples
More simplification and documentation
Remove extra css
Test
2021-10-06 19:44:47 -07:00