Struct 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 markdowns(&self) -> &[Markdown]

List of markdown files.

Source

pub fn toc(&self) -> &TableOfContents

Return table of contents.

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_bindings( &self, warnings: &mut Warnings, ) -> Result<(), SubplotError>

Check bindings for warnings

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, template: Option<&str>, ) -> Result<(), SubplotError>

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 T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where 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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more