cljs.repl

since v0.0-927

This namespace mainly provides reflection capabilities to assist you in exploring code in a REPL. It comes with macros that are automatically imported into your REPL environment, but you can use them outside of one as well.

These macros allow you to explore code by listing/searching available vars in a namespace and viewing a var's documentation or source.


Error->map - function
(Error->map o)
Constructs a data representation for a Error with keys:
 :cause - root cause message
 :phase - error phase
 :via - cause chain, with cause keys:
          :type - exception class symbol
          :message - exception message
          :data - ex-data
          :at - top stack element
 :trace - root cause stack elements

apropos - macro
(apropos str-or-pattern)
Given a regular expression or stringable thing, return a seq of all
public definitions in all currently-loaded namespaces that match the
str-or-pattern.

dir - macro
(dir ns)
Prints a sorted directory of public vars in a namespace

doc - macro
(doc name)
Prints documentation for a var or special form given its name,
or for a spec if given a keyword

error->str - function
(error->str error)

ex-str - function
(ex-str {:keys [:clojure.error/phase :clojure.error/source :clojure.error/line :clojure.error/column :clojure.error/symbol :clojure.error/class :clojure.error/cause :clojure.error/spec], :as triage-data})
Returns a string from exception data, as produced by ex-triage.
The first line summarizes the exception phase and location.
The subsequent lines describe the cause.

ex-triage - function
(ex-triage datafied-throwable)
Returns an analysis of the phase, error, cause, and location of an error that occurred
based on Throwable data, as returned by Throwable->map. All attributes other than phase
are optional:
  :clojure.error/phase - keyword phase indicator, one of:
    :read-source :compile-syntax-check :compilation :macro-syntax-check :macroexpansion
    :execution :read-eval-result :print-eval-result
  :clojure.error/source - file name (no path)
  :clojure.error/line - integer line number
  :clojure.error/column - integer column number
  :clojure.error/symbol - symbol being expanded/compiled/invoked
  :clojure.error/class - cause exception class symbol
  :clojure.error/cause - cause exception message
  :clojure.error/spec - explain-data for spec error

find-doc - macro
(find-doc re-string-or-pattern)
Prints documentation for any var whose documentation or name
contains a match for re-string-or-pattern

(print-doc {n :ns, nm :name, :as m})

pst - macro
(pst)
(pst e)

source - macro
(source n)
Prints the source code for the given symbol, if it can find it.
This requires that the symbol resolve to a Var defined in a
namespace for which the .cljs is in the classpath.

Example: (source filter)