emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/clojure-ts-mode 58f3c835ae 2/2: Capture docstrings defined


From: ELPA Syncer
Subject: [nongnu] elpa/clojure-ts-mode 58f3c835ae 2/2: Capture docstrings defined in metadata
Date: Sat, 9 Sep 2023 12:59:34 -0400 (EDT)

branch: elpa/clojure-ts-mode
commit 58f3c835aeafe0378ab9693731b95096827dbb24
Author: Danny Freeman <danny@dfreeman.email>
Commit: Danny Freeman <danny@dfreeman.email>

    Capture docstrings defined in metadata
    
    Clojure.core has a lot of examples of this:
    
    (def ^{:doc "This is a docstring"} identity [x]
      x)
---
 clojure-ts-mode.el | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/clojure-ts-mode.el b/clojure-ts-mode.el
index eb267b7a25..10efd3e10e 100644
--- a/clojure-ts-mode.el
+++ b/clojure-ts-mode.el
@@ -207,8 +207,10 @@ Only intended for use at development time.")
    (or (group (or "ns" "fn"))
        (group "def"
               (+ (or alnum
-                     ;; What are valid characters for symbols? is a negative 
match better?
-                     "-" "_" "!" "@" "#" "$" "%" "^" "&" "*" "|" "?" "<" ">" 
"+" "=" ":"))))
+                     ;; What are valid characters for symbols?
+                     ;; is a negative match better?
+                     "-" "_" "!" "@" "#" "$" "%" "^" "&"
+                     "*" "|" "?" "<" ">" "+" "=" ":"))))
    line-end))
 
 (defconst clojure-ts--variable-definition-symbol-regexp
@@ -247,6 +249,22 @@ Only intended for use at development time.")
                :anchor (str_lit) ,capture-symbol
                :anchor (_)) ; the variable's value
      (:match ,clojure-ts--variable-definition-symbol-regexp @def_symbol))
+    ;; Captures docstrings in metadata of definitions
+    ((list_lit :anchor (sym_lit) @def_symbol
+               :anchor (sym_lit
+                        (meta_lit
+                         value: (map_lit
+                                 (kwd_lit) @doc-keyword
+                                 :anchor
+                                 (str_lit) ,capture-symbol))))
+     ;; We're only supporting this on a fixed set of defining symbols
+     ;; Existing regexes don't encompass def and defn
+     ;; Naming another regex is very cumbersome.
+     (:match ,(regexp-opt '("def" "defonce" "defn" "defn-" "defmacro" "ns"
+                            "defmulti" "definterface" "defprotocol"
+                            "deftype" "defrecord" "defstruct"))
+             @def_symbol)
+     (:equal @doc-keyword ":doc"))
     ;; Captures docstrings defn, defmacro, ns, and things like that
     ((list_lit :anchor (sym_lit) @def_symbol
                :anchor (sym_lit) ; function_name



reply via email to

[Prev in Thread] Current Thread [Next in Thread]