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

Function clean_comment_markers

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

cleanCommentMarkers — strip comment syntax, keep the prose.

(comment: &str)

Source from the content-addressed store, hash-verified

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

Callers 1

preceding_docstringFunction · 0.85

Calls 2

cleanersFunction · 0.85
js_multiline_stripFunction · 0.85

Tested by

no test coverage detected