(source: &[u8], node: TsNode<'_>)
| 107 | /// preceding `node`. |
| 108 | #[allow(dead_code)] |
| 109 | pub(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. |
no test coverage detected