rustdoc: fix --emit=dep-info on scraped examples
This commit is contained in:
parent
292db4a13c
commit
8611f0b67c
12 changed files with 43 additions and 9 deletions
|
|
@ -896,7 +896,7 @@ fn main_args(early_dcx: &mut EarlyDiagCtxt, at_args: &[String]) {
|
|||
// Register the loaded external files in the source map so they show up in depinfo.
|
||||
// We can't load them via the source map because it gets created after we process the options.
|
||||
for external_path in &loaded_paths {
|
||||
let _ = sess.source_map().load_file(external_path);
|
||||
let _ = sess.source_map().load_binary_file(external_path);
|
||||
}
|
||||
|
||||
if sess.opts.describe_lints {
|
||||
|
|
|
|||
|
|
@ -273,6 +273,7 @@ pub(crate) fn run(
|
|||
bin_crate: bool,
|
||||
) {
|
||||
let inner = move || -> Result<(), String> {
|
||||
let emit_dep_info = renderopts.dep_info().is_some();
|
||||
// Generates source files for examples
|
||||
renderopts.no_emit_shared = true;
|
||||
let (cx, _) = Context::init(krate, renderopts, cache, tcx, Default::default())
|
||||
|
|
@ -320,6 +321,10 @@ pub(crate) fn run(
|
|||
calls.encode(&mut encoder);
|
||||
encoder.finish().map_err(|(_path, e)| e.to_string())?;
|
||||
|
||||
if emit_dep_info {
|
||||
rustc_interface::passes::write_dep_info(tcx);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
fn main() {}
|
||||
|
||||
#[test]
|
||||
fn a_test() {
|
||||
foobar::ok();
|
||||
}
|
||||
19
tests/run-make/rustdoc-scrape-examples-dep-info/rmake.rs
Normal file
19
tests/run-make/rustdoc-scrape-examples-dep-info/rmake.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
//@ needs-target-std
|
||||
use run_make_support::{assert_contains, rfs};
|
||||
|
||||
#[path = "../rustdoc-scrape-examples-remap/scrape.rs"]
|
||||
mod scrape;
|
||||
|
||||
fn main() {
|
||||
scrape::scrape(
|
||||
&["--scrape-tests", "--emit=dep-info"],
|
||||
&["--emit=dep-info,invocation-specific"],
|
||||
);
|
||||
|
||||
let content = rfs::read_to_string("foobar.d");
|
||||
assert_contains(&content, "lib.rs:");
|
||||
assert_contains(&content, "rustdoc/ex.calls:");
|
||||
|
||||
let content = rfs::read_to_string("ex.d");
|
||||
assert_contains(&content, "examples/ex.rs:");
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
//@ has foobar/fn.ok.html '//*[@class="docblock scraped-example-list"]' ''
|
||||
|
||||
pub fn ok() {}
|
||||
|
|
@ -3,5 +3,5 @@
|
|||
mod scrape;
|
||||
|
||||
fn main() {
|
||||
scrape::scrape(&[]);
|
||||
scrape::scrape(&[], &[]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
mod scrape;
|
||||
|
||||
fn main() {
|
||||
scrape::scrape(&[]);
|
||||
scrape::scrape(&[], &[]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
mod scrape;
|
||||
|
||||
fn main() {
|
||||
scrape::scrape(&[]);
|
||||
scrape::scrape(&[], &[]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,5 +2,5 @@
|
|||
mod scrape;
|
||||
|
||||
fn main() {
|
||||
scrape::scrape(&[]);
|
||||
scrape::scrape(&[], &[]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use std::path::Path;
|
|||
|
||||
use run_make_support::{htmldocck, rfs, rustc, rustdoc};
|
||||
|
||||
pub fn scrape(extra_args: &[&str]) {
|
||||
pub fn scrape(extra_args_scrape: &[&str], extra_args_doc: &[&str]) {
|
||||
let out_dir = Path::new("rustdoc");
|
||||
let crate_name = "foobar";
|
||||
let deps = rfs::read_dir("examples")
|
||||
|
|
@ -27,7 +27,7 @@ pub fn scrape(extra_args: &[&str]) {
|
|||
.arg(&out_example)
|
||||
.arg("--scrape-examples-target-crate")
|
||||
.arg(crate_name)
|
||||
.args(extra_args)
|
||||
.args(extra_args_scrape)
|
||||
.run();
|
||||
out_deps.push(out_example);
|
||||
}
|
||||
|
|
@ -42,6 +42,7 @@ pub fn scrape(extra_args: &[&str]) {
|
|||
for dep in out_deps {
|
||||
rustdoc.arg("--with-examples").arg(dep);
|
||||
}
|
||||
rustdoc.args(extra_args_doc);
|
||||
rustdoc.run();
|
||||
|
||||
htmldocck().arg(out_dir).arg("src/lib.rs").run();
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
mod scrape;
|
||||
|
||||
fn main() {
|
||||
scrape::scrape(&["--scrape-tests"]);
|
||||
scrape::scrape(&["--scrape-tests"], &[]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,5 +3,5 @@
|
|||
mod scrape;
|
||||
|
||||
fn main() {
|
||||
scrape::scrape(&[]);
|
||||
scrape::scrape(&[], &[]);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue