Skip to content

Instantly share code, notes, and snippets.

@puredanger
Last active November 20, 2017 07:36
Show Gist options
  • Save puredanger/bebde3bba60540e834140b0cf2525b09 to your computer and use it in GitHub Desktop.
Save puredanger/bebde3bba60540e834140b0cf2525b09 to your computer and use it in GitHub Desktop.
Dumping a var meta table
;; Prints a table of vars in an ns with name/line/added/macro flag/deprecated flag
(defn pr-vars [ns-sym]
(->> (ns-publics ns-sym) vals (map meta) (sort-by :name)
(map #(select-keys % [:name :line :added :macro :deprecated]))
(map #(merge {:added nil :macro false :deprecated false} %))
clojure.pprint/print-table))
(pr-vars 'clojure.string)
;; | :added | :macro | :deprecated | :name | :line |
;; |--------+--------+-------------+----------------------+-------|
;; | 1.2 | false | false | blank? | 287 |
;; | 1.2 | false | false | capitalize | 196 |
;; | 1.8 | false | false | ends-with? | 366 |
;; | 1.2 | false | false | escape | 300 |
;; | 1.8 | false | false | includes? | 372 |
;; | 1.8 | false | false | index-of | 318 |
;; | 1.2 | false | false | join | 180 |
;; | 1.8 | false | false | last-index-of | 339 |
;; | 1.2 | false | false | lower-case | 213 |
;; | 1.5 | false | false | re-quote-replacement | 54 |
;; | 1.2 | false | false | replace | 75 |
;; | 1.2 | false | false | replace-first | 138 |
;; | 1.2 | false | false | reverse | 48 |
;; | 1.2 | false | false | split | 219 |
;; | 1.2 | false | false | split-lines | 228 |
;; | 1.8 | false | false | starts-with? | 360 |
;; | 1.2 | false | false | trim | 234 |
;; | 1.2 | false | false | trim-newline | 274 |
;; | 1.2 | false | false | triml | 251 |
;; | 1.2 | false | false | trimr | 263 |
;; | 1.2 | false | false | upper-case | 207 |
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment