Liking cljdoc? Tell your friends :D

Clojurescript Kernel of Pinkgorilla Notebook

We use self-hosted clojurescript via klipse library. Klipse is well maintained and production proof. It allows to include custom dependencies.

Our fork is in https://github.com/pink-gorilla/kernel-cljs

Great Reagent demo using klipse is here: https://blog.klipse.tech/clojure/2019/02/17/reframe-tutorial.html https://day8.github.io/re-playground/?gist-id=saskali/d9b7d0ccc36cdb89ef49a56a531e5b25# also done with klipse plugin

Klipse automatically generates via clojure macros cache files of dependencies that can be used at runtime.

Dynamically add klipse dependencies

This still needs to be implemented:

https://github.com/viebel/codox-klipse-theme

Lets' say your github user is my_user and your repo is my_repo, with namespace my_repo.my_ns with a function my_func, then add the following options to :codox: :codox {:metadata {:doc/format :markdown} :output-path "docs" :themes [:default [:klipse {:klipse/external-libs "https://raw.githubusercontent.com/my_user/my_repo/master/src/" :klipse/require-statement "(ns my.test (:require [my_repo.my_ns :as my_ns :refer [my_func]]))"}]] }

data-static-fns: (default false) set to true for using static dispatch http://blog.klipse.tech/clojurescript/2016/04/13/static-fns.html

data-external-libs: comma separated list of github repositories to resolve dependencies: you need to provide the full list of dependencies (including the dependencies of dependencies recursively). See for instance Lambda Caclulus with clojure and Klipse data-print-length: (default 1000) max number of items in collections to display - useful to prevent browser stuck when evaluating infinite sequences like (range)

You can require clojure libraries in your code snippet but the code might take a while to execute, as the code of the library is JIT loaded from github. Here is an example with clojure.set:

When you require a clojure library, klipse will try to load the library from several repos. As a consequence, if you open the browser dev tools, you’ll see a lot of 404s.

Ways to include clojurescript code

compiled with :advanced

  • functions to be used in repl need to be exported with :export.

compiled with :simple

  • that all of the function entry points remain available.

self-hosted ClojureScript and compile new code in the browser.

  • Using self-hosted ClojureScript results in more code being shipped to the browser, but it results in the most dynamic / flexible environment.

Dmitri Sotnikov was looking into dynamically adding new functionality to a web app written with ClojureScript and I had chatted with him briefly about marking cljs.core functions with :export in order to try to have your cake and eat it too with respect to :advanced and dynamically loaded code. It might be worth checking with him to see if they explored that approach. https://yogthos.net/posts/2016-05-20-ExpandableWidgetsInReagent.html

Other options for self hosted clojurescript

https://github.com/pink-gorilla/cljs-eval-example/blob/master/project.clj

https://code.thheller.com/blog/shadow-cljs/2017/10/14/bootstrap-support.html

Can you improve this documentation?Edit on GitHub

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

× close