@@ -3,18 +3,12 @@ use std::fs::{create_dir_all, read_to_string, File};
33use std:: io:: prelude:: * ;
44use std:: path:: Path ;
55
6- use tempfile:: tempdir;
7-
86use rustc_span:: edition:: Edition ;
9- use rustc_span:: DUMMY_SP ;
107
11- use crate :: config:: { Options , RenderOptions } ;
12- use crate :: doctest:: { generate_args_file, Collector , GlobalTestOptions } ;
8+ use crate :: config:: RenderOptions ;
139use crate :: html:: escape:: Escape ;
1410use crate :: html:: markdown;
15- use crate :: html:: markdown:: {
16- find_testable_code, ErrorCodes , HeadingOffset , IdMap , Markdown , MarkdownWithToc ,
17- } ;
11+ use crate :: html:: markdown:: { ErrorCodes , HeadingOffset , IdMap , Markdown , MarkdownWithToc } ;
1812
1913/// Separate any lines at the start of the file that begin with `# ` or `%`.
2014fn extract_leading_metadata ( s : & str ) -> ( Vec < & str > , & str ) {
@@ -137,41 +131,3 @@ pub(crate) fn render<P: AsRef<Path>>(
137131 Ok ( _) => Ok ( ( ) ) ,
138132 }
139133}
140-
141- /// Runs any tests/code examples in the markdown file `input`.
142- pub ( crate ) fn test ( options : Options ) -> Result < ( ) , String > {
143- use rustc_session:: config:: Input ;
144- let input_str = match & options. input {
145- Input :: File ( path) => {
146- read_to_string ( & path) . map_err ( |err| format ! ( "{}: {err}" , path. display( ) ) ) ?
147- }
148- Input :: Str { name : _, input } => input. clone ( ) ,
149- } ;
150-
151- let mut opts = GlobalTestOptions :: default ( ) ;
152- opts. no_crate_inject = true ;
153-
154- let temp_dir =
155- tempdir ( ) . map_err ( |error| format ! ( "failed to create temporary directory: {error:?}" ) ) ?;
156- let file_path = temp_dir. path ( ) . join ( "rustdoc-cfgs" ) ;
157- generate_args_file ( & file_path, & options) ?;
158-
159- let mut collector = Collector :: new (
160- options. input . filestem ( ) . to_string ( ) ,
161- options. clone ( ) ,
162- true ,
163- opts,
164- None ,
165- options. input . opt_path ( ) . map ( ToOwned :: to_owned) ,
166- options. enable_per_target_ignores ,
167- file_path,
168- ) ;
169- collector. set_position ( DUMMY_SP ) ;
170- let codes = ErrorCodes :: from ( options. unstable_features . is_nightly_build ( ) ) ;
171-
172- // For markdown files, custom code classes will be disabled until the feature is enabled by default.
173- find_testable_code ( & input_str, & mut collector, codes, options. enable_per_target_ignores , None ) ;
174-
175- crate :: doctest:: run_tests ( options. test_args , options. nocapture , collector. tests ) ;
176- Ok ( ( ) )
177- }
0 commit comments