Compare commits

..

No commits in common. "354d24cf696d4bc4904c1649d6a2166b9d044414" and "7b012302342669dff430d50b9243d14aede2a8c6" have entirely different histories.

19 changed files with 33 additions and 303 deletions

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IComment;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "comment")]
pub(crate) struct RenderComment {}
impl RenderComment {
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
config: &Config,
output_directory: D,
output_file: F,
comment: &IComment,
) -> Result<RenderComment, CustomError> {
Ok(RenderComment {})
}
}

View File

@ -1,49 +1,5 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IElement;
use super::comment::RenderComment;
use super::keyword::RenderKeyword;
use super::paragraph::RenderParagraph;
#[derive(Debug, Serialize)]
#[serde(untagged)]
pub(crate) enum RenderElement {
Paragraph(RenderParagraph),
Keyword(RenderKeyword),
Comment(RenderComment),
}
impl RenderElement {
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
config: &Config,
output_directory: D,
output_file: F,
element: &IElement,
) -> Result<RenderElement, CustomError> {
match element {
IElement::Paragraph(inner) => Ok(RenderElement::Paragraph(RenderParagraph::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::Keyword(inner) => Ok(RenderElement::Keyword(RenderKeyword::new(
config,
output_directory,
output_file,
inner,
)?)),
IElement::Comment(inner) => Ok(RenderElement::Comment(RenderComment::new(
config,
output_directory,
output_file,
inner,
)?)),
}
}
}
pub(crate) enum RenderElement {}

View File

@ -1,23 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IKeyword;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "keyword")]
pub(crate) struct RenderKeyword {}
impl RenderKeyword {
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
config: &Config,
output_directory: D,
output_file: F,
keyword: &IKeyword,
) -> Result<RenderKeyword, CustomError> {
Ok(RenderKeyword {})
}
}

View File

@ -1,12 +1,9 @@
mod blog_post_page;
mod comment;
mod document_element;
mod element;
mod global_settings;
mod heading;
mod keyword;
mod object;
mod paragraph;
mod plain_text;
mod section;
mod target;

View File

@ -1,32 +0,0 @@
use std::path::Path;
use serde::Serialize;
use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::IParagraph;
use super::RenderObject;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "paragraph")]
pub(crate) struct RenderParagraph {
children: Vec<RenderObject>,
}
impl RenderParagraph {
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
config: &Config,
output_directory: D,
output_file: F,
paragraph: &IParagraph,
) -> Result<RenderParagraph, CustomError> {
let children = paragraph
.children
.iter()
.map(|obj| RenderObject::new(config, &output_directory, &output_file, obj))
.collect::<Result<Vec<_>, _>>()?;
Ok(RenderParagraph { children })
}
}

View File

@ -8,7 +8,7 @@ use crate::intermediate::IPlainText;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "plain_text")]
#[serde(rename = "heading")]
pub(crate) struct RenderPlainText {}
impl RenderPlainText {

View File

@ -6,14 +6,10 @@ use crate::config::Config;
use crate::error::CustomError;
use crate::intermediate::ISection;
use super::RenderElement;
#[derive(Debug, Serialize)]
#[serde(tag = "type")]
#[serde(rename = "section")]
pub(crate) struct RenderSection {
children: Vec<RenderElement>,
}
pub(crate) struct RenderSection {}
impl RenderSection {
pub(crate) fn new<D: AsRef<Path>, F: AsRef<Path>>(
@ -22,12 +18,6 @@ impl RenderSection {
output_file: F,
section: &ISection,
) -> Result<RenderSection, CustomError> {
let children = section
.children
.iter()
.map(|obj| RenderElement::new(config, &output_directory, &output_file, obj))
.collect::<Result<Vec<_>, _>>()?;
Ok(RenderSection { children })
Ok(RenderSection {})
}
}

View File

@ -1,16 +0,0 @@
use crate::error::CustomError;
use super::registry::Registry;
/// Essentially a no-op since the comment is not rendered.
#[derive(Debug)]
pub(crate) struct IComment {}
impl IComment {
pub(crate) async fn new<'parse>(
registry: &mut Registry<'parse>,
comment: &organic::types::Comment<'parse>,
) -> Result<IComment, CustomError> {
Ok(IComment {})
}
}

View File

@ -61,14 +61,11 @@ impl BlogPost {
let mut ret = Vec::new();
for (real_path, _contents, parsed_document) in parsed_org_files.iter() {
let relative_to_post_dir_path = real_path.strip_prefix(post_dir)?;
ret.push(
BlogPostPage::new(
relative_to_post_dir_path,
&mut registry,
parsed_document,
)
.await?,
);
ret.push(BlogPostPage::new(
relative_to_post_dir_path,
&mut registry,
parsed_document,
)?);
}
ret
};

View File

@ -1,53 +1,2 @@
use crate::error::CustomError;
use super::comment::IComment;
use super::keyword::IKeyword;
use super::registry::Registry;
use super::IParagraph;
#[derive(Debug)]
pub(crate) enum IElement {
Paragraph(IParagraph),
Keyword(IKeyword),
Comment(IComment),
}
impl IElement {
pub(crate) async fn new<'parse>(
registry: &mut Registry<'parse>,
elem: &organic::types::Element<'parse>,
) -> Result<IElement, CustomError> {
match elem {
organic::types::Element::Paragraph(inner) => {
Ok(IElement::Paragraph(IParagraph::new(registry, inner).await?))
}
organic::types::Element::PlainList(_) => todo!(),
organic::types::Element::CenterBlock(_) => todo!(),
organic::types::Element::QuoteBlock(_) => todo!(),
organic::types::Element::SpecialBlock(_) => todo!(),
organic::types::Element::DynamicBlock(_) => todo!(),
organic::types::Element::FootnoteDefinition(_) => todo!(),
organic::types::Element::Comment(inner) => {
Ok(IElement::Comment(IComment::new(registry, inner).await?))
}
organic::types::Element::Drawer(_) => todo!(),
organic::types::Element::PropertyDrawer(_) => todo!(),
organic::types::Element::Table(_) => todo!(),
organic::types::Element::VerseBlock(_) => todo!(),
organic::types::Element::CommentBlock(_) => todo!(),
organic::types::Element::ExampleBlock(_) => todo!(),
organic::types::Element::ExportBlock(_) => todo!(),
organic::types::Element::SrcBlock(_) => todo!(),
organic::types::Element::Clock(_) => todo!(),
organic::types::Element::DiarySexp(_) => todo!(),
organic::types::Element::Planning(_) => todo!(),
organic::types::Element::FixedWidthArea(_) => todo!(),
organic::types::Element::HorizontalRule(_) => todo!(),
organic::types::Element::Keyword(inner) => {
Ok(IElement::Keyword(IKeyword::new(registry, inner).await?))
}
organic::types::Element::BabelCall(_) => todo!(),
organic::types::Element::LatexEnvironment(_) => todo!(),
}
}
}
pub(crate) enum IElement {}

View File

@ -10,17 +10,15 @@ pub(crate) struct IHeading {
}
impl IHeading {
pub(crate) async fn new<'parse>(
pub(crate) fn new<'parse>(
registry: &mut Registry<'parse>,
heading: &organic::types::Heading<'parse>,
) -> Result<IHeading, CustomError> {
let title = {
let mut ret = Vec::new();
for obj in heading.title.iter() {
ret.push(IObject::new(registry, obj).await?);
}
ret
};
let title = heading
.title
.iter()
.map(|obj| IObject::new(registry, obj))
.collect::<Result<Vec<_>, _>>()?;
Ok(IHeading {
title,
level: heading.level,

View File

@ -1,16 +0,0 @@
use crate::error::CustomError;
use super::registry::Registry;
/// Essentially a no-op since the keyword is not rendered and any relevant impact on other elements is pulled from the parsed form of keyword.
#[derive(Debug)]
pub(crate) struct IKeyword {}
impl IKeyword {
pub(crate) async fn new<'parse>(
registry: &mut Registry<'parse>,
keyword: &organic::types::Keyword<'parse>,
) -> Result<IKeyword, CustomError> {
Ok(IKeyword {})
}
}

View File

@ -1,28 +1,22 @@
mod comment;
mod convert;
mod definition;
mod document_element;
mod element;
mod heading;
mod keyword;
mod object;
mod page;
mod paragraph;
mod plain_text;
mod registry;
mod section;
mod target;
mod util;
pub(crate) use comment::IComment;
pub(crate) use convert::convert_blog_post_page_to_render_context;
pub(crate) use definition::BlogPost;
pub(crate) use document_element::IDocumentElement;
pub(crate) use element::IElement;
pub(crate) use heading::IHeading;
pub(crate) use keyword::IKeyword;
pub(crate) use object::IObject;
pub(crate) use page::BlogPostPage;
pub(crate) use paragraph::IParagraph;
pub(crate) use plain_text::IPlainText;
pub(crate) use section::ISection;
pub(crate) use target::ITarget;

View File

@ -11,7 +11,7 @@ pub(crate) enum IObject {
}
impl IObject {
pub(crate) async fn new<'parse>(
pub(crate) fn new<'parse>(
registry: &mut Registry<'parse>,
obj: &organic::types::Object<'parse>,
) -> Result<IObject, CustomError> {
@ -22,8 +22,8 @@ impl IObject {
organic::types::Object::StrikeThrough(_) => todo!(),
organic::types::Object::Code(_) => todo!(),
organic::types::Object::Verbatim(_) => todo!(),
organic::types::Object::PlainText(inner) => {
Ok(IObject::PlainText(IPlainText::new(registry, inner).await?))
organic::types::Object::PlainText(plain_text) => {
Ok(IObject::PlainText(IPlainText::new(registry, plain_text)?))
}
organic::types::Object::RegularLink(_) => todo!(),
organic::types::Object::RadioLink(_) => todo!(),
@ -40,8 +40,8 @@ impl IObject {
organic::types::Object::InlineBabelCall(_) => todo!(),
organic::types::Object::InlineSourceBlock(_) => todo!(),
organic::types::Object::LineBreak(_) => todo!(),
organic::types::Object::Target(inner) => {
Ok(IObject::Target(ITarget::new(registry, inner).await?))
organic::types::Object::Target(target) => {
Ok(IObject::Target(ITarget::new(registry, target)?))
}
organic::types::Object::StatisticsCookie(_) => todo!(),
organic::types::Object::Subscript(_) => todo!(),

View File

@ -18,7 +18,7 @@ pub(crate) struct BlogPostPage {
}
impl BlogPostPage {
pub(crate) async fn new<'parse, P: Into<PathBuf>>(
pub(crate) fn new<'parse, P: Into<PathBuf>>(
path: P,
registry: &mut Registry<'parse>,
document: &organic::types::Document<'parse>,
@ -26,14 +26,10 @@ impl BlogPostPage {
let path = path.into();
let mut children = Vec::new();
if let Some(section) = document.zeroth_section.as_ref() {
children.push(IDocumentElement::Section(
ISection::new(registry, section).await?,
));
children.push(IDocumentElement::Section(ISection::new(registry, section)?));
}
for heading in document.children.iter() {
children.push(IDocumentElement::Heading(
IHeading::new(registry, heading).await?,
));
children.push(IDocumentElement::Heading(IHeading::new(registry, heading)?));
}
Ok(BlogPostPage {

View File

@ -1,26 +0,0 @@
use crate::error::CustomError;
use super::registry::Registry;
use super::IObject;
#[derive(Debug)]
pub(crate) struct IParagraph {
pub(crate) children: Vec<IObject>,
}
impl IParagraph {
pub(crate) async fn new<'parse>(
registry: &mut Registry<'parse>,
paragraph: &organic::types::Paragraph<'parse>,
) -> Result<IParagraph, CustomError> {
let children = {
let mut ret = Vec::new();
for obj in paragraph.children.iter() {
ret.push(IObject::new(registry, obj).await?);
}
ret
};
Ok(IParagraph { children })
}
}

View File

@ -9,9 +9,9 @@ pub(crate) struct IPlainText {
}
impl IPlainText {
pub(crate) async fn new<'parse>(
registry: &mut Registry<'parse>,
plain_text: &organic::types::PlainText<'parse>,
pub(crate) fn new(
registry: &mut Registry<'_>,
plain_text: &organic::types::PlainText<'_>,
) -> Result<IPlainText, CustomError> {
Ok(IPlainText {
source: coalesce_whitespace(plain_text.source).into_owned(),

View File

@ -1,26 +1,15 @@
use crate::error::CustomError;
use super::registry::Registry;
use super::IElement;
#[derive(Debug)]
pub(crate) struct ISection {
pub(crate) children: Vec<IElement>,
}
pub(crate) struct ISection {}
impl ISection {
pub(crate) async fn new<'parse>(
registry: &mut Registry<'parse>,
section: &organic::types::Section<'parse>,
pub(crate) fn new(
registry: &mut Registry<'_>,
section: &organic::types::Section<'_>,
) -> Result<ISection, CustomError> {
let children = {
let mut ret = Vec::new();
for elem in section.children.iter() {
ret.push(IElement::new(registry, elem).await?);
}
ret
};
Ok(ISection { children })
Ok(ISection {})
}
}

View File

@ -10,7 +10,7 @@ pub(crate) struct ITarget {
}
impl ITarget {
pub(crate) async fn new<'parse>(
pub(crate) fn new<'parse>(
registry: &mut Registry<'parse>,
target: &organic::types::Target<'parse>,
) -> Result<ITarget, CustomError> {