Skip to main content

microcad_lang/syntax/statement/
inner_doc_comment.rs

1// Copyright © 2026 The µcad authors <info@microcad.xyz>
2// SPDX-License-Identifier: AGPL-3.0-or-later
3
4//! Inner doc syntax element impl.
5
6use microcad_lang_base::{Refer, SrcRef, SrcReferrer, TreeDisplay, TreeState};
7
8/// Inner doc syntax element: `//!`.
9///
10/// A doc comment statement only contains one line of documentation.
11#[derive(Clone, Debug)]
12pub struct InnerDocComment(pub Refer<String>);
13
14impl SrcReferrer for InnerDocComment {
15    fn src_ref(&self) -> SrcRef {
16        self.0.src_ref()
17    }
18}
19
20impl std::fmt::Display for InnerDocComment {
21    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22        write!(f, "/// {}", self.0.value)
23    }
24}
25
26impl TreeDisplay for InnerDocComment {
27    fn tree_print(&self, f: &mut std::fmt::Formatter, depth: TreeState) -> std::fmt::Result {
28        writeln!(f, "{:depth$}Doc: {}", "", self.0)
29    }
30}