last doc gen update before I do the changes
This commit is contained in:
parent
1c925ea1fb
commit
043cfc033c
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,2 +1,3 @@
|
||||
/fennel-ls
|
||||
/result
|
||||
/lua*.html
|
||||
|
||||
@ -15,6 +15,7 @@
|
||||
(let [begin-index (assert (html:find "<h2>.%.1 – <a name=\".%.1\">Basic Functions.-\n") "no basic functions?")
|
||||
end-index (assert (html:find "<h1>. – <a name=\".\".-\n" begin-index))
|
||||
stdlib (html:sub begin-index (- end-index 1))
|
||||
last-update (html:match "Last update:\n(.-)\n")
|
||||
fields []
|
||||
modules []]
|
||||
(fn loop [prev]
|
||||
@ -28,7 +29,7 @@
|
||||
(table.insert fields section)))
|
||||
(when header (loop header))))
|
||||
(loop (stdlib:find "<hr><h3>.-\n"))
|
||||
(values modules fields)))
|
||||
(values modules fields last-update)))
|
||||
|
||||
(fn html-to-markdown [str]
|
||||
(let [str
|
||||
@ -56,9 +57,9 @@
|
||||
(: :gsub "[ \n]%(see <a href=\"#[^\"]+\">[^<]+</a>%)." "")
|
||||
(: :gsub "[ \n]%(<a href=\"#[^\"]+\">[^<]+</a>%)." "")
|
||||
;; code blocks
|
||||
(: :gsub "<pre>\n?([^<]+)\n?</pre>" "```lua\n%1\n```")
|
||||
(: :gsub "<pre>\n?([^<]-)\n?</pre>" "```lua\n%1\n```")
|
||||
;; list items to indented * thingies
|
||||
(: :gsub "<li>([^<]+)</li>" #(.. "* " ($:gsub "\n" "\n ")))
|
||||
(: :gsub "<li>([^<]+)</li>" #(.. "* " (: ($:match "^\n*(.-)\n*$") :gsub "\n" "\n ")))
|
||||
(: :gsub "</?ul>" ""))
|
||||
;; 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"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user