MCPcopy Create free account
hub / github.com/ScriptedAlchemy/tracedecay / docstring_from_hash_comments

Function docstring_from_hash_comments

src/extraction/common.rs:109–128  ·  view source on GitHub ↗
(source: &[u8], node: TsNode<'_>)

Source from the content-addressed store, hash-verified

107/// preceding `node`.
108#[allow(dead_code)]
109pub(crate) fn docstring_from_hash_comments(source: &[u8], node: TsNode<'_>) -> Option<String> {
110 let mut comments: Vec<String> = Vec::new();
111 let mut prev = node.prev_named_sibling();
112 while let Some(prev_node) = prev {
113 if prev_node.kind() == "comment" {
114 let text = node_text(source, prev_node);
115 let stripped = text.trim_start_matches('#').trim().to_string();
116 comments.push(stripped);
117 prev = prev_node.prev_named_sibling();
118 } else {
119 break;
120 }
121 }
122 if comments.is_empty() {
123 return None;
124 }
125 // Comments were collected in reverse order; reverse them back.
126 comments.reverse();
127 Some(comments.join("\n"))
128}
129
130/// Recursively find `call_expression` nodes and create unresolved Calls
131/// references, taking the callee name from the first named child.

Callers 2

extract_docstringMethod · 0.85
extract_docstringMethod · 0.85

Calls 4

node_textFunction · 0.85
kindMethod · 0.80
pushMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected