diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2023-02-25 14:51:44 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2023-02-25 14:51:44 +0000 |
commit | 3ccd4398b7a2d42b574bfdd8baed8e665c0d1cca (patch) | |
tree | 09a8f5307f193892de951ae0c3a21c35b698921d /src/bin/subplot.rs | |
parent | 7e02c646edb95ddb4cf2aceeb67888b9d420d930 (diff) | |
download | subplot-3ccd4398b7a2d42b574bfdd8baed8e665c0d1cca.tar.gz |
(doc, md, bin): Update APIs so warnings are externally accumulated
Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
Diffstat (limited to 'src/bin/subplot.rs')
-rw-r--r-- | src/bin/subplot.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/bin/subplot.rs b/src/bin/subplot.rs index f4057d9..7998416 100644 --- a/src/bin/subplot.rs +++ b/src/bin/subplot.rs @@ -7,6 +7,7 @@ use env_logger::fmt::Color; use log::{debug, error, info, trace, warn}; use subplot::{ codegen, load_document, resource, Document, EmbeddedFile, MarkupOpts, Style, SubplotError, + Warnings, }; use time::{format_description::FormatItem, macros::format_description, OffsetDateTime}; @@ -273,7 +274,7 @@ impl Docgen { pandoc.add_option(pandoc::PandocOption::NumberSections); if Self::need_output(&mut doc, self.template.as_deref(), &self.output) { - doc.typeset(); + doc.typeset(&mut Warnings::default()); pandoc.set_input_format(pandoc::InputFormat::Json, vec![]); pandoc.set_input(pandoc::InputKind::Pipe(doc.ast()?)); pandoc.set_output(pandoc::OutputKind::File(self.output.clone())); @@ -398,7 +399,7 @@ fn load_linted_doc( template: Option<&str>, merciful: bool, ) -> Result<Document, SubplotError> { - let mut doc = load_document(filename, style, None)?; + let doc = load_document(filename, style, None)?; trace!("Got doc, now linting it"); doc.lint()?; trace!("Doc linted ok"); @@ -417,16 +418,17 @@ fn load_linted_doc( }; let template = template.to_string(); trace!("Template: {:#?}", template); - doc.check_named_files_exist(&template)?; - doc.check_matched_steps_have_impl(&template); - doc.check_embedded_files_are_used(&template)?; + let mut warnings = Warnings::default(); + doc.check_named_files_exist(&template, &mut warnings)?; + doc.check_matched_steps_have_impl(&template, &mut warnings); + doc.check_embedded_files_are_used(&template, &mut warnings)?; - for w in doc.warnings() { + for w in warnings.warnings() { warn!("{}", w); } - if !doc.warnings().is_empty() && !merciful { - return Err(SubplotError::Warnings(doc.warnings().len())); + if !warnings.is_empty() && !merciful { + return Err(SubplotError::Warnings(warnings.len())); } Ok(doc) |