190 Commits

Author SHA1 Message Date
Joshua Nelson
727baf0db1 When documenting private items in a binary, ignore warnings about links to private items
Previously, rustdoc would warn about linking to items in a binary, even
though cargo unconditionally documents private items in a binary.
This changes cargo to silence the warning, since it's only relevant in
cases where the private items might not be documented.
2022-05-03 20:03:44 -05:00
Will Crichton
642ca5491a Ensure host units don't depend on Docscrape units, fixes #10535 2022-04-08 15:01:01 -07:00
Will Crichton
e55c40fdda Fix scrape-examples incorrectly handling proc macros 2022-04-01 19:34:53 -07:00
Loïc BRANSTETT
e828e85ee7 Add -Z check-cfg-features support for rustdoc 2022-02-26 14:10:17 +01:00
hi-rustin
81c2cd5a95 Compute non custom build and non transitive deps for doc
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2022-01-30 00:06:27 +08:00
Eric Huss
fdeb38b903 Fix documenting with undocumented dependencies. 2022-01-24 17:10:05 -08:00
hi-rustin
07843ed8fb add open_no_doc_crate test
Signed-off-by: hi-rustin <rustin.liu@gmail.com>
2021-12-16 22:29:32 +08:00
Eric Huss
6e568690a6 Don't document libs with doc=false 2021-12-15 15:13:54 -08:00
bors
a4cdd757e5 Auto merge of #10171 - ehuss:no-executable-doc, r=alexcrichton
Don't emit "executable" JSON field for non-executables.

The "executable" field of JSON artifact messages was accidentally filled (with the path to `index.html`) when documenting a binary target. This fixes it so that it is null.

Closes #10149
2021-12-13 19:48:00 +00:00
Eric Huss
6a79008cad Don't emit "executable" JSON field for non-executables. 2021-12-05 18:39:30 -08:00
Eric Huss
a09fbf2ef8 Document lib before bin. 2021-12-05 15:14:54 -08:00
Eric Huss
2507d53bb6 Fix some tests with output collisions. 2021-11-29 11:04:08 -08:00
Esteban Kuber
0dfe70f7e1 Change test to not trigger emoji error
This change is needed to land rust-lang/rust#88781, as it changes the
handling of emojis in source code to treat them as identifiers.
2021-11-24 17:07:40 +00:00
Joshua Nelson
8713cd7e69 Give a hard error if -Zrustdoc-scrape-examples is missing a flag
It's the same as if the flag wasn't passed, and it makes it difficult to
figure out why rustdoc isn't generating examples.
2021-11-05 09:07:15 -05:00
Will Crichton
7ee3ffc7e6 Fix --scrape-examples-target-crate using package name (with dashes) instead of crate name (with underscores), closes #10035 2021-11-04 11:23:40 -07:00
Will Crichton
9fb78cf698 Change --scrape-examples flag to -Z rustdoc-scrape-examples 2021-10-29 00:15:19 -07:00
Will Crichton
0a2382b6db Formatting 2021-10-28 00:38:16 -07:00
Will Crichton
11209570c9 Change scraping to apply to all workspace packages instead of just
root units. Only attach Docscrape unit dependencies to workspace Doc
units. Add test for scraping examples with complex reverse dependencies.
2021-10-28 00:35:34 -07:00
Will Crichton
e4a65b91be Fix several bugs when checking wasmtime repo:
* Docscrape unit not having dev-dependencies included
* Sources for reverse-dependencies generated to the wrong directory
* Incorrect features being selected for Docscrape units
* Panics from Docscrape-dependent packages not being available
2021-10-27 11:42:31 -07:00
Will Crichton
b948fc86c0 Add test / documentation for scrape-examples cycle-avoidance, add map for doc unit -> metadata to Context 2021-10-14 16:06:26 -07:00
Will Crichton
470556603e Add documentation and a test 2021-10-12 19:11:07 -07:00
Eric Huss
422d5b030c Enable some tests on windows. 2021-09-08 23:34:37 -07:00
l00556901
1bbd505a72 add fmt 2021-08-24 17:49:21 +08:00
l00556901
2929efdf88 add --examples subcommand 2021-08-24 17:44:58 +08:00
bors
4952979031 Auto merge of #9531 - 5225225:cargo-doc-open-fix, r=ehuss
Fix `BorrowMutError` when calling `cargo doc --open`

~~I'm not sure why the existing test suite didn't catch this, it definitely calls `cargo doc --open`.~~

I had

```toml
[doc.extern-map]
std = "local"
```

in my `.cargo/config.toml`. Will write a test case that sets that and then tries to run `cargo doc --open`.

Closes #9530
2021-07-01 01:14:50 +00:00
5225225
950c415583 Fully match stderr, return if not nightly, shorten file 2021-06-28 19:01:16 +01:00
5225225
9e4c0e1e44 Don't use CargoDocConfig struct 2021-06-19 17:45:44 +01:00
Eric Huss
bd4010c43d Relax doc collision error. 2021-06-17 16:28:17 -07:00
Eric Huss
16b5402fd7 testsuite: Switch to colored diffs with Myers diff. 2021-06-16 15:43:29 -07:00
5225225
1919ce7ce5 Add test to try to catch doc --open issue with extern-map 2021-06-06 13:28:45 +01:00
Eric Huss
81defa6d1e Consolidate doc collision detection. 2021-05-30 19:39:48 -07:00
Jade
50486be0c0 testsuite/doc: Check the arguments used to invoke the browser
Previously we apparently weren't doing this as we weren't checking
stdout.
2021-05-15 18:59:24 -07:00
Jade
ed46a9a4de test path and args 2021-05-15 14:23:44 -07:00
Jade
e840c8e81c Add a cargo-doc.browser config option
The idea of this option is to allow cargo to use a separate browser from
the rest of the system. My motivation in doing this is that I want to
write a script that adds a symbolic link in some web root on my system
such that I can access my docs via the http protocol to avoid the
limitations of the file protocol that are accessibility problems for me.
For instance, zoom is not retained across multiple pages and Stylus
filters don't work well.
2021-05-10 21:04:41 -07:00
Eric Huss
44c549e650 Clear rustdoc output just before running rustdoc. 2021-04-26 21:04:01 -07:00
Eric Huss
77855f3636 Use consolidated fingerprint directory for rustdoc. 2021-04-26 21:02:29 -07:00
Eric Huss
c373867304 Add tests for new rustdoc fingerprint behavior. 2021-04-24 09:08:21 -07:00
Eric Huss
d17c85132b Make doc_fingerprint_respects_target_paths work on all targets. 2021-04-23 14:31:14 -07:00
Simonas Kazlauskas
548300b20f Add the path to the manifest in json output
This allows consumers of the json messages to avoid guessing where
exactly the package root is. Having access to the package root is
difficult by virtue of requiring logic to guess its location by e.g.
walking filesystem from the source file.

This guessing logic becomes further complicated in presence of
workspaces and nigh impossible to implement correctly in instances where
artifacts end up produced from paths above the package root (e.g.
`../foo.rs`).

Since Cargo has access to this data in the first place, there doesn't
seem to be much reason to force consumers to invent their own, possibly
flawed, logic.
2021-03-04 20:09:51 +02:00
Arpad Borsos
b4c4028f76
Run rustdoc doctests relative to the workspace
By doing so, rustdoc will also emit workspace-relative filenames for the doctests.

This was first landed in #8954 but later backed out in #8996 because it changed the CWD of rustdoc test invocations.

The second try relies on the new `--test-run-directory` rustdoc option which was added in https://github.com/rust-lang/rust/pull/81264 to explicitly control the rustdoc test cwd.

fixes #8993
2021-02-22 20:33:31 +01:00
CPerezz
cb21e6424b
Improve & fix doc dir removal process 2021-02-01 01:54:13 +01:00
CPerezz
7c45021328
Check target-dependant doc folders
When checking the fingerprint for rustdoc and applying
the corresponding logic, we don't only need to consider
the `target/doc` folder (Host target) but also triple targets.

So now the actual compilation targets are checked during the
rustdoc_fingerprint processing and they're treated as the Host/doc
folder.
2021-01-31 23:43:27 +01:00
CPerezz
d2572a2800
Address latest reivew suggestions
- Instead of `fs` we use the `utils::paths` functions
to interact with the filesystem.
- The doc fingerprint is now stored under `target/` instead
of `target/doc/`.
- The code in `compile` has been reduced to a single function call.
2021-01-27 01:14:31 +01:00
CPerezz
94519f2649
Create dirs if needed before f_p write call
Once `RustDocFingerprint::check_rustdoc_fingerprint()` is
executed it might happen that the `doc/` dir is removed.

This means that when we call `fingerprint.write()` we need
to create the `doc` directory again.
2021-01-26 00:54:41 +01:00
CPerezz
994ccec136
Address @ehuss suggestions/nits 2020-12-17 02:05:25 +01:00
CPerezz
ebd0d58c1c
Apply rustfmt 2020-12-16 09:39:51 +01:00
Carlos Pérez
31ef7affcb
Merge branch 'master' into doc_versioning 2020-12-16 09:32:39 +01:00
CPerezz
2fea14e449
Add tests for rustdoc fingerprint impl
- Check wether the fingerprint is created with the
correct data after a `rustdoc` execution.
- Check wether the previous docs are removed if the version
used to compile them reported in the fingerprint is different
from the actual one being used by the compiler.
2020-12-16 09:24:59 +01:00
Arpad Borsos
e729880f56 fix failures on linux 2020-12-07 09:25:49 +01:00
Arpad Borsos
2cc2ae8c96 Run rustdoc doctests relative to the workspace
By doing so, rustdoc will also emit workspace-relative filenames for
the doctests.

fixes #8097
2020-12-06 23:21:06 +01:00