Roxygen2-style docstrings start with `#'`.
(state: &ExtractionState, node: TsNode<'_>)
| 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 { |