MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / clean_comment_markers

Function clean_comment_markers

codegraph-kernel/src/docstring.rs:107–129  ·  view source on GitHub ↗

cleanCommentMarkers — strip comment syntax, keep the prose.

(comment: &str)

Source from the content-addressed store, hash-verified

105
106/// cleanCommentMarkers — strip comment syntax, keep the prose.
107pub fn clean_comment_markers(comment: &str) -> String {
108 let c = cleaners();
109 let mut s = comment.trim().to_string();
110 if s.starts_with("/*") {
111 s = c.block_open.replace(&s, "").into_owned();
112 s = c.block_close.replace(&s, "").into_owned();
113 } else if s.starts_with("--[") {
114 s = c.lua_open.replace(&s, "").into_owned();
115 s = c.lua_close.replace(&s, "").into_owned();
116 } else if s.starts_with("(*") {
117 s = c.paren_star_open.replace(&s, "").into_owned();
118 s = c.paren_star_close.replace(&s, "").into_owned();
119 } else if s.starts_with('{') {
120 s = c.brace_open.replace(&s, "").into_owned();
121 s = c.brace_close.replace(&s, "").into_owned();
122 }
123 s = js_multiline_strip(&s, &c.slashes);
124 s = js_multiline_strip(&s, &c.dashes);
125 s = js_multiline_strip(&s, &c.hash);
126 s = js_multiline_strip(&s, &c.percent);
127 s = js_multiline_strip(&s, &c.star_cont);
128 s.trim().to_string()
129}
130
131/// getPrecedingDocstring — collect the comment run immediately preceding the
132/// node (climbing out of declaration wrappers first), cleaned and joined.

Callers 1

preceding_docstring_withFunction · 0.85

Calls 2

cleanersFunction · 0.85
js_multiline_stripFunction · 0.85

Tested by

no test coverage detected