34 lines
1.4 KiB
Fennel
34 lines
1.4 KiB
Fennel
"Script to generate /src/fennel-ls/docs/lua54.fnl and friends automatically"
|
|
(local {: sh} (require :tools.util.sh))
|
|
|
|
(fn curl-cached [url]
|
|
(let [filename (.. "build/" (url:gsub "[/:]" "_"))
|
|
file (io.open filename :r)]
|
|
(if file
|
|
file
|
|
(do
|
|
(sh "curl" url [">"] filename)
|
|
(io.open filename :r)))))
|
|
|
|
(fn derive-docs-from-url [url out-filename convert]
|
|
(let [result
|
|
(convert
|
|
(with-open [file (curl-cached url)]
|
|
(file:read "*a")))]
|
|
(with-open [file (io.open (.. "src/fennel-ls/docs/" out-filename) :w)]
|
|
(file:write ";; auto-generated by `make docs` from fennel-ls. Contents come from " url "\n"
|
|
result "\n"))))
|
|
|
|
(fn main []
|
|
(sh :mkdir :-p "build/")
|
|
(sh :mkdir :-p "src/fennel-ls/docs/")
|
|
(let [{:convert lua-manual} (require :tools.get-docs.lua-manual)
|
|
{:convert tic-manual} (require :tools.get-docs.tic80)]
|
|
(derive-docs-from-url "https://www.lua.org/manual/5.1/manual.html" "lua51.fnl" lua-manual)
|
|
(derive-docs-from-url "https://www.lua.org/manual/5.2/manual.html" "lua52.fnl" lua-manual)
|
|
(derive-docs-from-url "https://www.lua.org/manual/5.3/manual.html" "lua53.fnl" lua-manual)
|
|
(derive-docs-from-url "https://www.lua.org/manual/5.4/manual.html" "lua54.fnl" lua-manual)
|
|
(derive-docs-from-url "https://tic80.com/learn" "tic80.fnl" tic-manual)))
|
|
|
|
(main)
|