Implement example block and export block.
This commit is contained in:
@@ -3,16 +3,35 @@ use serde::Serialize;
|
||||
|
||||
use super::ast_node::WasmAstNode;
|
||||
use super::macros::to_wasm;
|
||||
use super::src_block::WasmNumberLines;
|
||||
use super::src_block::WasmNumberLinesWrapper;
|
||||
use super::src_block::WasmRetainLabels;
|
||||
use super::to_wasm::ToWasm;
|
||||
use super::AdditionalProperties;
|
||||
use crate::compare::ElispFact;
|
||||
use crate::types::CharOffsetInLine;
|
||||
use crate::types::ExampleBlock;
|
||||
use crate::types::GetAffiliatedKeywords;
|
||||
use crate::types::RetainLabels;
|
||||
use crate::types::SwitchNumberLines;
|
||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct WasmExampleBlock {
|
||||
#[serde(flatten)]
|
||||
pub(crate) additional_properties: AdditionalProperties,
|
||||
pub(crate) value: String,
|
||||
pub(crate) switches: Option<String>,
|
||||
#[serde(rename = "number-lines")]
|
||||
pub(crate) number_lines: Option<WasmNumberLinesWrapper>,
|
||||
#[serde(rename = "preserve-indent")]
|
||||
pub(crate) preserve_indent: Option<CharOffsetInLine>,
|
||||
#[serde(rename = "retain-labels")]
|
||||
pub(crate) retain_labels: WasmRetainLabels,
|
||||
#[serde(rename = "use-labels")]
|
||||
pub(crate) use_labels: bool,
|
||||
#[serde(rename = "label-fmt")]
|
||||
pub(crate) label_format: Option<String>,
|
||||
}
|
||||
|
||||
to_wasm!(
|
||||
@@ -21,12 +40,35 @@ to_wasm!(
|
||||
original,
|
||||
wasm_context,
|
||||
{ WasmAstNode::ExampleBlock(original) },
|
||||
{ "TODO".into() },
|
||||
{ "example-block".into() },
|
||||
{
|
||||
let additional_properties = original
|
||||
.get_affiliated_keywords()
|
||||
.to_wasm(wasm_context.clone())?;
|
||||
|
||||
Ok((
|
||||
Vec::new(),
|
||||
WasmExampleBlock {
|
||||
additional_properties: AdditionalProperties::default(),
|
||||
additional_properties,
|
||||
value: original.get_value().into_owned(),
|
||||
switches: original.switches.map(|s| s.to_owned()),
|
||||
number_lines: match original.number_lines {
|
||||
None => None,
|
||||
Some(SwitchNumberLines::New(n)) => Some(WasmNumberLinesWrapper {
|
||||
inner: WasmNumberLines::New(n),
|
||||
}),
|
||||
Some(SwitchNumberLines::Continued(n)) => Some(WasmNumberLinesWrapper {
|
||||
inner: WasmNumberLines::continued(n),
|
||||
}),
|
||||
},
|
||||
preserve_indent: original.preserve_indent,
|
||||
retain_labels: match original.retain_labels {
|
||||
RetainLabels::No => WasmRetainLabels::YesNo(false),
|
||||
RetainLabels::Yes => WasmRetainLabels::YesNo(true),
|
||||
RetainLabels::Keep(n) => WasmRetainLabels::Keep(n),
|
||||
},
|
||||
use_labels: original.use_labels,
|
||||
label_format: original.label_format.map(|s| s.to_owned()),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user