diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-09-28 10:25:20 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-09-28 10:25:20 +0300 |
commit | f974c9919502764a0319b224eb604d094499ae37 (patch) | |
tree | 270b505f63b57df15c65e259dd896689ce6bec15 /src | |
parent | f204a2e599f74485b80c4168e03358c6f3c985bf (diff) | |
download | subplot-f974c9919502764a0319b224eb604d094499ae37.tar.gz |
fix: include the subplot in the sources of the document
This means that if only the subplot is modified, docgen will rebuild
the output.
Sponsored-by: author
Diffstat (limited to 'src')
-rw-r--r-- | src/doc.rs | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -82,6 +82,7 @@ static KNOWN_PANDOC_CLASSES: &[&str] = &["numberLines", "noNumberLines"]; /// ~~~~ #[derive(Debug)] pub struct Document { + subplot: PathBuf, markdowns: Vec<PathBuf>, ast: Pandoc, meta: Metadata, @@ -92,6 +93,7 @@ pub struct Document { impl Document { fn new( + subplot: PathBuf, markdowns: Vec<PathBuf>, ast: Pandoc, meta: Metadata, @@ -99,6 +101,7 @@ impl Document { style: Style, ) -> Document { Document { + subplot, markdowns, ast, meta, @@ -115,6 +118,7 @@ impl Document { fn from_ast<P>( basedir: P, + subplot: PathBuf, markdowns: Vec<PathBuf>, yamlmeta: &ast::YamlMetadata, mut ast: Pandoc, @@ -133,7 +137,7 @@ impl Document { return Err(linter.issues.remove(0)); } let files = EmbeddedFiles::new(&mut ast); - let doc = Document::new(markdowns, ast, meta, files, style); + let doc = Document::new(subplot, markdowns, ast, meta, files, style); trace!("Loaded from JSON OK"); Ok(doc) } @@ -186,7 +190,15 @@ impl Document { trace!("Parsing document AST as JSON..."); let mut ast: Pandoc = serde_json::from_str(&json).map_err(SubplotError::AstJson)?; ast.meta = meta.to_map(); - let doc = Self::from_ast(basedir, markdowns, &meta, ast, style, template)?; + let doc = Self::from_ast( + basedir, + filename.into(), + markdowns, + &meta, + ast, + style, + template, + )?; trace!("Loaded document OK"); Ok(doc) @@ -214,7 +226,8 @@ impl Document { trace!("Parsed document OK"); Self::from_ast( basedir, - vec![filename.into()], + filename.into(), + vec![mdfile], &meta, ast.to_pandoc(), style, @@ -241,7 +254,7 @@ impl Document { /// The sources are any files that affect the output so that if /// the source file changes, the output needs to be re-generated. pub fn sources(&mut self, template: Option<&str>) -> Vec<PathBuf> { - let mut names = vec![]; + let mut names = vec![self.subplot.clone()]; for x in self.meta().bindings_filenames() { names.push(PathBuf::from(x)) |