diff --git a/.gitignore b/.gitignore index 9f43c49..854f9f4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /fennel-ls /result +/lua*.html diff --git a/make-docs.fnl b/make-docs.fnl index 97c07d8..0f6976f 100644 --- a/make-docs.fnl +++ b/make-docs.fnl @@ -15,6 +15,7 @@ (let [begin-index (assert (html:find "

.%.1 – Basic Functions.-\n") "no basic functions?") end-index (assert (html:find "

. –

.-\n")) - (values modules fields))) + (values modules fields last-update))) (fn html-to-markdown [str] (let [str @@ -56,9 +57,9 @@ (: :gsub "[ \n]%(see [^<]+%)." "") (: :gsub "[ \n]%([^<]+%)." "") ;; code blocks - (: :gsub "
\n?([^<]+)\n?
" "```lua\n%1\n```") + (: :gsub "
\n?([^<]-)\n?
" "```lua\n%1\n```") ;; list items to indented * thingies - (: :gsub "
  • ([^<]+)
  • " #(.. "* " ($:gsub "\n" "\n "))) + (: :gsub "
  • ([^<]+)
  • " #(.. "* " (: ($:match "^\n*(.-)\n*$") :gsub "\n" "\n "))) (: :gsub "" "")) ;; check to ensure that all the tags have been defeated tag (str:match "<[^>]+>[^>]+>")] @@ -156,10 +157,10 @@ (fn main [] (each [_ version (ipairs [:5.1 :5.2 :5.3 :5.4])] - (let [infile (open-file-cached - (.. "lua" version ".html") - (.. "https://www.lua.org/manual/" version "/manual.html")) - (modules module-items) (parse-html (infile:read :a)) + (let [local-filename (.. "lua" version ".html") + url (.. "https://www.lua.org/manual/" version "/manual.html") + infile (open-file-cached local-filename url) + (modules module-items last-update) (parse-html (infile:read :a)) docs (collect [_ module (ipairs modules)] (parse-h2-section module))] @@ -177,6 +178,8 @@ (let [outfile (io.open (.. "src/fennel-ls/docs/lua" (version:gsub "%." "") ".fnl") :w)] (local {: view : sym : list} (require :fennel)) (outfile:write + ";; Generated by make-docs.fnl. Contents come from " url "\n" + ";; This lua manual was last updated " last-update "\n" (view (list (sym :local) (sym :docs) docs)) "\n" "(set docs._G.fields docs)\n"