Struct subplot::Document

source ·
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

source

pub fn from_file( basedir: &Path, filename: &Path, style: Style, template: Option<&str> ) -> Result<Document, SubplotError>

Construct a Document from a named file.

source

pub fn to_html(&mut self, date: &str) -> Result<String, SubplotError>

Return Document as an HTML page serialized into HTML text

source

pub fn meta(&self) -> &Metadata

Return the document’s metadata.

source

pub fn set_date(&mut self, date: String)

Set document date.

source

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.

source

pub fn embedded_files(&self) -> &[EmbeddedFile]

Return list of files embeddedin the document.

source

pub fn lint(&self) -> Result<(), SubplotError>

Check the document for common problems.

source

pub fn check_named_code_blocks_have_appropriate_class( &self, warnings: &mut Warnings ) -> Result<bool, SubplotError>

Check labelled code blocks have some appropriate class

source

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.

source

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.

source

pub fn check_matched_steps_have_impl( &self, template: &str, warnings: &mut Warnings ) -> bool

Check that all matched steps actually have function implementations

source

pub fn typeset(&mut self, warnings: &mut Warnings)

Typeset a Subplot document.

source

pub fn scenarios(&self) -> Result<Vec<Scenario>, SubplotError>

Return all scenarios in a document.

source

pub fn matched_scenarios( &self, template: &str ) -> Result<Vec<MatchedScenario>, SubplotError>

Return matched scenarios in a document.

source

pub fn template(&self) -> Result<&str, SubplotError>

Extract a template name from this document

Trait Implementations§

source§

impl Debug for Document

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.