Liking cljdoc? Tell your friends :D

Picasso GitHub Actions status |pink-gorilla/picassoClojars Project

  • This project is used in Notebook , but the library can be used independently.
  • Data structures from clojure/clojurescript have to be converted to some kind of visual repesentation so that the notebook can render them
  • For all clojure/clojurescript datatypes default renderers are defined here
  • Custom data-types can implement the renderable protocol
  • The notebook receives the render-datastructure and renders it to the notebook cell.

This are the core concepts in picasso:

render (used in nrepl middleware)

(defprotocol Renderable
  (render [self]))

paint (used in notebook-ui)

(defmulti paint :type)

Clojure/Clojurescript Data => (render) => Picasso DataStructure => (paint) => Notebook

Clojure/Clojurescript type based rendering

  • All clj/cljs datatypes have default renderers that will be selected based on the type of the data.

Syntactic sugar for librarys that need visualization

  • Goal is to use meta-data to trigger rendering of function output.
  • Say we want a function that creates a vega spec to be rendered with a vega renderer:
(defn timeseries-plot 
  "timeseries-plot creates vega spec for a timeseries plot"
  [data] 
  ^{:render-with :p/vega} vega-spec)
  • The user would then use this with:
[:div [:h1 "demo"]
      (timeseries-plot data)]
  • the rendering system would then internally convert this to:
[:div [:h1 "demo"]
      [:p/vega (timeseries-plot data)]]
  • This saves the library author from writing a wrapper.

Unit Tests

Clojure:

lein test

Clojurescript:

npm install
lein test-js

Licence

This code is licensed to you under the MIT licence. See LICENCE.txt for details.

Can you improve this documentation? These fine people already did:
awb99, Andreas Steffan & JonyEpsilon
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close