Commit Graph

38 Commits

Author SHA1 Message Date
Jacob Pratt
6970246886
Remove crate visibility modifier in libs, tests 2022-05-21 00:32:47 -04:00
Miguel Guarniz
cad1fd2f16 update rustdoc code to use new method name
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Miguel Guarniz
93616dd539 remove ItemLikeVisitor and DeepVisitor
Signed-off-by: Miguel Guarniz <mi9uel9@gmail.com>
2022-05-13 11:46:06 -04:00
Will Crichton
6a18b68655 Add Rustdoc book link to scrape examples help. Remove remaining panic
locations in scrape examples.
2022-04-12 11:05:07 -07:00
Will Crichton
b9ecdca0d5 Don't panic when scraping invalid calls 2022-03-27 19:36:22 -07:00
Will Crichton
f1e3e2c366 Use PathSegment::ident for scraping method calls 2022-03-27 18:10:50 -07:00
Will Crichton
d58c9dfdb9 Only highlight identifier in scraped examples, not arguments 2022-03-27 18:10:50 -07:00
Matthias Krüger
e3a1e19296
Rollup merge of #93497 - willcrichton:rustdoc-scrape-test, r=GuillaumeGomez
Pass `--test` flag through rustdoc to rustc so `#[test]` functions can be scraped

As a part of stabilizing the scrape examples extension in Cargo, I uncovered a bug where examples cannot be scraped from tests. See this test: https://github.com/rust-lang/cargo/pull/10343/files#diff-27aa4f012ebfebaaee61498d91d2370de460628405d136b05e77efe61e044679R2496

The issue is that when rustdoc is run on a test file, because `--test` is not passed as a rustc option, then functions annotated with `#[test]` are ignored by the compiler. So this PR changes rustdoc so when `--test` is passed in conjunction with a `--scrape-example-<suffix>` flag, then the `test` field of `rustc_interface::Config` is true.

r? `@camelid`
2022-02-18 23:23:05 +01:00
est31
60f969a4f2 Adopt let_else in even more places 2022-02-16 22:43:39 +01:00
Will Crichton
fbbcb089c5 Add --scrape-tests flags so rustdoc can scrape examples from tests 2022-02-11 21:48:59 -08:00
Matthias Krüger
338979232a
Rollup merge of #93568 - willcrichton:scrape-examples-leading-whitespace, r=CraftSpider
Include all contents of first line of scraped item in Rustdoc

This fixes #93528. When scraping examples, it extends the span of the enclosing item to include all characters up to the start of the first line of the span.

r? `@camelid`
2022-02-08 06:47:33 +01:00
Matthias Krüger
f1a399abaa rustdoc: clippy::complexity fixes
clippy::map_flatten
clippy::clone_on_copy
clippy::useless_conversion
clippy::needless_arbitrary_self_type
2022-02-03 23:17:13 +01:00
Will Crichton
1ab23bda9c Include all contents of first line of scraped item 2022-02-01 17:03:22 -08:00
Nicholas Nethercote
416399dc10 Make Decodable and Decoder infallible.
`Decoder` has two impls:
- opaque: this impl is already partly infallible, i.e. in some places it
  currently panics on failure (e.g. if the input is too short, or on a
  bad `Result` discriminant), and in some places it returns an error
  (e.g. on a bad `Option` discriminant). The number of places where
  either happens is surprisingly small, just because the binary
  representation has very little redundancy and a lot of input reading
  can occur even on malformed data.
- json: this impl is fully fallible, but it's only used (a) for the
  `.rlink` file production, and there's a `FIXME` comment suggesting it
  should change to a binary format, and (b) in a few tests in
  non-fundamental ways. Indeed #85993 is open to remove it entirely.

And the top-level places in the compiler that call into decoding just
abort on error anyway. So the fallibility is providing little value, and
getting rid of it leads to some non-trivial performance improvements.

Much of this commit is pretty boring and mechanical. Some notes about
a few interesting parts:
- The commit removes `Decoder::{Error,error}`.
- `InternIteratorElement::intern_with`: the impl for `T` now has the same
  optimization for small counts that the impl for `Result<T, E>` has,
  because it's now much hotter.
- Decodable impls for SmallVec, LinkedList, VecDeque now all use
  `collect`, which is nice; the one for `Vec` uses unsafe code, because
  that gave better perf on some benchmarks.
2022-01-22 10:38:31 +11:00
Cameron Steffen
b11733534d Remove a span from hir::ExprKind::MethodCall 2022-01-21 07:48:10 -06:00
Cameron Steffen
45db716902 Replace NestedVisitorMap with NestedFilter 2022-01-16 16:02:36 -06:00
Camille GILLOT
60064726ae Return a LocalDefId in get_parent_item. 2022-01-15 21:26:20 +01:00
Will Crichton
b7de7973b2 Don't emit shared files when scraping dependencies 2021-12-11 10:13:16 -08:00
Deadbeef
c86da9b7b2
Add trace statements 2021-11-27 00:26:21 +08:00
Deadbeef
2d3d6bc5a2
Fix another ICE in rustdoc scrape_examples 2021-11-27 00:26:18 +08:00
bors
88b4ea8fb6 Auto merge of #90635 - matthiaskrgr:rustdoc_compl, r=GuillaumeGomez
rustdoc: clippy::complexity fixes
2021-11-07 02:17:35 +00:00
Matthias Krüger
952fea793e rustdoc: clippy::complexity fixes 2021-11-05 22:06:17 +01:00
Will Crichton
4846d102e2 Fix ICE when rustdoc is scraping examples inside of a proc macro 2021-11-04 13:57:39 -07:00
Will Crichton
3ad6d12827 Sort scraped call locations before serializing 2021-11-04 13:57:09 -07:00
Will Crichton
b8ecc9fefa Fix rare ICE during typeck in rustdoc scrape_examples 2021-10-29 13:21:50 -07:00
Will Crichton
24a71cbdd7 Fix local crate not being scraped 2021-10-12 18:26:39 -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
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
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
5c05b3c03d Add target crates as inputs to reduce size of intermediates
Add tests for module-path remapping and scrape example options

Find all crates with a given name
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
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