cljs / api

ClojureScript API parser
http://cljs.github.io/api/
MIT License
193 stars 23 forks source link

Host site as github repo of md files? #192

Open shaunlebron opened 1 year ago

shaunlebron commented 1 year ago

I’d like to populate the docfiles with generated content to avoid hosting a separate site.

Embed clojure code inside <!-- clj (...) -> tags to generate content.

## Summary
...

## Details
...

## Examples
...

## Source

<!-- clj (cljs-api/get-source *entry*)-->
...
<!-- clj -->

And I’d like a way to run something like clj -M docgen.clj <docfile> to update it using info from cljs-api.edn maybe.

Migration plan

shaunlebron commented 1 year ago

assoc!

function |-

(assoc! tcoll key val) (assoc! tcoll key val & kvs)

Summary

assoc(iate) on transient collection

When applied to a transient map, adds mapping of key(s) to val(s).

When applied to a transient vector, sets the val at index. Note - index must be <= (count vector).

Returns coll.

Examples

(def tcoll (transient! {}))
(assoc! tcoll :a 1)
(assoc! tcoll :b 2)

tcoll
;;=> #<[object Object]> 

(:a tcoll)
;;=> 1

(:b tcoll)
;;=> 2

(def a (persistent! tcoll))
;;=> {:a 1 :b 2}

See Also

Source

When applied to a transient map, adds mapping of key(s) to
val(s). When applied to a transient vector, sets the val at index.
Note - index must be <= (count vector). Returns coll.

clojurescript:src/main/cljs/cljs/core.cljs

(defn assoc!
  ([tcoll key val]
    (-assoc! tcoll key val))
  ([tcoll key val & kvs]
    (let [ntcoll (-assoc! tcoll key val)]
      (if kvs
        (recur ntcoll (first kvs) (second kvs) (nnext kvs))
        ntcoll))))