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
+47
View File
@@ -0,0 +1,47 @@
name: SCIP Index
on:
push:
branches: [main, master]
workflow_dispatch: # Allow manual trigger
jobs:
index:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Clojure
uses: DeLaGuardo/setup-clojure@12.5
with:
cli: latest
- name: Cache Clojure dependencies
uses: actions/cache@v4
with:
path: |
~/.m2/repository
~/.gitlibs
~/.clojure
key: ${{ runner.os }}-clojure-${{ hashFiles('**/deps.edn') }}
restore-keys: |
${{ runner.os }}-clojure-
- name: Install clojure-lsp
run: |
curl -fsSL https://raw.githubusercontent.com/clojure-lsp/clojure-lsp/master/install | bash
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Generate SCIP index
run: clojure -M:run -p . -o index.scip
- name: Install Sourcegraph CLI
run: |
curl -fsSL https://sourcegraph.com/.api/src-cli/src_linux_amd64 -o /usr/local/bin/src
chmod +x /usr/local/bin/src
- name: Upload to Sourcegraph
run: src code-intel upload -file=index.scip
env:
SRC_ENDPOINT: ${{ secrets.SRC_ENDPOINT }}
SRC_ACCESS_TOKEN: ${{ secrets.SRC_ACCESS_TOKEN }}
+5 -1
View File
@@ -4,7 +4,11 @@
org.clojure/tools.cli {:mvn/version "1.1.230"}}
:aliases
{:build {:extra-deps {io.github.clojure/tools.build {:mvn/version "0.10.5"}}
{:nrepl {:extra-deps {nrepl/nrepl {:mvn/version "1.3.0"}
cider/cider-nrepl {:mvn/version "0.50.2"}}
:main-opts ["-m" "nrepl.cmdline" "--middleware" "[cider.nrepl/cider-middleware]"]}
:build {:extra-deps {io.github.clojure/tools.build {:mvn/version "0.10.5"}}
:ns-default build}
:run {:main-opts ["-m" "scip-clojure.core"]}
+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...")