From 6dc1ca9cca762f3ebb93ceafef81be86ec0c5614 Mon Sep 17 00:00:00 2001 From: Locria Cyber <74560659+iacore@users.noreply.github.com> Date: Mon, 19 Jun 2023 20:02:01 +0000 Subject: [PATCH] Add generate-docs.scm --- tools/generate-docs.scm | 65 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 tools/generate-docs.scm diff --git a/tools/generate-docs.scm b/tools/generate-docs.scm new file mode 100644 index 00000000..bac011d4 --- /dev/null +++ b/tools/generate-docs.scm @@ -0,0 +1,65 @@ +(import + (chibi) + (chibi io) + (chibi string) + (chibi process) + (chibi filesystem) + (chibi pathname) + (srfi 18)) + +(define (walk-directory path) + #;(write (cons "visiting: " path)) + (apply append + (map + (lambda (filename) + (define path2 (string-append path "/" filename)) + #;(write `(,path2)) + (cond + ((equal? #\. (string-ref filename 0)) (list)) + ((file-directory? path2) (walk-directory path2)) + (else (list path2)))) + (directory-files path)))) + +(define (filter f xs) + (apply append + (map + (lambda (x) + (if (f x) + (list x) + (list))) + xs))) + +(define (filename-filter filename) + (and + (string-suffix? ".sld" filename) + (not (string-contains filename "-test")))) + + +(define (process x) + (define outfile + (string-append + "doc/" + (substring x 0 (- (string-length x) 4)) + ".html")) + (display `("Processing" ,x ,outfile)) + (newline) + (let ((output (process->string `("./chibi-scheme" "tools/chibi-doc" "--html" ,x)))) + (create-directory* (path-directory outfile)) + (call-with-output-file + outfile + (lambda (port) + (display output port))))) + +(define (fork-map f xs) + (if (pair? xs) + (let* ((x (car xs)) + (thread (make-thread (lambda () (f x))))) + (thread-start! thread) + (fork-map f (cdr xs)) + (thread-join! thread)) + (begin))) + +(fork-map + process + (filter filename-filter (walk-directory "lib"))) +