Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 0.5.3
## 0.6.0
* Removes logical expression hints, they could cause double evaluation in test.
* Adds syntax-highlighting to arglists in `doc` (#39)
* `=` having only one argument now no longer creates problems with Eastwood (#77)
* Fixes a bug wherein string diffs wouldn't include whitespace (#81)
* Replaces Pyro as the default stacktrace engine, removing Pretty.

## 0.5.2
* Changed the printing behavior of test results to flush test output at the end of the test, making output clearer in cases where multi-threaded tests print to *out*
Expand Down
31 changes: 12 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ All of the above features are enabled by default, but can be turned off by setti
```clojure
{:ultra {:repl false
:stacktraces false
:tests false}}}}
:tests false}}
```
### REPL Configuration

Expand All @@ -70,29 +70,22 @@ Ultra uses [Whidbey](https://github.com/greglook/whidbey) as its pretty-printing
...}}}
```

###### `:width`
Additional documentation on individual configuration flags can be found [here](./doc/repl.md).

Number of characters to try to wrap pretty-printed forms at.
### Stacktrace Configuration

###### `:print-meta`
As of version `0.6.0`, Ultra uses [Pyro](https://github.com/venantius/pyro) as a stacktrace engine. This means that arguments to Pyro's configuration are passed straight along.

If true, metadata will be printed before values.
Note that Pyro is still relatively new and this API is liable to change.

###### `:sort-keys`

Print maps and sets with ordered keys. Defaults to true, which will sort all collections. If a number, counted collections will be sorted up to the set size. Otherwise, collections are not sorted before printing.

###### `:map-delimiter`

The text placed between key-value pairs in a map.

###### `:map-coll-separator`

The text placed between a map key and a collection value. The keyword :line will cause line breaks if the whole map does not fit on a single line.

###### `:seq-limit`
```clojure
{:ultra {:stacktraces {:show-source true
:drop-nrepl-elements true
:hide-clojure-elements true
:hide-lein-elements true}}}
```

If set to a positive number, then lists will only render at most the first n elements. This can help prevent unintentional realization of infinite lazy sequences.
Additional documentation on individual configuration flags can be found [here](./doc/stacktraces.md).

## Contributing

Expand Down
36 changes: 36 additions & 0 deletions doc/repl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
### REPL Configuration Flags

Ultra uses [Whidbey](https://github.com/greglook/whidbey) as its pretty-printing engine, and supports all of Whidbey's configuration flags.

```clojure
{:ultra {:repl {:width 180
:map-delimiter ""
:extend-notation true
:print-meta true
...}}}
```

###### `:width`

Number of characters to try to wrap pretty-printed forms at.

###### `:print-meta`

If true, metadata will be printed before values.

###### `:sort-keys`

Print maps and sets with ordered keys. Defaults to true, which will sort all collections. If a number, counted collections will be sorted up to the set size. Otherwise, collections are not sorted before printing.

###### `:map-delimiter`

The text placed between key-value pairs in a map.

###### `:map-coll-separator`

The text placed between a map key and a collection value. The keyword :line will cause line breaks if the whole map does not fit on a single line.

###### `:seq-limit`

If set to a positive number, then lists will only render at most the first n elements. This can help prevent unintentional realization of infinite lazy sequences.

30 changes: 30 additions & 0 deletions doc/stacktraces.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
### Stacktrace Configuration Flags

As of version `0.6.0`, Ultra uses [Pyro](https://github.com/venantius/pyro) as a stacktrace engine. This means that arguments to Pyro's configuration are passed straight along.

Note that Pyro is still relatively new and this API is liable to change.

```clojure
{:ultra {:stacktraces {:show-source true
:drop-nrepl-elements true
:hide-clojure-elements true
:hide-lein-elements true}}}
```

All options are set to true by default.

###### `:show-source`

If `:show-source` is set to true, Pyro will try to print out the syntax-highlighted source code corresponding to each stacktrace element.

###### `:drop-nrepl-elements`

If `:drop-nrepl-elements` is set to true, Pyro will omit any stackframe elements up to the point that the REPL's read-eval-print-loop was actually invoked.

###### `:hide-clojure-elements`

If `:hide-clojure-elements` is set to true, Pyro will omit any stackframe elements from `clojure.core`, `clojure.test`, or the compiler (`clojure.lang.*`).

###### `:hide-lein-elements`

If `:hide-lein-elements` is set to true, Pyro will omit any stackframe elements from `leiningen.core.eval`, `leiningen.core.main`, or `leiningen.test`.
6 changes: 3 additions & 3 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
(defproject venantius/ultra "0.5.3"
(defproject venantius/ultra "0.6.0-SNAPSHOT"
:description "Ultra: A Leiningen plugin for a superior development environment"
:url "http://github.com/venantius/ultra"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/tools.nrepl "0.2.12"]

[grimradical/clj-semver "0.3.0" :exclusions [org.clojure/clojure]]
[io.aviso/pretty "0.1.30"]
[venantius/pyro "0.1.2"]
[mvxcvi/whidbey "1.3.0"]
[mvxcvi/puget "1.0.1"]
[org.clojars.brenton/google-diff-match-patch "0.1"]
[robert/hooke "1.3.0"]
[venantius/glow "0.1.4" :exclusions [hiccup garden]]]
[venantius/glow "0.1.5" :exclusions [hiccup garden]]]
:profiles {:dev {:dependencies [[circleci/bond "0.2.9"]
[org.clojure/clojure "1.8.0"]]}}
:test-selectors {:default (complement :demo)
Expand Down
27 changes: 1 addition & 26 deletions src/ultra/colorscheme.clj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
(ns ultra.colorscheme
(:require [clojure.edn :as edn]
[clojure.java.io :as io]
[io.aviso.exception]
[puget.color.ansi :as ansi]
[whidbey.repl]))

Expand Down Expand Up @@ -31,29 +30,6 @@
(eval (symbol "io.aviso.ansi" (str (name k) "-font")))
(ansi/escape :none)))

(defn set-pretty-colors
"Set the color palette for pretty (which handles exceptions)."
[color-scheme]
(alter-var-root
#'io.aviso.exception/*fonts*
merge
{:clojure-frame (ansi-vec->pretty-str
(:symbol color-scheme))
:exception (ansi-vec->pretty-str
(:exception color-scheme))
:function-name (ansi-vec->pretty-str
(:function-symbol color-scheme))
:java-frame (ansi-vec->pretty-str
(:symbol color-scheme))
:message (ansi-vec->pretty-str nil)
:omitted-frame (ansi-vec->pretty-str
(:symbol color-scheme))
:property (ansi-vec->pretty-str
(:number color-scheme))
:reset (ansi-vec->pretty-str nil)
:source (ansi-vec->pretty-str
(:string color-scheme))}))

(defn set-colorscheme
[{:keys [color-scheme] :as opts}]
(let [color-scheme (if (map? color-scheme)
Expand All @@ -62,5 +38,4 @@
(alter-var-root
#'whidbey.repl/printer
merge
{:color-scheme color-scheme})
(set-pretty-colors color-scheme)))
{:color-scheme color-scheme})))
12 changes: 6 additions & 6 deletions src/ultra/hardcore.clj
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
(defmacro configure-stacktraces!
"Dynamically import ultra's stacktrace namespace and configure them."
{:added "0.3.0"}
[]
[opts]
`(do ~(require 'ultra.stacktrace)
(ultra.stacktrace/configure-stacktraces!)))
(ultra.stacktrace/configure-stacktraces! ~opts)))

(defmacro configure-tests!
"Dyanmically import ultra's test namespace and configure them."
{:added "0.3.0"}
[]
[stacktraces]
`(do ~(require 'ultra.test)
(ultra.test/activate!)))
(ultra.test/activate! ~stacktraces)))

(defmacro set-colorscheme!
"Dynamically import ultra's colorscheme namespace and configures it."
Expand All @@ -44,9 +44,9 @@
(when (not (false? repl))
(eval `(configure-repl! ~repl ~stacktraces)))
(when (not (false? stacktraces))
(eval `(configure-stacktraces!)))
(eval `(configure-stacktraces! ~stacktraces)))
(when (not (false? tests))
(eval `(configure-tests!))))
(eval `(configure-tests! ~stacktraces))))

(defn configure!
"Only run the configuration step once."
Expand Down
28 changes: 18 additions & 10 deletions src/ultra/plugin.clj
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@
[project {:keys [repl] :as opts}]
(let [whidbey-opts (:whidbey project)]
(plugin/add-repl-init
project
(if repl
`(do (require 'ultra.hardcore)
(require 'whidbey.repl)
(whidbey.repl/init! ~whidbey-opts)
(ultra.hardcore/configure! ~opts))
`(do (require 'ultra.hardcore)
(ultra.hardcore/configure! ~opts))))))
project
(if repl
`(do (require 'ultra.hardcore)
(require 'whidbey.repl)
(whidbey.repl/init! ~whidbey-opts)
(ultra.hardcore/configure! ~opts))
`(do (require 'ultra.hardcore)
(ultra.hardcore/configure! ~opts))))))

(defn add-ultra-legacy
"If this project doesn't support reader conditionals, inject Ultra 0.3.4 and
Expand Down Expand Up @@ -94,6 +94,12 @@
(-> project
(add-ultra-legacy opts))))

(def default-opts
{:stacktraces {:show-source true
:drop-nrepl-elements true
:hide-clojure-elements true
:hide-lein-elements true}})

(defn middleware
"Ultra's middleware re-writes the project map."
{:added "0.1.0"}
Expand All @@ -102,12 +108,14 @@
:map-delimiter ""
:print-fallback :print
:sort-keys true}
repl (-> project :ultra :repl)
{:keys [repl stacktraces tests]} (-> project :ultra)
repl-opts (if (false? repl)
repl
(if (true? repl)
default-whidbey-opts
(merge default-whidbey-opts repl)))
opts (-> (:ultra project)
opts (-> default-opts
(assoc :tests tests)
(update :stacktraces merge stacktraces)
(assoc :repl repl-opts))]
(add-ultra project opts)))
16 changes: 8 additions & 8 deletions src/ultra/repl.clj
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
[glow.terminal]
[glow.colorschemes]
[glow.parse]
[io.aviso.repl :as pretty-repl]
[puget.color.ansi :as ansi]
[pyro.printer :as stacktrace]
[ultra.printer :refer [cprint]]))

(defmacro source
Expand Down Expand Up @@ -89,16 +89,16 @@
partial
middleware))

(defn add-pretty-middleware
"Add Aviso's Pretty functionality"
{:added "0.1.2"}
[]
(defn add-pyro-pretty-printing
"Add Pyro's pretty printed stacktraces"
{:added "0.6.0"}
[opts]
(alter-var-root
#'main/repl-caught
(constantly pretty-repl/pretty-repl-caught))
(constantly (partial stacktrace/pprint-exception opts)))
(alter-var-root
#'repl/pst
(constantly pretty-repl/pretty-pst)))
(constantly (partial stacktrace/pprint-exception opts))))

(defn configure-repl!
"Was the fn name not clear enough?"
Expand All @@ -112,4 +112,4 @@
(replace-source)
(replace-doc))
(when (not (false? stacktraces))
(add-pretty-middleware)))
(add-pyro-pretty-printing stacktraces)))
22 changes: 14 additions & 8 deletions src/ultra/stacktrace.clj
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
(ns ultra.stacktrace
(:require [io.aviso.repl :as pretty-repl]
(:require [pyro.printer :as printer]
[clojure.stacktrace :as st]))

(defn configure-stacktraces!
"Configure the printing of stacktraces for exceptions."
{:added "0.1.1"}
[]
"Configure the printing of stacktraces for exceptions.

As of 0.6.0, uses Pyro as a stacktrace engine. Prior to that, Ultra used
Aviso's Pretty."
{:added "0.1.1"
:updated "0.5.3"}
[opts]
(reset! printer/options opts)
(alter-var-root
#'st/print-stack-trace
(constantly pretty-repl/pretty-print-stack-trace))
#'st/print-stack-trace
(constantly (partial printer/pprint-exception {})))
;; used by clojure.test
(alter-var-root
#'st/print-cause-trace
(constantly pretty-repl/pretty-print-stack-trace)))
#'st/print-cause-trace
(constantly (partial printer/pprint-exception opts))))
6 changes: 3 additions & 3 deletions src/ultra/test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
(:use clojure.test)
(:require [clojure.data :as data]
[clojure.pprint :as pp]
[io.aviso.repl :as pretty-repl]
[puget.color.ansi :as ansi]
[pyro.printer :as stacktrace]
[ultra.test.diff :as diff]))

(defn generate-diffs
Expand All @@ -15,7 +15,7 @@

(defn activate!
{:added "0.3.3"}
[]
[stacktrace-opts]
(defmethod assert-expr '= [msg [_ a & more]]
(if (seq more)
`(let [a# ~a
Expand Down Expand Up @@ -53,5 +53,5 @@
(println "expected:" (pr-str expected))
(print " actual: ")
(if (instance? Throwable actual)
(pretty-repl/pretty-print-stack-trace actual)
(stacktrace/pprint-exception actual)
(prn actual)))))
4 changes: 3 additions & 1 deletion test/ultra/hardcore_test.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
(ns ultra.hardcore-test
(:require [clojure.test :refer :all]))
(:require [clojure.test :refer :all]
[ultra.hardcore] ;; make sure this actually loads
))

(deftest working-test
(is (= 1 1)))