From c4b98e69050a94cac865af4d5f92985b9e5262b3 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 3 Sep 2022 11:51:02 +0300 Subject: refactor: drop unnecessary single-line function used from one caller Sponsored-by: author --- src/doc.rs | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/doc.rs b/src/doc.rs index 2f3368e..38e14b5 100644 --- a/src/doc.rs +++ b/src/doc.rs @@ -135,22 +135,6 @@ impl Document { Ok(doc) } - /// Construct a Document from a JSON AST - pub fn from_json

( - basedir: P, - markdowns: Vec, - json: &str, - style: Style, - template: Option<&str>, - ) -> Result - where - P: AsRef + Debug, - { - trace!("Parsing document..."); - let ast: Pandoc = serde_json::from_str(json).map_err(SubplotError::AstJson)?; - Self::from_ast(basedir, markdowns, ast, style, template) - } - /// Construct a Document from a named file. /// /// The file can be in any format Pandoc understands. This runs @@ -181,13 +165,20 @@ impl Document { // Add external Pandoc filters. crate::policy::add_citeproc(&mut pandoc); - trace!("Invoking Pandoc to parse document {:?}", filename); - let output = match pandoc.execute().map_err(SubplotError::Pandoc)? { + trace!( + "Invoking Pandoc to parse document {:?} into AST as JSON", + filename + ); + let json = match pandoc.execute().map_err(SubplotError::Pandoc)? { pandoc::PandocOutput::ToBuffer(o) => o, _ => return Err(SubplotError::NotJson), }; trace!("Pandoc was happy"); - let doc = Document::from_json(basedir, markdowns, &output, style, template)?; + + trace!("Parsing document AST as JSON..."); + let ast: Pandoc = serde_json::from_str(&json).map_err(SubplotError::AstJson)?; + let doc = Self::from_ast(basedir, markdowns, ast, style, template)?; + trace!("Loaded document OK"); Ok(doc) } -- cgit v1.2.1