Skip to content

Commit 8cbd495

Browse files
committed
add js-comment for emitting top-level JSDoc style comments
1 parent c99f65f commit 8cbd495

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/main/clojure/cljs/core.cljc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -865,6 +865,20 @@
865865
[]
866866
(core/list 'js* "debugger;"))
867867

868+
(core/defmacro js-comment
869+
"Emit top-level JavaScript multi-line comment. New lines will create a
870+
new comment line."
871+
[comment]
872+
(let [[x & ys] (string/split comment #"\n")]
873+
(core/list 'js*
874+
(core/str
875+
"\n/**\n"
876+
(core/str " * " x "\n")
877+
(core/->> ys
878+
(map #(core/str " * " (subs % 3) "\n"))
879+
(reduce core/str ""))
880+
" */\n"))))
881+
868882
(core/defmacro true? [x]
869883
(bool-expr (core/list 'js* "~{} === true" x)))
870884

0 commit comments

Comments
 (0)