Completely removed the `create_missing` option from MDBook
This commit is contained in:
parent
f993677626
commit
527fc5cf79
|
@ -118,8 +118,9 @@ impl MDBook {
|
||||||
pub fn write_file<P: AsRef<Path>>(&self, filename: P, content: &[u8]) -> Result<()> {
|
pub fn write_file<P: AsRef<Path>>(&self, filename: P, content: &[u8]) -> Result<()> {
|
||||||
let path = self.get_destination().join(filename);
|
let path = self.get_destination().join(filename);
|
||||||
|
|
||||||
utils::fs::create_file(&path)?.write_all(content)
|
utils::fs::create_file(&path)?
|
||||||
.map_err(|e| e.into())
|
.write_all(content)
|
||||||
|
.map_err(|e| e.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parses the `book.json` file (if it exists) to extract
|
/// Parses the `book.json` file (if it exists) to extract
|
||||||
|
@ -149,16 +150,18 @@ impl MDBook {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn test(&mut self, library_paths: Vec<&str>) -> Result<()> {
|
pub fn test(&mut self, library_paths: Vec<&str>) -> Result<()> {
|
||||||
let library_args: Vec<&str> = (0..library_paths.len()).map(|_| "-L")
|
let library_args: Vec<&str> = (0..library_paths.len())
|
||||||
.zip(library_paths.into_iter())
|
.map(|_| "-L")
|
||||||
.flat_map(|x| vec![x.0, x.1])
|
.zip(library_paths.into_iter())
|
||||||
.collect();
|
.flat_map(|x| vec![x.0, x.1])
|
||||||
|
.collect();
|
||||||
let temp_dir = TempDir::new("mdbook")?;
|
let temp_dir = TempDir::new("mdbook")?;
|
||||||
for item in self.iter() {
|
for item in self.iter() {
|
||||||
if let BookItem::Chapter(ref ch) = *item {
|
if let BookItem::Chapter(ref ch) = *item {
|
||||||
if !ch.path.as_os_str().is_empty() {
|
if !ch.path.as_os_str().is_empty() {
|
||||||
let path = self.get_source().join(&ch.path);
|
let path = self.get_source().join(&ch.path);
|
||||||
let base = path.parent().ok_or_else(|| String::from("Invalid bookitem path!"))?;
|
let base = path.parent()
|
||||||
|
.ok_or_else(|| String::from("Invalid bookitem path!"))?;
|
||||||
let content = utils::fs::file_to_string(&path)?;
|
let content = utils::fs::file_to_string(&path)?;
|
||||||
// Parse and expand links
|
// Parse and expand links
|
||||||
let content = preprocess::links::replace_all(&content, base)?;
|
let content = preprocess::links::replace_all(&content, base)?;
|
||||||
|
@ -169,10 +172,11 @@ impl MDBook {
|
||||||
let mut tmpf = utils::fs::create_file(&path)?;
|
let mut tmpf = utils::fs::create_file(&path)?;
|
||||||
tmpf.write_all(content.as_bytes())?;
|
tmpf.write_all(content.as_bytes())?;
|
||||||
|
|
||||||
let output = Command::new("rustdoc").arg(&path)
|
let output = Command::new("rustdoc")
|
||||||
.arg("--test")
|
.arg(&path)
|
||||||
.args(&library_args)
|
.arg("--test")
|
||||||
.output()?;
|
.args(&library_args)
|
||||||
|
.output()?;
|
||||||
|
|
||||||
if !output.status.success() {
|
if !output.status.success() {
|
||||||
bail!(ErrorKind::Subprocess(
|
bail!(ErrorKind::Subprocess(
|
||||||
|
|
Loading…
Reference in New Issue