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 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_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 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