(define xtmdoc-export-caches-to-json
(lambda (file-path include-nativefuncs?)
(let ((outfile-port (open-output-file file-path)))
(display "[\n" outfile-port)
(let loop ((doc-alists (cl:sort (xtmdoc-all-doc-alists include-nativefuncs?)
(lambda (a b) (not (xtmdoc-alist-lessthan a b))))))
(if (null? doc-alists)
(begin
(display "\n]" outfile-port)
(close-port outfile-port)
(print "Succesfully exported docs as json to " file-path "\n")
#t)
(begin
(xtmdoc-write-alist-as-json (car doc-alists) outfile-port)
(if (not (null? (cdr doc-alists)))
(display ",\n" outfile-port))
(loop (cdr doc-alists))))))))