workspacer_syntax/
generate_macro_signature.rs

1// ---------------- [ File: workspacer-syntax/src/generate_macro_signature.rs ]
2crate::ix!();
3
4#[derive(Debug, Clone)]
5pub struct MacroRulesSignatureGenerator(ast::MacroRules);
6
7impl GenerateSignature for ast::MacroRules {
8    fn generate_signature_with_opts(&self, opts: &SignatureOptions) -> String {
9        trace!("Generating signature for ast::MacroRules with opts: {:?}", opts);
10
11        let doc_text = if *opts.include_docs() {
12            extract_docs(&self.syntax())
13                .map(|d| format!("{}\n", d))
14                .unwrap_or_default()
15        } else {
16            "".to_string()
17        };
18
19        let name = self
20            .name()
21            .map(|n| n.to_string())
22            .unwrap_or_else(|| "<unknown_macro>".to_string());
23
24        // If fully_expand = true, we might try to show the macro body.
25        // For demonstration, let's just do a partial or placeholder expansion.
26        let body_text = if *opts.fully_expand() {
27            "{ /* macro body here */ }"
28        } else {
29            "{ /* macro body omitted */ }"
30        };
31
32        let core = format!("macro_rules! {name} {body_text}");
33
34        let final_sig = format!("{doc_text}{core}");
35        post_process_spacing(&final_sig)
36    }
37}