From 31c22fe261c705b28d9443990831c497185d2100 Mon Sep 17 00:00:00 2001 From: XeroOl Date: Sun, 12 May 2024 12:01:06 -0500 Subject: [PATCH] doc extraction, also parse the module descriptions --- make-docs.fnl | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/make-docs.fnl b/make-docs.fnl index e99d8f9..43730b8 100644 --- a/make-docs.fnl +++ b/make-docs.fnl @@ -11,19 +11,23 @@ (local html (file:read :a)) -;; The section about the standard library +;; The section of the html about the standard library (local begin-index (assert (html:find "

.%.1 – Basic Functions.-\n"))) (local end-index (assert (html:find "

. – -;; TODO figure out

-(local sections []) +(local module-items []) +(local modules []) (fn loop [prev] (let [header (stdlib:find "

.-\n" (+ prev 1)) section (stdlib:sub prev (if header (- header 1)))] - (table.insert sections section) + (let [index (section:find "

")] + (if index + (do + (table.insert module-items (section:sub 1 (- index 1))) + (table.insert modules (section:sub index)))) + (table.insert module-items section)) (when header (loop header)))) (loop (stdlib:find "

.-\n")) @@ -74,15 +78,16 @@ (assert (not (signature:find "[%[%]]")) (.. "bad signature " signature)) ;; Debug prints for now. - (print "=============") - (print "```fnl") - (print signature) - (print "```") - (print description))) + (when false + (print "=============") + (print "```fnl") + (print signature) + (print "```") + (print description)))) (var done false) -(each [_ section (ipairs sections) &until done] +(each [_ section (ipairs module-items) &until done] (process-html-thing section)) ; (if (= (io.read) "done") ; (set done true)))