Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bfd16ab
mips64-openwrt-linux-musl: correct soft-foat
Grommish Feb 9, 2022
64406c5
kmc-solid: Use the filesystem thread-safety wrapper
kawadakk Feb 10, 2022
784c7a6
only mark projection as ambiguous if GAT substs are constrained
compiler-errors Feb 11, 2022
fbbcb08
Add --scrape-tests flags so rustdoc can scrape examples from tests
willcrichton Feb 12, 2022
7c6ff4b
Add the known-bug compiletest prop
jackh726 Feb 12, 2022
e660d52
Use known-bug prop for GAT bug tests
jackh726 Feb 12, 2022
5aae654
Cleanup header parsing by extracting common logic
jackh726 Feb 12, 2022
36cf48b
Don't allow error annotations in known-bug tests
jackh726 Feb 14, 2022
879e4f8
use an enum in matches_projection_projection
compiler-errors Feb 12, 2022
3a73ca5
Implement --check-cfg option (RFC 3013)
Urgau Sep 29, 2021
568aeda
MemTagSanitizer Support
ivanloz Dec 3, 2021
f04f732
Add more information to `impl Trait` deny error
compiler-errors Jan 12, 2022
207fb5f
fix impl trait message, bless tests
compiler-errors Feb 18, 2022
4bed748
Suggest `impl Trait` return type
Noratrieb Oct 14, 2021
11250b8
asm: Allow the use of r8-r14 as clobbers on Thumb1
Amanieu Feb 10, 2022
f8b83a2
Rollup merge of #89892 - Nilstrieb:suggest-return-impl-trait, r=jackh726
matthiaskrgr Feb 18, 2022
0bb72a2
Rollup merge of #91675 - ivanloz:memtagsan, r=nagisa
matthiaskrgr Feb 18, 2022
5c08c39
Rollup merge of #92806 - compiler-errors:better-impl-trait-deny, r=es…
matthiaskrgr Feb 18, 2022
e3a1e19
Rollup merge of #93497 - willcrichton:rustdoc-scrape-test, r=Guillaum…
matthiaskrgr Feb 18, 2022
32c8acd
Rollup merge of #93814 - Itus-Shield:mips64-openwrt, r=bjorn3
matthiaskrgr Feb 18, 2022
724cca6
Rollup merge of #93847 - solid-rs:fix-kmc-solid-fs-ts, r=yaahc
matthiaskrgr Feb 18, 2022
cb35370
Rollup merge of #93877 - Amanieu:asm_fixes, r=nagisa
matthiaskrgr Feb 18, 2022
1e2f63d
Rollup merge of #93892 - compiler-errors:issue-92917, r=jackh726,niko…
matthiaskrgr Feb 18, 2022
576afec
Rollup merge of #93915 - Urgau:rfc-3013, r=petrochenkov
matthiaskrgr Feb 18, 2022
620b0c5
Rollup merge of #93953 - jackh726:known_bug, r=Mark-Simulacrum
matthiaskrgr Feb 18, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add --scrape-tests flags so rustdoc can scrape examples from tests
  • Loading branch information
willcrichton committed Feb 12, 2022
commit fbbcb089c52e6dce88600be36a1cc97884294d4f
3 changes: 3 additions & 0 deletions src/doc/rustdoc/src/unstable-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
3 changes: 3 additions & 0 deletions src/librustdoc/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ crate fn create_config(
lint_opts,
describe_lints,
lint_cap,
scrape_examples_options,
..
}: RustdocOptions,
) -> rustc_interface::Config {
Expand Down Expand Up @@ -227,6 +228,7 @@ crate fn create_config(

let crate_types =
if proc_macro_crate { vec![CrateType::ProcMacro] } else { vec![CrateType::Rlib] };
let test = scrape_examples_options.map(|opts| opts.scrape_tests).unwrap_or(false);
// plays with error output here!
let sessopts = config::Options {
maybe_sysroot,
Expand All @@ -244,6 +246,7 @@ crate fn create_config(
edition,
describe_lints,
crate_name,
test,
..Options::default()
};

Expand Down
3 changes: 3 additions & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,9 @@ fn opts() -> Vec<RustcOptGroup> {
"collect function call information for functions from the target crate",
)
}),
unstable("scrape-tests", |o| {
o.optflag("", "scrape-tests", "Include test code when scraping examples")
}),
unstable("with-examples", |o| {
o.optmulti(
"",
Expand Down
15 changes: 11 additions & 4 deletions src/librustdoc/scrape_examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use std::path::PathBuf;
crate struct ScrapeExamplesOptions {
output_path: PathBuf,
target_crates: Vec<String>,
crate scrape_tests: bool,
}

impl ScrapeExamplesOptions {
Expand All @@ -43,16 +44,22 @@ impl ScrapeExamplesOptions {
) -> Result<Option<Self>, i32> {
let output_path = matches.opt_str("scrape-examples-output-path");
let target_crates = matches.opt_strs("scrape-examples-target-crate");
match (output_path, !target_crates.is_empty()) {
(Some(output_path), true) => Ok(Some(ScrapeExamplesOptions {
let scrape_tests = matches.opt_present("scrape-tests");
match (output_path, !target_crates.is_empty(), scrape_tests) {
(Some(output_path), true, _) => Ok(Some(ScrapeExamplesOptions {
output_path: PathBuf::from(output_path),
target_crates,
scrape_tests,
})),
(Some(_), false) | (None, true) => {
(Some(_), false, _) | (None, true, _) => {
diag.err("must use --scrape-examples-output-path and --scrape-examples-target-crate together");
Err(1)
}
(None, false) => Ok(None),
(None, false, true) => {
diag.err("must use --scrape-examples-output-path and --scrape-examples-target-crate with --scrape-tests");
Err(1)
}
(None, false, false) => Ok(None),
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/test/run-make/rustdoc-scrape-examples-multiple/scrape.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ $(TMPDIR)/%.calls: $(TMPDIR)/libfoobar.rmeta
--extern foobar=$(TMPDIR)/libfoobar.rmeta \
-Z unstable-options \
--scrape-examples-output-path $@ \
--scrape-examples-target-crate foobar
--scrape-examples-target-crate foobar \
$(extra_flags)

$(TMPDIR)/lib%.rmeta: src/lib.rs
$(RUSTC) src/lib.rs --crate-name $* --crate-type lib --emit=metadata
Expand Down
6 changes: 6 additions & 0 deletions src/test/run-make/rustdoc-scrape-examples-test/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
extra_flags := --scrape-tests
deps := ex

-include ../rustdoc-scrape-examples-multiple/scrape.mk

all: scrape
6 changes: 6 additions & 0 deletions src/test/run-make/rustdoc-scrape-examples-test/examples/ex.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main() {}

#[test]
fn a_test() {
foobar::ok();
}
3 changes: 3 additions & 0 deletions src/test/run-make/rustdoc-scrape-examples-test/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]' ''

pub fn ok() {}