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

Method extract_docstring

src/extraction/r_extractor.rs:265–286  ·  view source on GitHub ↗

Roxygen2-style docstrings start with `#'`.

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

Source from the content-addressed store, hash-verified

263
264 /// Roxygen2-style docstrings start with `#'`.
265 fn extract_docstring(state: &ExtractionState, node: TsNode<'_>) -> Option<String> {
266 let mut comments = Vec::new();
267 let mut prev = node.prev_named_sibling();
268 while let Some(p) = prev {
269 if p.kind() == "comment" {
270 let text = state.node_text(p);
271 if text.starts_with("#'") {
272 comments.push(text.trim_start_matches("#'").trim().to_string());
273 prev = p.prev_named_sibling();
274 } else {
275 break;
276 }
277 } else {
278 break;
279 }
280 }
281 if comments.is_empty() {
282 return None;
283 }
284 comments.reverse();
285 Some(comments.join("\n"))
286 }
287
288 fn build_result(state: ExtractionState, start: Instant) -> ExtractionResult {
289 ExtractionResult {

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