Improve code and add missing docs for new doctest::extracted
module
This commit is contained in:
parent
07c878910b
commit
a5d66e07e1
3 changed files with 26 additions and 17 deletions
|
@ -453,12 +453,10 @@ impl Options {
|
||||||
&& !matches.opt_present("show-coverage")
|
&& !matches.opt_present("show-coverage")
|
||||||
&& !nightly_options::is_unstable_enabled(matches)
|
&& !nightly_options::is_unstable_enabled(matches)
|
||||||
{
|
{
|
||||||
let extra = if format == "json" {
|
let extra = match format {
|
||||||
" (see https://github.com/rust-lang/rust/issues/76578)"
|
"json" => " (see https://github.com/rust-lang/rust/issues/76578)",
|
||||||
} else if format == "doctest" {
|
"doctest" => " (see https://github.com/rust-lang/rust/issues/134529)",
|
||||||
" (see https://github.com/rust-lang/rust/issues/134529)"
|
_ => "",
|
||||||
} else {
|
|
||||||
""
|
|
||||||
};
|
};
|
||||||
dcx.fatal(
|
dcx.fatal(
|
||||||
format!(
|
format!(
|
||||||
|
|
|
@ -211,15 +211,7 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
|
||||||
crate::wrap_return(dcx, generate_args_file(&args_path, &options));
|
crate::wrap_return(dcx, generate_args_file(&args_path, &options));
|
||||||
|
|
||||||
let extract_doctests = options.output_format == OutputFormat::Doctest;
|
let extract_doctests = options.output_format == OutputFormat::Doctest;
|
||||||
let CreateRunnableDocTests {
|
let result = interface::run_compiler(config, |compiler| {
|
||||||
standalone_tests,
|
|
||||||
mergeable_tests,
|
|
||||||
rustdoc_options,
|
|
||||||
opts,
|
|
||||||
unused_extern_reports,
|
|
||||||
compiling_test_count,
|
|
||||||
..
|
|
||||||
} = match interface::run_compiler(config, |compiler| {
|
|
||||||
let krate = rustc_interface::passes::parse(&compiler.sess);
|
let krate = rustc_interface::passes::parse(&compiler.sess);
|
||||||
|
|
||||||
let collector = rustc_interface::create_and_enter_global_ctxt(compiler, krate, |tcx| {
|
let collector = rustc_interface::create_and_enter_global_ctxt(compiler, krate, |tcx| {
|
||||||
|
@ -256,7 +248,17 @@ pub(crate) fn run(dcx: DiagCtxtHandle<'_>, input: Input, options: RustdocOptions
|
||||||
compiler.sess.dcx().abort_if_errors();
|
compiler.sess.dcx().abort_if_errors();
|
||||||
|
|
||||||
collector
|
collector
|
||||||
}) {
|
});
|
||||||
|
|
||||||
|
let CreateRunnableDocTests {
|
||||||
|
standalone_tests,
|
||||||
|
mergeable_tests,
|
||||||
|
rustdoc_options,
|
||||||
|
opts,
|
||||||
|
unused_extern_reports,
|
||||||
|
compiling_test_count,
|
||||||
|
..
|
||||||
|
} = match result {
|
||||||
Ok(Some(collector)) => collector,
|
Ok(Some(collector)) => collector,
|
||||||
Ok(None) => return,
|
Ok(None) => return,
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
|
|
|
@ -1,14 +1,23 @@
|
||||||
|
//! Rustdoc's doctest extraction.
|
||||||
|
//!
|
||||||
|
//! This module contains the logic to extract doctests and output a JSON containing this
|
||||||
|
//! information.
|
||||||
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
use super::{DocTestBuilder, ScrapedDocTest};
|
use super::{DocTestBuilder, ScrapedDocTest};
|
||||||
use crate::config::Options as RustdocOptions;
|
use crate::config::Options as RustdocOptions;
|
||||||
use crate::html::markdown;
|
use crate::html::markdown;
|
||||||
|
|
||||||
|
/// The version of JSON output that this code generates.
|
||||||
|
///
|
||||||
|
/// This integer is incremented with every breaking change to the API,
|
||||||
|
/// and is returned along with the JSON blob into the `format_version` root field.
|
||||||
|
/// Consuming code should assert that this value matches the format version(s) that it supports.
|
||||||
const FORMAT_VERSION: u32 = 1;
|
const FORMAT_VERSION: u32 = 1;
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
pub(crate) struct ExtractedDocTests {
|
pub(crate) struct ExtractedDocTests {
|
||||||
#[allow(non_snake_case)]
|
|
||||||
format_version: u32,
|
format_version: u32,
|
||||||
doctests: Vec<ExtractedDocTest>,
|
doctests: Vec<ExtractedDocTest>,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue