diff options
author | Lars Wirzenius <liw@liw.fi> | 2023-06-21 05:27:25 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2023-06-21 05:27:25 +0300 |
commit | d8e88bcdf5fddab3757d64cb7ca4c355480a8ca5 (patch) | |
tree | 3d8c953216c94d505f4b21e849181451f8889a13 /src | |
parent | 39601b16c513fe3f1f60cb260fae2e046f7eadaf (diff) | |
download | subplot-d8e88bcdf5fddab3757d64cb7ca4c355480a8ca5.tar.gz |
refactor: inline Document::from_ast to its only call site
The extra method doesn't provide anything useful to it's better inline.
Sponsored-by: author
Diffstat (limited to 'src')
-rw-r--r-- | src/doc.rs | 24 |
1 files changed, 4 insertions, 20 deletions
@@ -95,25 +95,6 @@ impl Document { doc } - fn from_ast<P>( - basedir: P, - subplot: PathBuf, - yamlmeta: &YamlMetadata, - markdowns: Vec<Markdown>, - style: Style, - template: Option<&str>, - ) -> Result<Document, SubplotError> - where - P: AsRef<Path> + Debug, - { - let meta = Metadata::from_yaml_metadata(basedir, yamlmeta, template)?; - trace!("metadata from YAML: {:#?}", meta); - let files = Self::all_files(&markdowns)?; - let doc = Document::new(subplot, markdowns, meta, files, style); - trace!("Loaded from JSON OK"); - Ok(doc) - } - fn all_files(markdowns: &[Markdown]) -> Result<EmbeddedFiles, SubplotError> { let mut files = EmbeddedFiles::default(); for md in markdowns { @@ -146,7 +127,10 @@ impl Document { markdowns.push(Markdown::load_file(&filename)?); } - let doc = Self::from_ast(basedir, filename.into(), &meta, markdowns, style, template)?; + let meta = Metadata::from_yaml_metadata(basedir, &meta, template)?; + trace!("metadata from YAML: {:#?}", meta); + let files = Self::all_files(&markdowns)?; + let doc = Document::new(filename.into(), markdowns, meta, files, style); trace!("Loaded document OK"); Ok(doc) |