((fn (dox examples) (def dox-add-doc (name what texts args src) (hash-set dox name (cons (list name what texts args src) (hash-get dox sym)))) (def dox-add-examples (name example-exprs) (hash-set examples name (cons example-exprs (hash-get examples name)))) (def dox-lookup (sym) (hash-get dox sym)) (def dox? (sym) (hash-key? dox sym)) (def dox-names () (hash-keys dox)) (def dox-what-is? (name) (cond (dox? name) (cadr (car (dox-lookup name))))) (def dox-src (name) (cond (dox? name) (car (cddr (cddr (car (dox-lookup name))))))) (def dox-examples (name) (hash-get examples name)) (def dox-example-names () (hash-keys examples)) (def dox-arg-names (name) (cond (dox? name) (cadddr (car (dox-lookup name)))))) (hash) (hash)) (def isa-comment? (thing) (cond (pair? thing) (eq? (car thing) 'comment))) (def rev-accum (things acc) (cond (no things) acc (rev-accum (cdr things) (cons (car things) acc)))) (def rev (things) (rev-accum things nil)) (def dox-gather-comments (body acc) (cond (isa-comment? (car body)) (dox-gather-comments (cdr body) (cons (cadar body) acc)) (list (rev acc) body))) (def define-mac-expr (name args documentation body) ; used internally by 'mac `(do (hash-set macs ',name (fn ,args ,@body)) (dox-add-doc ',name 'mac ',documentation ',args '(mac ,name ,args ,@body)))) (hash-set macs 'mac (fn (name args . body) (apply define-mac-expr name args (dox-gather-comments body)))) (dox-add-doc 'mac 'mac '("define a new global macro") '(name args . body) (dox-src 'define-mac-expr)) (dox-add-doc 'do 'mac '("perform a series of operations") 'args '`((fn nil ,@args))) (mac def-assign args `(assign ,@args)) (def define-def-expr (name args documentation body) ; used internally by 'def `(do (def-assign ,name (fn ,args ,@body)) (dox-add-doc ',name 'def ',documentation ',args '(def ,name ,args ,@body)))) (mac def (name args . body) ; define a new function in the global namespace (apply define-def-expr name args (dox-gather-comments body)))