1
Fork 0

Rollup merge of #85833 - willcrichton:example-analyzer, r=jyn514

Scrape code examples from examples/ directory for Rustdoc

Adds support for the functionality described in https://github.com/rust-lang/rfcs/pull/3123

Matching changes to Cargo are here: https://github.com/rust-lang/cargo/pull/9525

Live demo here: https://willcrichton.net/example-analyzer/warp/trait.Filter.html#method.and
This commit is contained in:
Matthias Krüger 2021-10-23 14:58:39 +02:00 committed by GitHub
commit dcf9242795
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 1104 additions and 30 deletions

View file

@ -48,11 +48,13 @@ extern crate rustc_interface;
extern crate rustc_lexer;
extern crate rustc_lint;
extern crate rustc_lint_defs;
extern crate rustc_macros;
extern crate rustc_metadata;
extern crate rustc_middle;
extern crate rustc_parse;
extern crate rustc_passes;
extern crate rustc_resolve;
extern crate rustc_serialize;
extern crate rustc_session;
extern crate rustc_span;
extern crate rustc_target;
@ -120,6 +122,7 @@ mod json;
crate mod lint;
mod markdown;
mod passes;
mod scrape_examples;
mod theme;
mod visit_ast;
mod visit_lib;
@ -619,6 +622,30 @@ fn opts() -> Vec<RustcOptGroup> {
"Make the identifiers in the HTML source code pages navigable",
)
}),
unstable("scrape-examples-output-path", |o| {
o.optopt(
"",
"scrape-examples-output-path",
"",
"collect function call information and output at the given path",
)
}),
unstable("scrape-examples-target-crate", |o| {
o.optmulti(
"",
"scrape-examples-target-crate",
"",
"collect function call information for functions from the target crate",
)
}),
unstable("with-examples", |o| {
o.optmulti(
"",
"with-examples",
"",
"path to function call information (for displaying examples in the documentation)",
)
}),
]
}
@ -732,6 +759,7 @@ fn main_options(options: config::Options) -> MainResult {
// FIXME: fix this clone (especially render_options)
let manual_passes = options.manual_passes.clone();
let render_options = options.render_options.clone();
let scrape_examples_options = options.scrape_examples_options.clone();
let config = core::create_config(options);
interface::create_compiler_and_run(config, |compiler| {
@ -768,6 +796,10 @@ fn main_options(options: config::Options) -> MainResult {
});
info!("finished with rustc");
if let Some(options) = scrape_examples_options {
return scrape_examples::run(krate, render_opts, cache, tcx, options);
}
cache.crate_version = crate_version;
if show_coverage {