summaryrefslogtreecommitdiff
path: root/src/ast.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2020-02-15 07:20:05 +0000
committerLars Wirzenius <liw@liw.fi>2020-02-15 07:20:05 +0000
commit62df0717e7087a051ec697b59b21feefaa27ece7 (patch)
tree9e33c085db46629672b566bfd7712c002a2c6ed3 /src/ast.rs
parentb0c3b2f3158611caf3f7bcc4ce8b277abde1e035 (diff)
parente975bd5b30eb7f3f46cba32e16ca813e110bc497 (diff)
downloadsubplot-62df0717e7087a051ec697b59b21feefaa27ece7.tar.gz
Merge branch 'liw/titles' into 'master'
Change: require docgen, codegen to fail if document has no title See merge request larswirzenius/subplot!2
Diffstat (limited to 'src/ast.rs')
-rw-r--r--src/ast.rs9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/ast.rs b/src/ast.rs
index e6fd5db..f59d9f4 100644
--- a/src/ast.rs
+++ b/src/ast.rs
@@ -109,6 +109,15 @@ impl<'a> Document {
self.files.files()
}
+ /// Check that document has a title in its metadata.
+ pub fn has_title(&self) -> Result<()> {
+ if self.meta().title().is_empty() {
+ Err(Error::no_title())
+ } else {
+ Ok(())
+ }
+ }
+
/// Typeset a Subplot document.
pub fn typeset(&mut self) {
let mut visitor = TypesettingVisitor::new(&self.meta.bindings);