cljsinfo / cljs.info

ClojureScript website
http://cljs.info
MIT License
96 stars 9 forks source link

generate docs for special forms #36

Closed shaunlebron closed 9 years ago

shaunlebron commented 9 years ago

After Chris was asking about the ns form, I found the special forms were present only in the analyzer here:

(def specials '#{if def fn* do let* loop* letfn* throw try recur new set!
                 ns deftype* defrecord* . js* & quote case*})

https://github.com/clojure/clojurescript/blob/r2411/src/clj/cljs/analyzer.clj#L413-L414

disregarding the asterisk and uncommon forms, we have:

so we definitely need docs for these. Would be nice to show this as source code too. Not really valuable for people who are using it, but would at least help encourage few devs who want to contribute to the language.

shaunlebron commented 9 years ago

Added the initial parser that just looks for (defmethod parse 'x ...) lines in cljs.analyzer. No docs yet since they don't exist in code yet, just Type and Source info for the cljsdoc files.

Perfect timing to be working on this though. ClojureScript just added var support so we can pull metadata/docs for a given var. And a doc function was built to print docs for vars. Macros and Special-forms are not supported yet. https://github.com/clojure/clojurescript/commit/7397ae2e089612fc05b8e16d7dc1497cbddc47a1

Clojure had clojure.repl/special-doc-map for printing docmaps of special forms. So as soon as something like that is added to cljs for the doc function to use, I'll upgrade the parser to use those in our cljsdocs.