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

Method extract_docstring

src/extraction/lua_extractor.rs:478–498  ·  view source on GitHub ↗

Extract docstrings from `--` or `---` comment lines preceding definitions. Lua uses comment lines (-- or --- for `LDoc`) as documentation. We look for `comment` sibling nodes that immediately precede the given definition node.

(state: &ExtractionState, node: TsNode<'_>)

Source from the content-addressed store, hash-verified

476 /// Lua uses comment lines (-- or --- for `LDoc`) as documentation. We look for
477 /// `comment` sibling nodes that immediately precede the given definition node.
478 fn extract_docstring(state: &ExtractionState, node: TsNode<'_>) -> Option<String> {
479 let mut comments: Vec<String> = Vec::new();
480 let mut prev = node.prev_named_sibling();
481 while let Some(prev_node) = prev {
482 if prev_node.kind() == "comment" {
483 let text = state.node_text(prev_node);
484 // Strip leading dashes and whitespace: "--- foo""foo", "-- bar""bar"
485 let stripped = text.trim_start_matches('-').trim().to_string();
486 comments.push(stripped);
487 prev = prev_node.prev_named_sibling();
488 } else {
489 break;
490 }
491 }
492 if comments.is_empty() {
493 return None;
494 }
495 // Comments were collected in reverse order; reverse them back.
496 comments.reverse();
497 Some(comments.join("\n"))
498 }
499
500 /// Recursively find `function_call` nodes inside a given node and create unresolved Calls references.
501 fn extract_call_sites(state: &mut ExtractionState, node: TsNode<'_>, fn_node_id: &str) {

Callers

nothing calls this directly

Calls 4

kindMethod · 0.80
pushMethod · 0.80
node_textMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected