pub struct Document { /* private fields */ }
Expand description
A parsed Subplot document.
§Example
fix this example;
let markdown = "\
---
title: Test Title
...
This is a test document.
";
use std::io::Write;
use tempfile::NamedTempFile;
let mut f = NamedTempFile::new().unwrap();
f.write_all(markdown.as_bytes()).unwrap();
let filename = f.path();
use subplot;
let basedir = std::path::Path::new(".");
let style = subplot::Style::default();
let doc = subplot::Document::from_file(&basedir, filename, style, None).unwrap();
assert_eq!(doc.files(), &[]);
Implementations§
Source§impl Document
impl Document
Sourcepub fn from_file(
basedir: &Path,
filename: &Path,
style: Style,
template: Option<&str>,
) -> Result<Document, SubplotError>
pub fn from_file( basedir: &Path, filename: &Path, style: Style, template: Option<&str>, ) -> Result<Document, SubplotError>
Construct a Document from a named file.
Sourcepub fn toc(&self) -> &TableOfContents
pub fn toc(&self) -> &TableOfContents
Return table of contents.
Sourcepub fn to_html(&mut self, date: &str) -> Result<String, SubplotError>
pub fn to_html(&mut self, date: &str) -> Result<String, SubplotError>
Return Document as an HTML page serialized into HTML text
Sourcepub fn sources(&self, template: Option<&str>) -> Vec<PathBuf>
pub fn sources(&self, template: Option<&str>) -> Vec<PathBuf>
Return all source filenames for the document.
The sources are any files that affect the output so that if the source file changes, the output needs to be re-generated.
Sourcepub fn embedded_files(&self) -> &[EmbeddedFile]
pub fn embedded_files(&self) -> &[EmbeddedFile]
Return list of files embeddedin the document.
Sourcepub fn lint(&self) -> Result<(), SubplotError>
pub fn lint(&self) -> Result<(), SubplotError>
Check the document for common problems.
Sourcepub fn check_bindings(
&self,
warnings: &mut Warnings,
) -> Result<(), SubplotError>
pub fn check_bindings( &self, warnings: &mut Warnings, ) -> Result<(), SubplotError>
Check bindings for warnings
Sourcepub fn check_named_code_blocks_have_appropriate_class(
&self,
warnings: &mut Warnings,
) -> Result<bool, SubplotError>
pub fn check_named_code_blocks_have_appropriate_class( &self, warnings: &mut Warnings, ) -> Result<bool, SubplotError>
Check labelled code blocks have some appropriate class
Sourcepub fn check_named_files_exist(
&self,
template: &str,
warnings: &mut Warnings,
) -> Result<bool, SubplotError>
pub fn check_named_files_exist( &self, template: &str, warnings: &mut Warnings, ) -> Result<bool, SubplotError>
Check that all named files (in matched steps) are actually present in the document.
Sourcepub fn check_embedded_files_are_used(
&self,
template: &str,
warnings: &mut Warnings,
) -> Result<bool, SubplotError>
pub fn check_embedded_files_are_used( &self, template: &str, warnings: &mut Warnings, ) -> Result<bool, SubplotError>
Check that all embedded files are used by matched steps.
Sourcepub fn check_matched_steps_have_impl(
&self,
template: &str,
warnings: &mut Warnings,
) -> bool
pub fn check_matched_steps_have_impl( &self, template: &str, warnings: &mut Warnings, ) -> bool
Check that all matched steps actually have function implementations
Sourcepub fn typeset(
&mut self,
warnings: &mut Warnings,
template: Option<&str>,
) -> Result<(), SubplotError>
pub fn typeset( &mut self, warnings: &mut Warnings, template: Option<&str>, ) -> Result<(), SubplotError>
Typeset a Subplot document.
Sourcepub fn scenarios(&self) -> Result<Vec<Scenario>, SubplotError>
pub fn scenarios(&self) -> Result<Vec<Scenario>, SubplotError>
Return all scenarios in a document.
Sourcepub fn matched_scenarios(
&self,
template: &str,
) -> Result<Vec<MatchedScenario>, SubplotError>
pub fn matched_scenarios( &self, template: &str, ) -> Result<Vec<MatchedScenario>, SubplotError>
Return matched scenarios in a document.
Sourcepub fn template(&self) -> Result<&str, SubplotError>
pub fn template(&self) -> Result<&str, SubplotError>
Extract a template name from this document