Skip to content

Instantly share code, notes, and snippets.

@spacegangster
Last active March 24, 2022 12:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save spacegangster/5d91d2e39af52ee3581b8f46f963f96e to your computer and use it in GitHub Desktop.
Save spacegangster/5d91d2e39af52ee3581b8f46f963f96e to your computer and use it in GitHub Desktop.
Getting call graph (vars structure) in Clojure
(ns user)
; Hey, I've been playing a bit with graphing out the structure of a module for Lightpad.
; It worked well, I've found the target function that I'll need change to add a new feature.
; Tweet with a screenshot https://twitter.com/spacegangster/status/1324760381735272450
; lein coordinate
; [com.gfredericks/clj-usage-graph "0.3.0"]
; https://github.com/gfredericks/clj-usage-graph
(defn gcal-graph []
(let [graph-desc
(with-out-str
(clj-graph/var-graph
"gcal-embassy/src/gcal_embassy/gcal_api.clj"
"gcal-embassy/src/gcal_embassy/logic.clj"
"gcal-embassy/src/gcal_embassy/persist.clj"
;"gcal-embassy/src/gcal_embassy/persist__digest_event.clj"
"gcal-embassy/src/gcal_embassy/polling.clj"
"gcal-embassy/src/gcal_embassy/push.clj"
"gcal-embassy/src/gcal_embassy/sync_facade.clj"))]
(spit "gcal-embassy/call-graph.gv" graph-desc)
(let [cwd (System/getProperty "user.dir")]
(clojure.java.shell/sh "dot" "-Tsvg" "-o" "call-graph.svg"
:in graph-desc
:dir (str cwd "/gcal-embassy"))))
(comment
(gcal-graph))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment