Skip to content

Commit

Permalink
Add documentation about the new REPL functions
Browse files Browse the repository at this point in the history
  • Loading branch information
hlship committed Nov 18, 2016
1 parent 4d46eb3 commit 49fceba
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Pretty is released under the terms of the `Apache Software License 2.0 <http://w

ansi
exceptions
repl
lein-plugin
binary
columns
Expand Down
54 changes: 54 additions & 0 deletions docs/repl.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
REPL
====

Pretty includes some useful REPL utilities in the ``io.aviso.repl`` namespace.

Primarily, the ``install-pretty-exceptions`` function overrides several
internal Clojure functions to enable
:doc:`formatted exceptions <exceptions>`.
This function is normally invoked for you
when Pretty is
:doc:`used as a Leiningen plugin <lein-plugin>`.

The remaining functions exist to help you make things pretty
that *don't* originate in the REPL. You will often see output in logs: EDN data perhaps,
or often, raw exceptions.

If you have a REPL running, you can use the following functions to get a better view
of that data:

copy
----

The ``copy`` function will return the current contents of the system clipboard
as a string.
This requires that AWT is running.
On OS X, you will see a window for your application start when you first invoke this function

The ``pretty-print`` and ``format-exception`` functions can be invoked
with no arguments, in which case the call to ``copy`` happens automatically.

Consult the API documentation for more details.

pretty-print
------------

This will pretty-print the contents of the clipboard; the clipboard text is parsed as EDN.

format-exception
----------------

This will parse a normal Java stack trace and format it for readability.

paste
-----

This will copy as string back on to the clipboard, so it can be pasted into
another window.

.. code-block:: clojure
(use 'io.aviso.repl)
(-> (copy) format-exception paste)

0 comments on commit 49fceba

Please sign in to comment.