Skip to content

Commit e766f60

Browse files
rustdoc: add option to abort process on markdown differences
1 parent eff3de0 commit e766f60

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/librustdoc/html/render.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,8 @@ pub fn run(mut krate: clean::Crate,
495495
css_file_extension: Option<PathBuf>,
496496
renderinfo: RenderInfo,
497497
render_type: RenderType,
498-
sort_modules_alphabetically: bool) -> Result<(), Error> {
498+
sort_modules_alphabetically: bool,
499+
deny_render_differences: bool) -> Result<(), Error> {
499500
let src_root = match krate.src {
500501
FileName::Real(ref p) => match p.parent() {
501502
Some(p) => p.to_path_buf(),
@@ -659,6 +660,11 @@ pub fn run(mut krate: clean::Crate,
659660
render_difference(d, &mut intro_msg, span, text);
660661
}
661662
}
663+
664+
if deny_render_differences {
665+
println!("Aborting with {} rendering differences", markdown_warnings.len());
666+
::std::process::exit(1);
667+
}
662668
}
663669

664670
result

src/librustdoc/lib.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ pub fn opts() -> Vec<RustcOptGroup> {
257257
o.optflag("", "sort-modules-by-appearance", "sort modules by where they appear in the \
258258
program, rather than alphabetically")
259259
}),
260+
unstable("deny-render-differences", |o| {
261+
o.optflag("", "deny-render-differences", "abort doc runs when markdown rendering \
262+
differences are found")
263+
}),
260264
]
261265
}
262266

@@ -393,6 +397,7 @@ pub fn main_args(args: &[String]) -> isize {
393397
}
394398

395399
let output_format = matches.opt_str("w");
400+
let deny_render_differences = matches.opt_present("deny-render-differences");
396401
let res = acquire_input(PathBuf::from(input), externs, &matches, move |out| {
397402
let Output { krate, passes, renderinfo } = out;
398403
info!("going to format");
@@ -404,7 +409,8 @@ pub fn main_args(args: &[String]) -> isize {
404409
css_file_extension,
405410
renderinfo,
406411
render_type,
407-
sort_modules_alphabetically)
412+
sort_modules_alphabetically,
413+
deny_render_differences)
408414
.expect("failed to generate documentation");
409415
0
410416
}

0 commit comments

Comments
 (0)