microcad_lang/syntax/
doc_block.rs1use crate::{src_ref::*, syntax::*};
7
8#[derive(Clone, Debug, Default)]
10pub struct DocBlock {
11 pub lines: Vec<String>,
13 pub src_ref: SrcRef,
15}
16
17impl SrcReferrer for DocBlock {
18 fn src_ref(&self) -> SrcRef {
19 self.src_ref.clone()
20 }
21}
22
23impl std::fmt::Display for DocBlock {
24 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
25 self.lines
26 .iter()
27 .try_for_each(|doc| writeln!(f, "/// {doc}"))
28 }
29}
30
31impl TreeDisplay for DocBlock {
32 fn tree_print(&self, f: &mut std::fmt::Formatter, mut depth: TreeState) -> std::fmt::Result {
33 writeln!(f, "{:depth$}DocBlock:", "")?;
34 depth.indent();
35 self.lines
36 .iter()
37 .try_for_each(|doc| writeln!(f, "{:depth$}/// {doc}", ""))
38 }
39}