diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-18 23:23:05 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-18 23:23:05 +0100 |
| commit | e3a1e192960c41acc196b59f0cb1b28f78e712f8 (patch) | |
| tree | 86a2d2d437d5a4939771c463b0275b0c7f552a82 /src/doc/rustdoc | |
| parent | 5c08c391211ca4d67e1908fccad45d73c6c76124 (diff) | |
| parent | fbbcb089c52e6dce88600be36a1cc97884294d4f (diff) | |
| download | rust-e3a1e192960c41acc196b59f0cb1b28f78e712f8.tar.gz rust-e3a1e192960c41acc196b59f0cb1b28f78e712f8.zip | |
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`
Diffstat (limited to 'src/doc/rustdoc')
| -rw-r--r-- | src/doc/rustdoc/src/unstable-features.md | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index d60be193bda..c7fd5ed6fcb 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -509,3 +509,6 @@ reverse-dependency like `examples/ex.rs` is given to rustdoc with the target crate being documented (`foobar`) and a path to output the calls (`output.calls`). Then, the generated calls file can be passed via `--with-examples` to the subsequent documentation of `foobar`. + +To scrape examples from test code, e.g. functions marked `#[test]`, then +add the `--scrape-tests` flag. |
