summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2023-05-31 08:07:28 +0300
committerLars Wirzenius <liw@liw.fi>2023-05-31 08:07:28 +0300
commit2bac6a7ba33fbc43c73a7ef77612d0fe27bc4418 (patch)
tree10e2fe08f0795bbf10665a789bfe5d92c12fc8bd /src
parent5a29cd95688a50808b25a4ec3b4fb3c3e68ff549 (diff)
downloadsubplot-2bac6a7ba33fbc43c73a7ef77612d0fe27bc4418.tar.gz
feat! docgen always outputs a document
We have long had a feature for docgen that checks the time stamps of all input files and the output file and avoids running Pandoc to produce the output file, if the output file won't change. This has always been a little imperfect: sometimes the output file would change due to other changes than what's in the input files. For example, when Pandoc changes, or when Subplot code changes. This has led to surprised users. We no longer user Pandoc at all. Drop the time stamp checking functionality and have docgen always write the output file. Sponsored-by: author
Diffstat (limited to 'src')
-rw-r--r--src/bin/subplot.rs26
1 files changed, 3 insertions, 23 deletions
diff --git a/src/bin/subplot.rs b/src/bin/subplot.rs
index 8da6c2b..b95b550 100644
--- a/src/bin/subplot.rs
+++ b/src/bin/subplot.rs
@@ -278,11 +278,9 @@ impl Docgen {
Self::mtime_formatted(newest.unwrap())
};
- if Self::need_output(&mut doc, self.template.as_deref(), &self.output) {
- doc.typeset(&mut Warnings::default());
- std::fs::write(&self.output, doc.to_html(&date))
- .map_err(|e| SubplotError::WriteFile(self.output.clone(), e))?;
- }
+ doc.typeset(&mut Warnings::default());
+ std::fs::write(&self.output, doc.to_html(&date))
+ .map_err(|e| SubplotError::WriteFile(self.output.clone(), e))?;
Ok(())
}
@@ -304,24 +302,6 @@ impl Docgen {
let time = OffsetDateTime::from_unix_timestamp(secs).unwrap();
time.format(DATE_FORMAT).unwrap()
}
-
- fn need_output(doc: &mut subplot::Document, template: Option<&str>, output: &Path) -> bool {
- let output = match Self::mtime(output) {
- Err(_) => return true,
- Ok(ts) => ts,
- };
-
- for filename in doc.sources(template) {
- let source = match Self::mtime(&filename) {
- Err(_) => return true,
- Ok(ts) => ts,
- };
- if source >= output {
- return true;
- }
- }
- false
- }
}
#[derive(Debug, Parser)]