microcad_lang/parse/
doc_block.rs1use crate::{parse::*, parser::*, syntax::DocBlock};
5use microcad_lang_base::Refer;
6use microcad_syntax::ast;
7
8impl FromAst for DocBlock {
9 type AstNode = ast::Comment;
10
11 fn from_ast(node: &Self::AstNode, context: &ParseContext) -> Result<Self, ParseError> {
12 Ok(DocBlock(Refer::new(
13 node.lines.clone(),
14 context.src_ref(&node.span),
15 )))
16 }
17}
18
19impl FromAst for InnerDocComment {
20 type AstNode = ast::Comment;
21
22 fn from_ast(node: &Self::AstNode, context: &ParseContext) -> Result<Self, ParseError> {
23 assert_eq!(node.lines.len(), 1, "There should not more than 1 line");
24 let line = node
25 .lines
26 .first()
27 .cloned()
28 .unwrap_or_default()
29 .trim()
30 .to_string();
31
32 Ok(Self(Refer::new(line, context.src_ref(&node.span))))
33 }
34}