Git Product home page Git Product logo

Comments (13)

bhb avatar bhb commented on July 22, 2024 3

@ arichiardi @carocad This feature is included in 0.6.0. Thanks for all your help!

from expound.

bhb avatar bhb commented on July 22, 2024

@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.

arichiardi avatar arichiardi commented on July 22, 2024

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.

bhb avatar bhb commented on July 22, 2024

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.

carocad avatar carocad commented on July 22, 2024

@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.

bhb avatar bhb commented on July 22, 2024

@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.

bhb avatar bhb commented on July 22, 2024

@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.

bhb avatar bhb commented on July 22, 2024

(and thanks for suggesting this!)

from expound.

bhb avatar bhb commented on July 22, 2024

cc @lacarmen @ikitommi feedback is appreciated from you as well 😄

from expound.

arichiardi avatar arichiardi commented on July 22, 2024

This is great and I will definitely try this out as soon as possible. Thanks a lot!

from expound.

carocad avatar carocad commented on July 22, 2024

@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.

screen shot 2018-04-03 at 11 18 31

screen shot 2018-04-03 at 11 18 44

from expound.

bhb avatar bhb commented on July 22, 2024

@carocad Thank you for trying it out and for the suggestions above!

from expound.

arichiardi avatar arichiardi commented on July 22, 2024

Works very nicely for me with:

{expound {:git/url "https://github.com/bhb/expound"
          :sha "59740c46c5a33cfa1257e563ec37b652eae692fd"}}

and output

2018-04-05-122203_840x659_scrot

from expound.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.