Commit Graph

676 Commits

Author SHA1 Message Date
Joshua Nelson
9221d4d1d3 [tmp] Pass TyCtxt through to the render backend
First actually useful step in https://github.com/rust-lang/rust/issues/76382

This doesn't yet compile because there's no way to get a `Lrc<Session>`
from a TyCtxt, only a `&Session`.
2020-12-17 11:36:04 -05:00
Joshua Nelson
79ab333cf0 Move run_renderer into the main global_ctxt closure 2020-12-17 11:36:00 -05:00
Joshua Nelson
c18c7c7059 Remove redundant assignment
`crate.name` is already set by `tcx.crate_name`, there's no need to
override it.
2020-12-15 21:22:15 -05:00
Joshua Nelson
4c1addfcb7 Use imports instead of rewriting the type signature of stable
This was an adventure; see https://rust-lang.zulipchat.com/#narrow/stream/122651-general/topic/'higher.20ranked.20subtype.20error'
2020-12-13 15:13:41 -05:00
bors
7efc097c4f Auto merge of #79957 - jyn514:smaller-span, r=GuillaumeGomez
[rustdoc] Calculate span information on demand instead of storing it ahead of time

This brings `size_of<clean::types::Span>()` down from over 100 bytes (!!) to only 12, the same as rustc. It brings `Item` down even more, from `784` to `680`.

~~TODO: I need to figure out how to do this for the JSON backend too. That uses `From` impls everywhere, which don't allow passing in the `Session` as an argument. `@P1n3appl3,` `@tmandry,` maybe one of you have ideas?~~ Figured it out, fortunately only two functions needed to be changed. I like the `convert_x()` format better than `From` everywhere but I'm open to feedback.

Helps with #79103
2020-12-12 19:41:56 +00:00
Joshua Nelson
4fa95b3a07 Calculate span info on-demand instead of ahead of time
This should *vastly* reduce memory usage.
2020-12-12 00:01:01 -05:00
Joshua Nelson
af6aa9f431 Pass Session into renderer 2020-12-12 00:00:09 -05:00
Eric Arellano
85e9ea0152 Dogfood 'str_split_once() with librustdoc 2020-12-07 14:00:31 -07:00
Camelid
376507f47b Add missing feature flag
Accidentally removed in rebase.
2020-12-03 14:11:37 -08:00
Nixon Enraght-Moony
40b5470b0d Address review comments.
Go back to CRATE_DEF_INDEX

Minor niceness improvements

Don't output hidden items

Remove striped items from fields

Add $TEST_BASE_DIR

Small catch
2020-12-01 18:34:39 +00:00
Nelson J Morais
f4d99d3aeb fixes a word typo in librustdoc 2020-11-25 19:09:11 +00:00
Guillaume Gomez
804ca1d5b7 Rollup merge of #78984 - GuillaumeGomez:rustdoc-check-option, r=jyn514
Rustdoc check option

The ultimate goal behind this option would be to have `rustdoc --check` being run when you use `cargo check` as a second step.

r? `@jyn514`
2020-11-13 15:26:16 +01:00
Guillaume Gomez
a51b13042e Add --check option to rustdoc 2020-11-12 14:57:44 +01:00
bors
a601302ff0 Auto merge of #75778 - AndyGauge:75521-rustdoc-book-improvements, r=jyn514
75521 rustdoc book improvements

Added some guidelines about documenting with rustdoc
Fixes #75521
2020-11-06 19:01:10 +00:00
Andrew Gauger
881820aa06 Added Rustdoc book sections for linting and embedding more examples
Co-authored-by: Joshua Nelson <joshua@yottadb.com>
2020-11-04 17:47:50 -08:00
Ian Jackson
39b80cb7c0 rustdoc: Fix some nits
* Remove a needless comma in the Rust code
* Replace double spaces after full stops with single spaces

Requested-by: @GuillaumeGomez
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-28 20:13:31 +00:00
Ian Jackson
709efd9df6 rustdoc: Provide a --default-theme THEME option
This is a fairly simple special case of --default-eetting.  We must
set both "theme" and "use-system-theme".

Providing it separately enables us to document a way to set the theme
without expoosing the individual settings keywords, which are quite
complex.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-28 18:01:06 +00:00
Ian Jackson
d8a4497561 rustdoc: Provide a general --default-setting SETTING[=VALUE] option
We just plumb through what the user tells us.

This is flagged as unstable, mostly because I don't understand the
compatibility rules that rustdoc obeys for local storage data, and how
error handling of invalid data works.

We collect() the needed HashMap from Vec of Vecs of (key, value)
pairs, so that there is a nice place to add new more-specific options.
It would have been possible to use Extend::extend but doing it this
way ensures that all the used inputs are (and will stay) right next to
each other.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2020-10-28 17:54:07 +00:00
Guillaume Gomez
f38250403c Remove unused type from librustdoc 2020-10-20 21:44:51 +02:00
Camelid
4c765f66a4 Allow generic parameters in intra-doc links
The contents of the generics will be mostly ignored (except for warning
if fully-qualified syntax is used, which is currently unsupported in
intra-doc links - see issue #74563).

* Allow links like `Vec<T>`, `Result<T, E>`, and `Option<Box<T>>`
* Allow links like `Vec::<T>::new()`
* Warn on
  * Unbalanced angle brackets (e.g. `Vec<T` or `Vec<T>>`)
  * Missing type to apply generics to (`<T>` or `<Box<T>>`)
  * Use of fully-qualified syntax (`<Vec as IntoIterator>::into_iter`)
  * Invalid path separator (`Vec:<T>:new`)
  * Too many angle brackets (`Vec<<T>>`)
  * Empty angle brackets (`Vec<>`)

Note that this implementation *does* allow some constructs that aren't
valid in the actual Rust syntax, for example `Box::<T>new()`. That may
not be supported in rustdoc in the future; it is an implementation
detail.
2020-10-08 22:24:34 -07:00
Joshua Nelson
b93a8315f2 Add a comment why rustdoc loads crates from the sysroot 2020-09-15 08:40:10 -04:00
Joshua Nelson
f7f9a6c135 Add a comment why extern crate is necessary for rustdoc 2020-09-14 22:03:54 -04:00
Guillaume Gomez
c9a48d1d73 Fix strings indent 2020-08-31 13:16:50 +02:00
Aleksey Kladov
df975cf9c2 Rename rustdoc/test -> rustdoc/doctest
This modules contains the implementation of doctests, and not the
tests of rustdoc itself. This name is confusing, so let's rename it to
doctest for clarity.
2020-08-27 18:21:25 +02:00
Joshua Nelson
bc7bce463f Rename debugging_options -> debugging_opts to match rustc
This way the rustdoc field names are the same as the rustc field names.
2020-08-25 09:22:26 -04:00
Joshua Nelson
a549c3ae70 Use underscores instead of spaces 2020-08-23 22:53:44 -04:00
Joshua Nelson
2934fd0a48 Time how long it takes to render HTML 2020-08-23 22:53:44 -04:00
Ralf Jung
0e4f335e63 stabilize ptr_offset_from 2020-08-22 14:37:10 +02:00
Joshua Nelson
9cf2fa84e8 Allow reusing the code in collect_trait_impls 2020-08-19 08:18:25 -04:00
bors
1d69e3b1d7 Auto merge of #75124 - nnethercote:clean-up-rustdoc-main, r=oli-obk
Clean up rustdoc's `main()`

It can be simplified and made more similar to rustc's `main()`.

r? @oli-obk
2020-08-05 09:09:17 +00:00
Nicholas Nethercote
5f8a11279d Be smarter about error handling in run().
`run()` returns `Result<(), String>`. But on failure it always returns
an empty string, and then `wrap_return()` treats an empty string
specially, by not reporting the error.

It turns out we already have the `ErrorReported` type for this sort of
behaviour. This commit changes `run()` to use it.
2020-08-05 11:25:57 +10:00
Nicholas Nethercote
af4e3e08ea Remove setup_callbacks_and_run_in_default_thread_pool_with_globals().
It's a very thin wrapper around
`setup_callbacks_and_run_in_thread_pool_with_globals()` and it has a
single call site.
2020-08-05 10:42:45 +10:00
Nicholas Nethercote
530140729a Avoid an unnecessary thread creation at rustdoc startup.
rustdoc's `main()` immediately spawns a thread, M, with a large stack
(16MiB or 32MiB) on which it runs `main_args()`. `main_args()` does a
small amount of options processing and then calls
`setup_callbacks_and_run_in_default_thread_pool_with_globals()`, which
spawns it own thread, and M is not used further.

So, thread M seems unnecessary. However, it does serve a purpose: if the
options processing in `main_args()` panics, that panic is caught when M
is joined. So M can't simply be removed.

However, `main_options()`, which is called by `main_args()`, has a
`catch_fatal_errors()` call within it. We can move that call to `main()`
and change it to the very similar `catch_with_exit_code()`. With that in
place, M can be removed, and panics from options processing will still
be caught appropriately.

Even better, this makes rustdoc's `main()` match rustc's `main()`, which
also uses `catch_with_exit_code()`.

(Also note that the use of a 16MiB/32MiB stack was eliminated from rustc
in #55617.)
2020-08-05 10:42:42 +10:00
Ivan Tham
c577d71e03 Remove log alias from librustdoc 2020-08-04 17:57:35 +08:00
Joshua Nelson
e97e6fbe34 Fix logging for rustdoc 2020-08-02 22:24:54 -04:00
Oliver Scherer
208f973d1f Make rustdoc share the logger initialization routine with rustc. 2020-07-31 22:38:27 +02:00
Joseph Ryan
48c6f05662 Update driver to add json backend 2020-07-30 14:13:51 -05:00
Joseph Ryan
7621a5b635 Refactor DocFS to fix error handling bugs 2020-07-29 16:15:31 -05:00
Joseph Ryan
cee8023c69 More requested changes 2020-07-27 17:34:17 -05:00
Joseph Ryan
3d707a008e Make requested changes 2020-07-27 16:00:39 -05:00
Joseph Ryan
6a4396b98c Extract Cache and other types from html module 2020-07-27 16:00:38 -05:00
Joseph Ryan
5bc97946ca Refactor html backend to use generic interface 2020-07-27 16:00:38 -05:00
Joseph Ryan
c692ed468c Move Error and RenderInfo out of html module 2020-07-27 16:00:38 -05:00
Joshua Nelson
02a24c8e2f Don't ICE on infinitely recursive types
`evaluate_obligation` can only be run on types that are already valid.
So rustdoc still has to run typeck even though it doesn't care about the
result.
2020-07-15 10:54:05 -04:00
Joshua Nelson
768d6a4950 Don't ICE on errors in function returning impl trait
Instead, report the error.

This emits the errors on-demand, without special-casing `impl Trait`, so
it should catch all ICEs of this kind, including ones that haven't been
found yet.

Since the error is emitted during type-checking there is less info about
the error; see comments in the code for details.

- Add test case for -> impl Trait
- Add test for impl trait with alias
- Move EmitIgnoredResolutionErrors to rustdoc

This makes `fn typeck_item_bodies` public, which is not desired behavior.
That change should be removed once
https://github.com/rust-lang/rust/pull/74070 is merged.

- Don't visit nested closures twice
2020-07-15 10:54:05 -04:00
Nicholas Nethercote
bf7078615b Change some function names.
A couple of these are quite long, but they do a much better job of
explaining what they do, which was non-obvious before.
2020-07-10 16:07:20 +10:00
Nicholas Nethercote
0a7d2970e5 Eliminate rust_input.
It has a single call site and having it as a separate (higher-order!)
function makes the code harder to read.
2020-07-10 11:50:21 +10:00
Guillaume Gomez
e955bebcda Remove render-redirect-pages option in rustdoc 2020-07-02 14:14:59 +02:00
Lukas Kalbertodt
1e6e082039 Remove uses of Vec::remove_item 2020-06-20 12:12:28 +02:00
Guillaume Gomez
724dfba460 Clean up some weird command strings 2020-06-13 15:05:37 +02:00