1
Fork 0
Commit graph

326 commits

Author SHA1 Message Date
Will Crichton
ce943d26f8 Add line number to URLs in "additional examples" section of rustdoc 2021-11-02 19:38:55 -07:00
Guillaume Gomez
73494404e9
Rollup merge of #90183 - GuillaumeGomez:recurse-deref, r=jyn514
Show all Deref implementations recursively

Fixes #87783.

This is a re-implementation of #80653, so taking the original PR comment:

This changes `rustdoc` to recursively follow `Deref` targets so that methods from all levels are added to the rendered output. This implementation displays the methods from all levels in the expanded state with separate sections for each level.

![image](https://user-images.githubusercontent.com/279572/103482863-46723b00-4ddb-11eb-972b-c463351a425c.png)

cc `@camelid`
r? `@jyn514`
2021-10-30 20:30:26 +02:00
Matthias Krüger
19b5b0f8fb
Rollup merge of #90412 - jyn514:macro-use, r=camelid
Remove unnecessary `macro_use`s in rustdoc
2021-10-30 14:37:04 +02:00
Joshua Nelson
b6851ba3c9 Remove unnecessary macro_uses in rustdoc 2021-10-30 02:22:38 +00:00
Guillaume Gomez
355e6eddfe Fix invalid handling of generics 2021-10-29 20:54:15 +02:00
Guillaume Gomez
dd68d207a5 Don't display "Methods from Deref<...>" if no method is display (the ones which don't have self argument) 2021-10-29 14:37:01 +02:00
Guillaume Gomez
8a473ca346 Recursively document Deref 2021-10-29 14:14:46 +02:00
bors
337e1565d3 Auto merge of #90186 - jsha:fix-header-sizes, r=GuillaumeGomez
Fix documentation header sizes

And add a rustdoc-gui test confirming various header sizes.

Split off from #90156. This fixes a regression in #89506 where the heading level of titles within Markdown was too high (h2) for docblocks under structs, unions, and enum impls.

r? `@camelid`

Demo: https://jacob.hoffman-andrews.com/rust/fix-header-sizes/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
Stable: https://doc.rust-lang.org/stable/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
Beta: https://doc.rust-lang.org/beta/std/string/struct.String.html#impl-Add%3C%26%27_%20str%3E
2021-10-27 12:27:47 +00:00
Matthias Krüger
e3eebfeea6
Rollup merge of #90154 - camelid:remove-getdefid, r=jyn514
rustdoc: Remove `GetDefId`

See the individual commit messages for details.

r? `@jyn514`
2021-10-27 06:11:35 +02:00
Jacob Hoffman-Andrews
89276ff7ed Fix documentation header sizes
And add a rustdoc-gui test confirming various header sizes.
2021-10-25 16:26:17 -07:00
Guillaume Gomez
4614ca4541 Fix clippy lints in librustdoc 2021-10-25 11:30:09 +02: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
Noah Lev
f93cf66507 Rename Type::def_id_full() to Type::def_id()
It should be preferred over `def_id_no_primitives()`, so it should have
a shorter name. I also put it before `def_id_no_primitives()` so that it
shows up first in the docs.
2021-10-22 13:07:43 -07:00
Noah Lev
bf0cc90050 Replace GetDefId with inherent methods
Now that it's only implemented for `Type`, using inherent methods
instead means that imports are no longer necessary. Also, `GetDefId` is
only meant to be used with `Type`, so it shouldn't be a trait.
2021-10-22 13:07:43 -07:00
Noah Lev
6d82ee839d Remove GetDefId impl for FnRetTy
It was only used in one place, so it seems better to use ordinary
functions.
2021-10-22 13:07:42 -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
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
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
586a9cea75 Move template initialization into its own file. 2021-10-08 23:28:42 -07: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
Will Crichton
5584c79597 Update to latest rustc and rustdoc styles 2021-10-06 21:43:40 -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
Mukund Lakshman
f1425c7c3e heading_level: u32 -> heading_offset: HeadingOffset 2021-10-04 22:28:04 -04:00
Mukund Lakshman
13558ee0a0 No need to default offset since we always override it. 2021-10-04 22:28:04 -04:00
Mukund Lakshman
6518a0a8b9 Change Markdown(...) to Markdown { ... } 2021-10-04 22:28:02 -04:00
Mukund Lakshman
4a6aa6e406 Fix heading for methods on trait impls. 2021-10-04 20:49:21 -04:00
Mukund Lakshman
a8a40ea9a4 librustdoc: Use correct heading levels.
- Avoid multiple <h1>s on a page.
- The <h#> tags should follow a semantic hierarchy.
- Cap at h6 (no h7)
2021-10-04 05:01:04 -04:00
Noah Lev
962e451443 Replace all uses of path.res.def_id() with path.def_id() 2021-10-02 15:57:57 -07:00
Noah Lev
a83112fe3e Remove temporary GetDefId impl for Path 2021-09-30 13:52:58 -07:00
Noah Lev
91d3b7201e Use Path instead of Type in PolyTrait
The change to `impl Clean<Path> for hir::TraitRef<'_>` was necessary to
fix a test failure for `src/test/rustdoc/trait-alias-mention.rs`.
Here's why:

The old code path was through `impl Clean<Type> for hir::TraitRef<'_>`,
which called `resolve_type`, which in turn called `register_res`. Now,
because `PolyTrait` uses a `Path` instead of a `Type`, the impl of
`Clean<Path>` was being run, which did not call `register_res`, causing
the trait alias to not be recorded in the `external_paths` cache.
2021-09-30 13:52:58 -07:00
Noah Lev
4c6385ff93 Make Impl.trait_ a Path, not a Type
It should only ever be a `ResolvedPath`, so this (a) enforces that, and
(b) reduces the size of `Impl`.

I had to update a test because the order of the rendered auto trait impl
bounds changed. I think the order changed because rustdoc sorts auto
trait bounds using their `Debug` output.
2021-09-30 13:52:57 -07:00
Alik Aslanyan
d98ac573a4
Remove visible path calculation from allowed deprecation lint 2021-09-30 15:15:10 +04:00
Manish Goregaokar
b3af37ac7b
Rollup merge of #88810 - camelid:cleanup-pt1, r=jyn514
rustdoc: Cleanup `clean` part 1

Split out from #88379.

These commits are completely independent of each other, and each is a fairly
small change (the last few are new commits; they are not from #88379):

- Remove unnecessary `Cache.*_did` fields
- rustdoc: Get symbol for `TyParam` directly
- Create a valid `Res` in `external_path()`
- Remove unused `hir_id` parameter from `resolve_type`
- Fix redundant arguments in `external_path()`
- Remove unnecessary `is_trait` argument
- rustdoc: Cleanup a pattern match in `external_generic_args()`

r? ``@jyn514``
2021-09-12 03:44:58 -07:00
Noah Lev
df281ee57b Only take tcx when it's all that's needed 2021-09-11 11:24:53 -07:00
Noah Lev
44e6f2e90f Remove unnecessary Cache.*_did fields
They can be obtained by accessing the `TyCtxt` where they are needed.
2021-09-09 19:17:38 -07:00
Fabian Wolff
79adda930f Ignore automatically derived impls of Clone and Debug in dead code analysis 2021-09-09 19:49:07 +02:00
bors
767edcf616 Auto merge of #88490 - GuillaumeGomez:associated-types-implementors-display, r=camelid,Manishearth
Display associated types of implementors

Fixes #86631.

Contrary to before, it doesn't display methods. I also had to "resurrect" the `auto-hide-trait-implementations` setting. :3

Only question at this point: should I move the `render_impl` boolean arguments into one struct? We're starting to have quite a lot of them...

cc `@cynecx`
r? `@camelid`
2021-09-01 21:31:16 +00:00