Put back in needed pubs.

This commit is contained in:
Tom Alexander
2023-09-11 13:13:28 -04:00
parent 7650a9edff
commit 84953c1669
71 changed files with 522 additions and 515 deletions

View File

@@ -2,42 +2,42 @@ use super::Element;
use super::Object;
use super::Source;
type PriorityCookie = u8;
pub type PriorityCookie = u8;
#[derive(Debug)]
struct Document<'s> {
source: &'s str,
zeroth_section: Option<Section<'s>>,
children: Vec<Heading<'s>>,
pub struct Document<'s> {
pub source: &'s str,
pub zeroth_section: Option<Section<'s>>,
pub children: Vec<Heading<'s>>,
}
#[derive(Debug)]
struct Heading<'s> {
source: &'s str,
stars: usize,
todo_keyword: Option<(TodoKeywordType, &'s str)>,
priority_cookie: Option<PriorityCookie>,
title: Vec<Object<'s>>,
tags: Vec<&'s str>,
children: Vec<DocumentElement<'s>>,
is_comment: bool,
is_archived: bool,
pub struct Heading<'s> {
pub source: &'s str,
pub stars: usize,
pub todo_keyword: Option<(TodoKeywordType, &'s str)>,
pub priority_cookie: Option<PriorityCookie>,
pub title: Vec<Object<'s>>,
pub tags: Vec<&'s str>,
pub children: Vec<DocumentElement<'s>>,
pub is_comment: bool,
pub is_archived: bool,
}
#[derive(Debug)]
struct Section<'s> {
source: &'s str,
children: Vec<Element<'s>>,
pub struct Section<'s> {
pub source: &'s str,
pub children: Vec<Element<'s>>,
}
#[derive(Debug)]
enum DocumentElement<'s> {
pub enum DocumentElement<'s> {
Heading(Heading<'s>),
Section(Section<'s>),
}
#[derive(Debug)]
enum TodoKeywordType {
pub enum TodoKeywordType {
Todo,
Done,
}

View File

@@ -23,7 +23,7 @@ use super::SetSource;
use super::Source;
#[derive(Debug)]
enum Element<'s> {
pub enum Element<'s> {
Paragraph(Paragraph<'s>),
PlainList(PlainList<'s>),
GreaterBlock(GreaterBlock<'s>),
@@ -51,28 +51,28 @@ use super::Source;
impl<'s> Source<'s> for Element<'s> {
fn get_source(&'s self) -> &'s str {
match self {
Element::Paragraph(obj) => obj.source,
Element::PlainList(obj) => obj.source,
Element::GreaterBlock(obj) => obj.source,
Element::DynamicBlock(obj) => obj.source,
Element::FootnoteDefinition(obj) => obj.source,
Element::Comment(obj) => obj.source,
Element::Drawer(obj) => obj.source,
Element::PropertyDrawer(obj) => obj.source,
Element::Table(obj) => obj.source,
Element::VerseBlock(obj) => obj.source,
Element::CommentBlock(obj) => obj.source,
Element::ExampleBlock(obj) => obj.source,
Element::ExportBlock(obj) => obj.source,
Element::SrcBlock(obj) => obj.source,
Element::Clock(obj) => obj.source,
Element::DiarySexp(obj) => obj.source,
Element::Planning(obj) => obj.source,
Element::FixedWidthArea(obj) => obj.source,
Element::HorizontalRule(obj) => obj.source,
Element::Keyword(obj) => obj.source,
Element::BabelCall(obj) => obj.source,
Element::LatexEnvironment(obj) => obj.source,
Element::Paragraph(obj) => obj.get_source(),
Element::PlainList(obj) => obj.get_source(),
Element::GreaterBlock(obj) => obj.get_source(),
Element::DynamicBlock(obj) => obj.get_source(),
Element::FootnoteDefinition(obj) => obj.get_source(),
Element::Comment(obj) => obj.get_source(),
Element::Drawer(obj) => obj.get_source(),
Element::PropertyDrawer(obj) => obj.get_source(),
Element::Table(obj) => obj.get_source(),
Element::VerseBlock(obj) => obj.get_source(),
Element::CommentBlock(obj) => obj.get_source(),
Element::ExampleBlock(obj) => obj.get_source(),
Element::ExportBlock(obj) => obj.get_source(),
Element::SrcBlock(obj) => obj.get_source(),
Element::Clock(obj) => obj.get_source(),
Element::DiarySexp(obj) => obj.get_source(),
Element::Planning(obj) => obj.get_source(),
Element::FixedWidthArea(obj) => obj.get_source(),
Element::HorizontalRule(obj) => obj.get_source(),
Element::Keyword(obj) => obj.get_source(),
Element::BabelCall(obj) => obj.get_source(),
Element::LatexEnvironment(obj) => obj.get_source(),
}
}
}

View File

@@ -5,73 +5,73 @@ use super::Object;
use super::Source;
#[derive(Debug)]
struct PlainList<'s> {
source: &'s str,
children: Vec<PlainListItem<'s>>,
pub struct PlainList<'s> {
pub source: &'s str,
pub children: Vec<PlainListItem<'s>>,
}
#[derive(Debug)]
struct PlainListItem<'s> {
source: &'s str,
indentation: usize,
bullet: &'s str,
tag: Vec<Object<'s>>,
children: Vec<Element<'s>>,
pub struct PlainListItem<'s> {
pub source: &'s str,
pub indentation: usize,
pub bullet: &'s str,
pub tag: Vec<Object<'s>>,
pub children: Vec<Element<'s>>,
}
#[derive(Debug)]
struct GreaterBlock<'s> {
source: &'s str,
name: &'s str,
parameters: Option<&'s str>,
children: Vec<Element<'s>>,
pub struct GreaterBlock<'s> {
pub source: &'s str,
pub name: &'s str,
pub parameters: Option<&'s str>,
pub children: Vec<Element<'s>>,
}
#[derive(Debug)]
struct DynamicBlock<'s> {
source: &'s str,
name: &'s str,
parameters: Option<&'s str>,
children: Vec<Element<'s>>,
pub struct DynamicBlock<'s> {
pub source: &'s str,
pub name: &'s str,
pub parameters: Option<&'s str>,
pub children: Vec<Element<'s>>,
}
#[derive(Debug)]
struct FootnoteDefinition<'s> {
source: &'s str,
label: &'s str,
children: Vec<Element<'s>>,
pub struct FootnoteDefinition<'s> {
pub source: &'s str,
pub label: &'s str,
pub children: Vec<Element<'s>>,
}
#[derive(Debug)]
struct Drawer<'s> {
source: &'s str,
name: &'s str,
children: Vec<Element<'s>>,
pub struct Drawer<'s> {
pub source: &'s str,
pub name: &'s str,
pub children: Vec<Element<'s>>,
}
#[derive(Debug)]
struct PropertyDrawer<'s> {
source: &'s str,
children: Vec<NodeProperty<'s>>,
pub struct PropertyDrawer<'s> {
pub source: &'s str,
pub children: Vec<NodeProperty<'s>>,
}
#[derive(Debug)]
struct NodeProperty<'s> {
source: &'s str,
value: Option<&'s str>,
pub struct NodeProperty<'s> {
pub source: &'s str,
pub value: Option<&'s str>,
}
#[derive(Debug)]
struct Table<'s> {
source: &'s str,
formulas: Vec<Keyword<'s>>,
children: Vec<TableRow<'s>>,
pub struct Table<'s> {
pub source: &'s str,
pub formulas: Vec<Keyword<'s>>,
pub children: Vec<TableRow<'s>>,
}
#[derive(Debug)]
struct TableRow<'s> {
source: &'s str,
children: Vec<TableCell<'s>>,
pub struct TableRow<'s> {
pub source: &'s str,
pub children: Vec<TableCell<'s>>,
}
impl<'s> Source<'s> for PlainList<'s> {

View File

@@ -3,101 +3,101 @@ use super::PlainText;
use super::Source;
#[derive(Debug)]
struct Paragraph<'s> {
source: &'s str,
children: Vec<Object<'s>>,
pub struct Paragraph<'s> {
pub source: &'s str,
pub children: Vec<Object<'s>>,
}
#[derive(Debug)]
struct Comment<'s> {
source: &'s str,
pub struct Comment<'s> {
pub source: &'s str,
}
#[derive(Debug)]
struct TableCell<'s> {
source: &'s str,
children: Vec<Object<'s>>,
pub struct TableCell<'s> {
pub source: &'s str,
pub children: Vec<Object<'s>>,
}
#[derive(Debug)]
struct VerseBlock<'s> {
source: &'s str,
name: &'s str,
data: Option<&'s str>,
children: Vec<Object<'s>>,
pub struct VerseBlock<'s> {
pub source: &'s str,
pub name: &'s str,
pub data: Option<&'s str>,
pub children: Vec<Object<'s>>,
}
#[derive(Debug)]
struct CommentBlock<'s> {
source: &'s str,
name: &'s str,
data: Option<&'s str>,
contents: &'s str,
pub struct CommentBlock<'s> {
pub source: &'s str,
pub name: &'s str,
pub data: Option<&'s str>,
pub contents: &'s str,
}
#[derive(Debug)]
struct ExampleBlock<'s> {
source: &'s str,
name: &'s str,
data: Option<&'s str>,
contents: &'s str,
pub struct ExampleBlock<'s> {
pub source: &'s str,
pub name: &'s str,
pub data: Option<&'s str>,
pub contents: &'s str,
}
#[derive(Debug)]
struct ExportBlock<'s> {
source: &'s str,
name: &'s str,
data: Option<&'s str>,
contents: &'s str,
pub struct ExportBlock<'s> {
pub source: &'s str,
pub name: &'s str,
pub data: Option<&'s str>,
pub contents: &'s str,
}
#[derive(Debug)]
struct SrcBlock<'s> {
source: &'s str,
name: &'s str,
data: Option<&'s str>,
contents: &'s str,
pub struct SrcBlock<'s> {
pub source: &'s str,
pub name: &'s str,
pub data: Option<&'s str>,
pub contents: &'s str,
}
#[derive(Debug)]
struct Clock<'s> {
source: &'s str,
pub struct Clock<'s> {
pub source: &'s str,
}
#[derive(Debug)]
struct DiarySexp<'s> {
source: &'s str,
pub struct DiarySexp<'s> {
pub source: &'s str,
}
#[derive(Debug)]
struct Planning<'s> {
source: &'s str,
pub struct Planning<'s> {
pub source: &'s str,
}
#[derive(Debug)]
struct FixedWidthArea<'s> {
source: &'s str,
pub struct FixedWidthArea<'s> {
pub source: &'s str,
}
#[derive(Debug)]
struct HorizontalRule<'s> {
source: &'s str,
pub struct HorizontalRule<'s> {
pub source: &'s str,
}
#[derive(Debug)]
struct Keyword<'s> {
source: &'s str,
key: &'s str,
value: &'s str,
pub struct Keyword<'s> {
pub source: &'s str,
pub key: &'s str,
pub value: &'s str,
}
#[derive(Debug)]
struct LatexEnvironment<'s> {
source: &'s str,
pub struct LatexEnvironment<'s> {
pub source: &'s str,
}
impl<'s> Paragraph<'s> {
fn of_text(input: &'s str) -> Self {
pub(crate) fn of_text(input: &'s str) -> Self {
let mut objects = Vec::with_capacity(1);
objects.push(Object::PlainText(PlainText { source: input }));
Paragraph {

View File

@@ -4,65 +4,65 @@ mod greater_element;
mod lesser_element;
mod object;
mod source;
use document::Document;
use document::DocumentElement;
use document::Heading;
use document::PriorityCookie;
use document::Section;
use document::TodoKeywordType;
use element::Element;
use greater_element::Drawer;
use greater_element::DynamicBlock;
use greater_element::FootnoteDefinition;
use greater_element::GreaterBlock;
use greater_element::NodeProperty;
use greater_element::PlainList;
use greater_element::PlainListItem;
use greater_element::PropertyDrawer;
use greater_element::Table;
use greater_element::TableRow;
use lesser_element::Clock;
use lesser_element::Comment;
use lesser_element::CommentBlock;
use lesser_element::DiarySexp;
use lesser_element::ExampleBlock;
use lesser_element::ExportBlock;
use lesser_element::FixedWidthArea;
use lesser_element::HorizontalRule;
use lesser_element::Keyword;
use lesser_element::LatexEnvironment;
use lesser_element::Paragraph;
use lesser_element::Planning;
use lesser_element::SrcBlock;
use lesser_element::TableCell;
use lesser_element::VerseBlock;
use object::AngleLink;
use object::Bold;
use object::Citation;
use object::CitationReference;
use object::Code;
use object::Entity;
use object::ExportSnippet;
use object::FootnoteReference;
use object::InlineBabelCall;
use object::InlineSourceBlock;
use object::Italic;
use object::LatexFragment;
use object::LineBreak;
use object::Object;
use object::OrgMacro;
use object::PlainLink;
use object::PlainText;
use object::RadioLink;
use object::RadioTarget;
use object::RegularLink;
use object::StatisticsCookie;
use object::StrikeThrough;
use object::Subscript;
use object::Superscript;
use object::Target;
use object::Timestamp;
use object::Underline;
use object::Verbatim;
use source::SetSource;
use source::Source;
pub use document::Document;
pub use document::DocumentElement;
pub use document::Heading;
pub use document::PriorityCookie;
pub use document::Section;
pub use document::TodoKeywordType;
pub use element::Element;
pub use greater_element::Drawer;
pub use greater_element::DynamicBlock;
pub use greater_element::FootnoteDefinition;
pub use greater_element::GreaterBlock;
pub use greater_element::NodeProperty;
pub use greater_element::PlainList;
pub use greater_element::PlainListItem;
pub use greater_element::PropertyDrawer;
pub use greater_element::Table;
pub use greater_element::TableRow;
pub use lesser_element::Clock;
pub use lesser_element::Comment;
pub use lesser_element::CommentBlock;
pub use lesser_element::DiarySexp;
pub use lesser_element::ExampleBlock;
pub use lesser_element::ExportBlock;
pub use lesser_element::FixedWidthArea;
pub use lesser_element::HorizontalRule;
pub use lesser_element::Keyword;
pub use lesser_element::LatexEnvironment;
pub use lesser_element::Paragraph;
pub use lesser_element::Planning;
pub use lesser_element::SrcBlock;
pub use lesser_element::TableCell;
pub use lesser_element::VerseBlock;
pub use object::AngleLink;
pub use object::Bold;
pub use object::Citation;
pub use object::CitationReference;
pub use object::Code;
pub use object::Entity;
pub use object::ExportSnippet;
pub use object::FootnoteReference;
pub use object::InlineBabelCall;
pub use object::InlineSourceBlock;
pub use object::Italic;
pub use object::LatexFragment;
pub use object::LineBreak;
pub use object::Object;
pub use object::OrgMacro;
pub use object::PlainLink;
pub use object::PlainText;
pub use object::RadioLink;
pub use object::RadioTarget;
pub use object::RegularLink;
pub use object::StatisticsCookie;
pub use object::StrikeThrough;
pub use object::Subscript;
pub use object::Superscript;
pub use object::Target;
pub use object::Timestamp;
pub use object::Underline;
pub use object::Verbatim;
pub use source::SetSource;
pub use source::Source;

View File

@@ -1,7 +1,7 @@
use super::Source;
#[derive(Debug, PartialEq)]
enum Object<'s> {
pub enum Object<'s> {
Bold(Bold<'s>),
Italic(Italic<'s>),
Underline(Underline<'s>),
@@ -32,157 +32,157 @@ use super::Source;
}
#[derive(Debug, PartialEq)]
struct Bold<'s> {
source: &'s str,
children: Vec<Object<'s>>,
pub struct Bold<'s> {
pub source: &'s str,
pub children: Vec<Object<'s>>,
}
#[derive(Debug, PartialEq)]
struct Italic<'s> {
source: &'s str,
children: Vec<Object<'s>>,
pub struct Italic<'s> {
pub source: &'s str,
pub children: Vec<Object<'s>>,
}
#[derive(Debug, PartialEq)]
struct Underline<'s> {
source: &'s str,
children: Vec<Object<'s>>,
pub struct Underline<'s> {
pub source: &'s str,
pub children: Vec<Object<'s>>,
}
#[derive(Debug, PartialEq)]
struct StrikeThrough<'s> {
source: &'s str,
children: Vec<Object<'s>>,
pub struct StrikeThrough<'s> {
pub source: &'s str,
pub children: Vec<Object<'s>>,
}
#[derive(Debug, PartialEq)]
struct Code<'s> {
source: &'s str,
contents: &'s str,
pub struct Code<'s> {
pub source: &'s str,
pub contents: &'s str,
}
#[derive(Debug, PartialEq)]
struct Verbatim<'s> {
source: &'s str,
contents: &'s str,
pub struct Verbatim<'s> {
pub source: &'s str,
pub contents: &'s str,
}
#[derive(Debug, PartialEq)]
struct PlainText<'s> {
source: &'s str,
pub struct PlainText<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
struct RegularLink<'s> {
source: &'s str,
pub struct RegularLink<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
struct RadioTarget<'s> {
source: &'s str,
children: Vec<Object<'s>>,
pub struct RadioTarget<'s> {
pub source: &'s str,
pub children: Vec<Object<'s>>,
}
#[derive(Debug, PartialEq)]
struct RadioLink<'s> {
source: &'s str,
children: Vec<Object<'s>>,
pub struct RadioLink<'s> {
pub source: &'s str,
pub children: Vec<Object<'s>>,
}
#[derive(Debug, PartialEq)]
struct PlainLink<'s> {
source: &'s str,
link_type: &'s str,
path: &'s str,
pub struct PlainLink<'s> {
pub source: &'s str,
pub link_type: &'s str,
pub path: &'s str,
}
#[derive(Debug, PartialEq)]
struct AngleLink<'s> {
source: &'s str,
link_type: &'s str,
path: &'s str,
pub struct AngleLink<'s> {
pub source: &'s str,
pub link_type: &'s str,
pub path: &'s str,
}
#[derive(Debug, PartialEq)]
struct OrgMacro<'s> {
source: &'s str,
macro_name: &'s str,
macro_args: Vec<&'s str>,
pub struct OrgMacro<'s> {
pub source: &'s str,
pub macro_name: &'s str,
pub macro_args: Vec<&'s str>,
}
#[derive(Debug, PartialEq)]
struct Entity<'s> {
source: &'s str,
entity_name: &'s str,
pub struct Entity<'s> {
pub source: &'s str,
pub entity_name: &'s str,
}
#[derive(Debug, PartialEq)]
struct LatexFragment<'s> {
source: &'s str,
pub struct LatexFragment<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
struct ExportSnippet<'s> {
source: &'s str,
backend: &'s str,
contents: Option<&'s str>,
pub struct ExportSnippet<'s> {
pub source: &'s str,
pub backend: &'s str,
pub contents: Option<&'s str>,
}
#[derive(Debug, PartialEq)]
struct FootnoteReference<'s> {
source: &'s str,
label: Option<&'s str>,
definition: Vec<Object<'s>>,
pub struct FootnoteReference<'s> {
pub source: &'s str,
pub label: Option<&'s str>,
pub definition: Vec<Object<'s>>,
}
#[derive(Debug, PartialEq)]
struct Citation<'s> {
source: &'s str,
pub struct Citation<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
struct CitationReference<'s> {
source: &'s str,
pub struct CitationReference<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
struct InlineBabelCall<'s> {
source: &'s str,
pub struct InlineBabelCall<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
struct InlineSourceBlock<'s> {
source: &'s str,
pub struct InlineSourceBlock<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
struct LineBreak<'s> {
source: &'s str,
pub struct LineBreak<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
struct Target<'s> {
source: &'s str,
pub struct Target<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
struct StatisticsCookie<'s> {
source: &'s str,
pub struct StatisticsCookie<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
struct Subscript<'s> {
source: &'s str,
pub struct Subscript<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
struct Superscript<'s> {
source: &'s str,
pub struct Superscript<'s> {
pub source: &'s str,
}
#[derive(Debug, PartialEq)]
struct Timestamp<'s> {
source: &'s str,
pub struct Timestamp<'s> {
pub source: &'s str,
}
impl<'s> Source<'s> for Object<'s> {

View File

@@ -1,6 +1,6 @@
trait Source<'s> {
pub trait Source<'s> {
fn get_source(&'s self) -> &'s str;
}
trait SetSource<'s> {
pub trait SetSource<'s> {
fn set_source(&mut self, source: &'s str);
}