Improve local definition docs + add CI workflow
SCIP Index / index (push) Failing after 11s

- Add signature and arglists to local var documentation
- Resolve arglists at runtime since clojure-lsp doesn't provide them
- Add GitHub Actions workflow for SCIP indexing on push

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-03 17:41:14 -05:00
parent c434adda76
commit 685d1eaa93
3 changed files with 85 additions and 14 deletions
+33 -13
View File
@@ -79,17 +79,42 @@
(.setSymbolRoles builder (int Scip$SymbolRole/Definition_VALUE))
(.build builder)))
(defn get-var-arglists
"Get arglists for a var by resolving it at runtime."
[ns-sym var-name]
(try
(require (symbol ns-sym))
(when-let [v (ns-resolve (symbol ns-sym) (symbol var-name))]
(:arglists (meta v)))
(catch Exception _ nil)))
(defn format-arglists
"Format arglists for display."
[arglists]
(when (seq arglists)
(str/join "\n" (map #(str " " (pr-str %)) arglists))))
(defn var-definition->symbol-info
"Convert a clojure-lsp var-definition to SCIP SymbolInformation."
[{:keys [ns name doc defined-by fixed-arities]}]
(let [builder (Scip$SymbolInformation/newBuilder)]
[{:keys [ns name doc defined-by fixed-arities arglist-strs macro]}]
(let [builder (Scip$SymbolInformation/newBuilder)
;; Get arglists from runtime if not provided by clojure-lsp
arglists (or (seq arglist-strs)
(get-var-arglists ns name))
;; Check if macro from defined-by if not in metadata
is-macro (or macro
(= defined-by 'clojure.core/defmacro))
sig (str (when is-macro "macro ") ns "/" name)]
(.setSymbol builder (make-symbol ns name))
;; Add signature as first doc line
(.addDocumentation builder (str "```clojure\n" sig "\n```"))
;; Add arglists in code block
(when (seq arglists)
(.addDocumentation builder
(str "```clojure\n" (format-arglists arglists) "\n```")))
;; Add docstring
(when doc
(.addDocumentation builder doc))
(when defined-by
(.addDocumentation builder (str "Defined by: " defined-by)))
(when (seq fixed-arities)
(.addDocumentation builder (str "Arities: " (str/join ", " fixed-arities))))
(.build builder)))
(defn var-usage->occurrence
@@ -200,12 +225,6 @@
:ns ns-sym}))
(catch Exception _ nil))))
(defn format-arglists
"Format arglists for display."
[arglists]
(when (seq arglists)
(str/join "\n" (map #(str " " (pr-str %)) arglists))))
(defn external-symbol->symbol-info
"Create SCIP SymbolInformation for an external symbol with documentation."
[{:keys [ns name doc arglists macro special-form]}]
@@ -334,7 +353,8 @@
"clojure-lsp")
result (sh lsp-path "dump"
"--project-root" project-root
"--output" "{:format :edn}")]
"--output" "{:format :edn}"
"--analysis" "{:arglists true}")]
(if (zero? (:exit result))
(do
(println "Parsing clojure-lsp output...")