Use macros for the intermediate to render step.

This is largely to make changing the type signature of these functions easier by significantly reducing the amount of places that duplicates the signature.
This commit is contained in:
Tom Alexander
2023-10-31 19:48:05 -04:00
parent 5e476e189a
commit ae933b491e
56 changed files with 304 additions and 537 deletions

View File

@@ -6,6 +6,7 @@ use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IRegularLink;
use super::macros::render;
use super::RenderObject;
#[derive(Debug, Serialize)]
@@ -16,16 +17,17 @@ pub(crate) struct RenderRegularLink {
children: Vec<RenderObject>,
}
impl RenderRegularLink {
pub(crate) fn new(
config: &Config,
output_directory: &Path,
output_file: &Path,
regular_link: &IRegularLink,
) -> Result<RenderRegularLink, CustomError> {
render!(
RenderRegularLink,
IRegularLink,
original,
config,
output_directory,
output_file,
{
let children = {
let mut ret = Vec::new();
for obj in regular_link.children.iter() {
for obj in original.children.iter() {
ret.push(RenderObject::new(
config,
output_directory,
@@ -37,8 +39,8 @@ impl RenderRegularLink {
};
Ok(RenderRegularLink {
raw_link: regular_link.raw_link.clone(),
raw_link: original.raw_link.clone(),
children,
})
}
}
);