diff options
author | Lars Wirzenius <liw@liw.fi> | 2021-10-05 12:02:56 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2021-10-13 10:04:59 +0300 |
commit | 5855c963b8c1e1748f50301ddcc21a923be60240 (patch) | |
tree | 2b53f37057da8b93e9b67250de9104d7c0883795 /src/bin/cli/mod.rs | |
parent | 2459137129c64e02a2948f6c5f9e17bf56742c64 (diff) | |
download | subplot-5855c963b8c1e1748f50301ddcc21a923be60240.tar.gz |
feat: add crate subplot-build for using Subplot from build.rs
Make it easy to generate test code from a subplot in another project's
`build.rs` script.
Move the code to load documents and generate test code from
src/bin/subplot.rs and src/bin/cli/mod.rs to src/doc.rs so it can be
used without using the subplot executable.
Make the add_search_path function public so it can be used outside its
module. The subplot executable arranged for the directory where the
markdown input file resides to be added to the search path via another
way.
Sponsored-by: pep.foundation
Diffstat (limited to 'src/bin/cli/mod.rs')
-rw-r--r-- | src/bin/cli/mod.rs | 44 |
1 files changed, 0 insertions, 44 deletions
diff --git a/src/bin/cli/mod.rs b/src/bin/cli/mod.rs index c53da0f..84bda10 100644 --- a/src/bin/cli/mod.rs +++ b/src/bin/cli/mod.rs @@ -11,50 +11,6 @@ use std::str::FromStr; use subplot::{DataFile, Document, Style, SubplotError}; use tracing::{event, instrument, Level}; -#[instrument(level = "trace")] -pub fn load_document<P>(filename: P, style: Style) -> Result<Document> -where - P: AsRef<Path> + Debug, -{ - let filename = filename.as_ref(); - let base_path = subplot::get_basedir_from(filename); - event!( - Level::TRACE, - ?filename, - ?base_path, - "Loading document based at `{}` called `{}` with {:?}", - base_path.display(), - filename.display(), - style - ); - let doc = Document::from_file(&base_path, filename, style)?; - event!(Level::TRACE, "Loaded doc from file OK"); - - Ok(doc) -} - -#[instrument(level = "trace")] -pub fn load_document_with_pullmark<P>(filename: P, style: Style) -> Result<Document> -where - P: AsRef<Path> + Debug, -{ - let filename = filename.as_ref(); - let base_path = subplot::get_basedir_from(filename); - event!( - Level::TRACE, - ?filename, - ?base_path, - "Loading document based at `{}` called `{}` with {:?} using pullmark-cmark", - base_path.display(), - filename.display(), - style - ); - let doc = Document::from_file_with_pullmark(&base_path, filename, style)?; - event!(Level::TRACE, "Loaded doc from file OK"); - - Ok(doc) -} - pub fn extract_file<'a>(doc: &'a Document, filename: &str) -> Result<&'a DataFile> { for file in doc.files() { if file.filename() == filename { |