116 Commits

Author SHA1 Message Date
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
Eric Huss
9b590d0dd4 Bump to 0.51.0 2020-11-23 17:34:18 -08:00
Weihang Lo
8f0664f02a
test: normalize raw string indentation. 2020-10-10 07:44:57 +08:00
Weihang Lo
f1de239450
test(doc): glob support for package selection 2020-10-05 01:24:42 +08:00
Eric Huss
6f8c7d5a87 Normalize raw string indentation. 2020-09-26 17:59:58 -07:00
CPerezz
7a5f7844aa Add skeleton for testing doc-fingerprint 2020-09-20 10:28:46 +02:00
Eric Huss
1b72e1fbf4 Fix intra-doc tests for renamed lint. 2020-08-01 09:52:11 -07:00
bors
dbbab42585 Auto merge of #8509 - ehuss:stabilize-crate-version, r=Eh2406
Stabilize -Z crate-versions

This stabilizes the `-Z crate-versions` flag which forwards the crate version to rustdoc so it can display the version in the sidebar.

The flag in rustdoc was stabilized in 1.44.

Closes #7907
2020-07-23 13:15:05 +00:00
Eric Huss
9e35ee1b93 Fix nightly tests for intra-doc links. 2020-07-22 19:11:01 -07:00
Eric Huss
3ce3d34071 Stabilize -Z crate-versions 2020-07-18 11:09:37 -07:00
Eric Huss
4ae79d2ffd Use fs helpers instead of File functions. 2020-04-17 07:56:16 -07:00
Alex Tokarev
d3b9d89a38 Use stabilized version of rustdoc's --crate-version
Since --crate-version flag of rustdoc was stabilized, there is no need to enable its unstable features when using it.
2020-03-26 01:17:45 +03:00
Alex Tokarev
c9e3141b0f Do not supply --crate-version flag to rustdoc if present in RUSTDOCFLAGS or extra compiler arguments 2020-03-18 21:26:49 +03:00
Eric Huss
517b59dbb4 Enable cargo doc --open tests on macos. 2020-02-25 08:13:30 -08:00
Alex Tokarev
1ea41babdc Add an option to include crate versions to the generated docs
Fixes https://github.com/rust-lang/cargo/issues/1681
2020-02-21 00:34:33 +03:00
Eric Huss
10e9bc9dfe Fix doc_target test which no longer works on stable/beta. 2020-01-20 11:16:53 -08:00
Eric Huss
2ad6b5413a Update tests for slight wording change in rustdoc error message. 2019-11-29 13:59:56 -08:00
Eric Huss
83571aee56 Minor testsuite organization. 2019-11-24 18:42:45 -08:00
Lukas Kalbertodt
00b21c8b46
Add tests for documenting private items by default in binary crates 2019-11-21 22:14:42 +01:00
Alex Crichton
9115b2c326 Extract support directory to its own crate
Extract out all our test support code to its own standalone crate so it
can be shared between multiple test suites if necessary.
2019-09-16 11:47:09 -07:00
Eric Huss
ecf824f7b2 Update additional uses of --all.
- man pages
- Slightly reword deprecation notice.
- Include --all in man pages.
- Update some additional usages in code and docs.
2019-09-03 17:51:07 -07:00
Eric Huss
3c20a24335 Clean up some git test support functions. 2019-08-12 22:25:36 -07:00
Eric Huss
a59ea45c1a Fix documenting an example. 2019-06-08 14:18:51 -07:00
Jethro Beekman
0e0d968825 Update #[test] attribute on all tests in the testsuite
sed -i 's/^#\[test\]/#[cargo_test]/' $(rg -l '^#\[test\]')

Manual fixes:
* proc_macro::proc_macro_doctest
2019-06-07 12:41:26 -07:00
Eric Huss
87449f453b Remove unnecessary calls to masquerade_as_nightly_cargo.
These are not needed anymore.
2019-05-09 10:58:18 -07:00