Comments (13)
@ arichiardi @carocad This feature is included in 0.6.0. Thanks for all your help!
from expound.
@arichiardi Great idea! I have a few ideas on how to start with this.
Unfortunately, it's a bit tricky to describe via GitHub issues because AFAICT, we can't colorize the Github-flavored-markdown, but I'll do my best :)
From the sample output in the README:
;; -- Spec failed --------------------
;; {:city ..., :state :CO}
;; ^^^
;; should satisfy
;; string?
;; -- Relevant specs -------
;; :example.place/state:
;; clojure.core/string?
;; :example/place:
;; (clojure.spec.alpha/keys
;; :req-un
;; [:example.place/city :example.place/state])
;; -------------------------
;; Detected 1 error
:CO
i.e. the "non-conforming value" : color A
^^^
i.e. the the "highlight" : color B
string?
i.e. the "predicate" : color A (so it visually matches the non-conforming value).
everything else could remain uncolored for now.
Some more examples of problems:
Full problem text | colored | uncolored |
---|---|---|
"should be one of: :bar ,:foo " |
":bar ,:foo " |
"should be one of:" |
should have additional elements. The next element is named :v and satisfies any? |
"The next element is named :v and satisfies any?" |
"should have additional elements." |
"Value has extra input" | "Value has extra input" | n/a |
"should contain keys: :keys-spec/name ,:age " |
":keys-spec/name ,:age " |
"should contain keys:" |
I suspect that this scheme would help visually connect the non-conforming value with the problem, but I could be wrong - perhaps in practice, it's nicer to have the entire problem (the whole left hand column) colorized.
What do you think? I'd prefer to start with minimal colors and see if it solves the problem. We can always add more colors as we go.
PRs welcome on this. Otherwise, I'll probably tackle after a few more bug fixes and one more big feature I want to work on.
from expound.
I like your idea, I definitely prefer minimal colors just to catch the eye where the problem is. I would also probably him the separator between spec in order to create a visual barrier between different spec problems.
Good that you started the discussion about this here!
PS.: the text of the second error in the table could be probably colored less 😄
from expound.
the separator between spec in order to create a visual barrier between different spec problem
Yep, good idea. Probably a third color C for this.
the text of the second error in the table could be probably colored less 😄
Yes, perhaps just :v
and any
.
from expound.
@bhb maybe it would be a good idea to have a color convention similar or equal to figwheel
colors for compiler error messages.
The idea is to make the colors as predictable as possible, and since figwheel is (afaik) the standard for Clojurescript I think that it would help to ease understanding the error messages.
Hope it helps
from expound.
@carocad That's a good idea - Figwheel has already put a lot of thought into this, and it would mean that if you're familiar with Figwheel messages, you'l have an easier time reading Expound error messages as well.
from expound.
@arichiardi @carocad If you have time, I'd appreciate it if you could try out Expound 0.5.1-SNAPSHOT, which includes ansi colorization:
(require '[clojure.spec.alpha :as s])
(require '[clojure.spec.test.alpha :as st])
(require '[expound.alpha :as expound])
(set! s/*explain-out* (expound/custom-printer {:theme :figwheel-theme}))
:figwheel-theme
is the only theme right now, but I may add others in the future.
from expound.
(and thanks for suggesting this!)
from expound.
cc @lacarmen @ikitommi feedback is appreciated from you as well 😄
from expound.
This is great and I will definitely try this out as soon as possible. Thanks a lot!
from expound.
@bhb I just gave it a try and I think it is a wonderful piece of work :)
I will stay with the snapshot version until a full release comes out just so that I can keep the colored output.
For those that come here and are curious about it here are some screenshots on the output on my Cursive IDE.
from expound.
@carocad Thank you for trying it out and for the suggestions above!
from expound.
Works very nicely for me with:
{expound {:git/url "https://github.com/bhb/expound"
:sha "59740c46c5a33cfa1257e563ec37b652eae692fd"}}
and output
from expound.
Related Issues (20)
- Error reports returned as :cause string in an exception when produced by instrumentation within generative testing HOT 11
- allow passing options map to expound/expound-str HOT 1
- Improve grouping of spec errors HOT 2
- Unnecessary dependency on `cider-nrepl` HOT 1
- Regression of #3 HOT 4
- Easier editing of error messages
- `printer` has invalid spec HOT 2
- "Cannot convert path" on instrumentation failures in the wild HOT 4
- (cljs.spec.test.alpha/instrument) breaks expound due to wrong arity HOT 4
- should expound work anywhere s/explain works? - clojurescript error HOT 7
- Error in :ret check when using with Orchestra 2020.07.12-1 HOT 5
- Internal error in `lift-singleton-groups` when having a datomic db value in fn args HOT 13
- Crash bug when printing, if a datomic db is present and the spec fails HOT 19
- Feature inquiry: a convenience function for validating a value against a spec HOT 4
- Wrapped `s/keys` does not properly display unqualified keyword specs HOT 5
- ClassCastException from `expound-str` when running in AWS Lambda HOT 9
- Small *print-length* and/or *print-level* sometimes yield NPE HOT 5
- PersistentList cannot be cast to class Named HOT 3
- proposal : defmsg equivalent for arbitrary predicates HOT 15
- optional include location of the spec error in the message. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from expound.