Compare commits

...

9 Commits

Author SHA1 Message Date
Tom Alexander
ff3e0a50af
Implement dynamic block.
Some checks failed
clippy Build clippy has failed
rust-foreign-document-test Build rust-foreign-document-test has succeeded
rust-build Build rust-build has failed
rust-test Build rust-test has failed
2023-12-30 20:56:35 -05:00
Tom Alexander
03c8c07fe0
Implement quote block. 2023-12-30 20:53:20 -05:00
Tom Alexander
3a6fc5b669
Support noop on all token types. 2023-12-30 20:50:28 -05:00
Tom Alexander
d258cdb839
Support null vs noop comparison. 2023-12-30 20:47:17 -05:00
Tom Alexander
aa5629354e
Implement special block. 2023-12-30 20:43:01 -05:00
Tom Alexander
efc4a04829
Implement center block. 2023-12-30 20:38:08 -05:00
Tom Alexander
dd611ea64a
Fix plain list item. 2023-12-30 20:35:27 -05:00
Tom Alexander
4bd5f3bec7
Implement node property. 2023-12-30 19:01:07 -05:00
Tom Alexander
c2b3509b6a
Implement property drawer. 2023-12-30 18:59:52 -05:00
8 changed files with 62 additions and 27 deletions

View File

@ -7,6 +7,7 @@ use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::types::CenterBlock;
use crate::types::GetAffiliatedKeywords;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
@ -21,8 +22,12 @@ to_wasm!(
original,
wasm_context,
{ WasmAstNode::CenterBlock(original) },
{ "TODO".into() },
{ "center-block".into() },
{
let additional_properties = original
.get_affiliated_keywords()
.to_wasm(wasm_context.clone())?;
let children = original
.children
.iter()
@ -36,7 +41,7 @@ to_wasm!(
Ok((
children,
WasmCenterBlock {
additional_properties: AdditionalProperties::default(),
additional_properties,
},
))
}

View File

@ -7,12 +7,16 @@ use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::types::DynamicBlock;
use crate::types::GetAffiliatedKeywords;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
pub struct WasmDynamicBlock {
#[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties,
#[serde(rename = "block-name")]
pub(crate) block_name: String,
pub(crate) arguments: Option<String>,
}
to_wasm!(
@ -21,8 +25,12 @@ to_wasm!(
original,
wasm_context,
{ WasmAstNode::DynamicBlock(original) },
{ "TODO".into() },
{ "dynamic-block".into() },
{
let additional_properties = original
.get_affiliated_keywords()
.to_wasm(wasm_context.clone())?;
let children = original
.children
.iter()
@ -36,7 +44,9 @@ to_wasm!(
Ok((
children,
WasmDynamicBlock {
additional_properties: AdditionalProperties::default(),
additional_properties,
block_name: original.block_name.to_owned(),
arguments: original.parameters.map(|s| s.to_owned()),
},
))
}

View File

@ -4,15 +4,14 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::types::NodeProperty;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
pub struct WasmNodeProperty {
#[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties,
pub(crate) key: String,
pub(crate) value: Option<String>,
}
to_wasm!(
@ -21,12 +20,13 @@ to_wasm!(
original,
wasm_context,
{ WasmAstNode::NodeProperty(original) },
{ "TODO".into() },
{ "node-property".into() },
{
Ok((
Vec::new(),
WasmNodeProperty {
additional_properties: AdditionalProperties::default(),
key: original.property_name.to_owned(),
value: original.value.map(|s| s.to_owned()),
},
))
}

View File

@ -42,7 +42,15 @@ to_wasm!(
Ok((
children,
WasmPlainListItem {
tag: Vec::new(),
tag: original
.tag
.iter()
.map(|child| {
child
.to_wasm(wasm_context.clone())
.map(Into::<WasmAstNode>::into)
})
.collect::<Result<Vec<_>, _>>()?,
bullet: original.bullet.to_owned(),
counter: original.counter.clone(),
checkbox: original.checkbox.as_ref().map(|(checkbox_type, _)| {

View File

@ -4,16 +4,12 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::types::PropertyDrawer;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
pub struct WasmPropertyDrawer {
#[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties,
}
pub struct WasmPropertyDrawer {}
to_wasm!(
WasmPropertyDrawer,
@ -21,7 +17,7 @@ to_wasm!(
original,
wasm_context,
{ WasmAstNode::PropertyDrawer(original) },
{ "TODO".into() },
{ "property-drawer".into() },
{
let children = original
.children
@ -33,11 +29,6 @@ to_wasm!(
})
.collect::<Result<Vec<_>, _>>()?;
Ok((
children,
WasmPropertyDrawer {
additional_properties: AdditionalProperties::default(),
},
))
Ok((children, WasmPropertyDrawer {}))
}
);

View File

@ -6,6 +6,7 @@ use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::QuoteBlock;
use crate::wasm::to_wasm::ToWasmStandardProperties;
@ -21,8 +22,12 @@ to_wasm!(
original,
wasm_context,
{ WasmAstNode::QuoteBlock(original) },
{ "TODO".into() },
{ "quote-block".into() },
{
let additional_properties = original
.get_affiliated_keywords()
.to_wasm(wasm_context.clone())?;
let children = original
.children
.iter()
@ -36,7 +41,7 @@ to_wasm!(
Ok((
children,
WasmQuoteBlock {
additional_properties: AdditionalProperties::default(),
additional_properties,
},
))
}

View File

@ -2,10 +2,12 @@ use serde::Deserialize;
use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::headline::Noop;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::SpecialBlock;
use crate::wasm::to_wasm::ToWasmStandardProperties;
@ -13,6 +15,10 @@ use crate::wasm::to_wasm::ToWasmStandardProperties;
pub struct WasmSpecialBlock {
#[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties,
#[serde(rename = "type")]
pub(crate) block_type: String,
pub(crate) parameters: Option<String>,
pub(crate) results: Noop,
}
to_wasm!(
@ -21,8 +27,12 @@ to_wasm!(
original,
wasm_context,
{ WasmAstNode::SpecialBlock(original) },
{ "TODO".into() },
{ "special-block".into() },
{
let additional_properties = original
.get_affiliated_keywords()
.to_wasm(wasm_context.clone())?;
let children = original
.children
.iter()
@ -36,7 +46,10 @@ to_wasm!(
Ok((
children,
WasmSpecialBlock {
additional_properties: AdditionalProperties::default(),
additional_properties,
block_type: original.block_type.to_owned(),
parameters: original.parameters.map(|s| s.to_owned()),
results: Noop {},
},
))
}

View File

@ -105,7 +105,7 @@ fn compare_json_value<'b, 's>(
(serde_json::Value::String(w), Token::Atom(e)) if w.as_str() == *e => {
Ok(WasmDiffResult::default())
}
(serde_json::Value::Object(w), Token::Atom(_)) if w.contains_key("noop") => {
(serde_json::Value::Object(w), _) if w.contains_key("noop") => {
Ok(WasmDiffResult::default())
}
(serde_json::Value::Null, Token::Atom(_)) => todo!(),
@ -156,6 +156,9 @@ fn compare_optional_json_value<'b, 's>(
(None, None) | (None, Some(serde_json::Value::Null)) | (Some(Token::Atom("nil")), None) => {
Ok(WasmDiffResult::default())
}
(None, Some(serde_json::Value::Object(w))) if w.contains_key("noop") => {
Ok(WasmDiffResult::default())
}
(Some(e), Some(w)) => compare_json_value(source, e, w),
_ => Ok(WasmDiffResult {
status: vec![WasmDiffStatus::Bad(