#!/usr/bin/env moon
import layout from require 'docs.gen.layout'
export OUT, BASE
spit = (file, str) ->
file = io.open file, 'w'
file\write str
file\close!
{ OUT } = arg
BASE = '$(base)'
spit OUT, layout
style: '$(base)style.css'
title: '$(ldoc.title)'
class: 'ldoc'
preamble: '
# local iter = ldoc.modules.iter
# local M = ldoc.markup
# local function display_name(item)
# if item.type == "function" then
# return item.name:gsub(":new$", "")..item.args
# else return item.name end
# end
# local function use_li(ls)
# if #ls > 1 then return "
","
" else return "","" end
# end
# local base = module and "../../" or "../"'
body: {
class: 'ldoc'
'
# if ldoc.body then
$(ldoc.body)
# elseif not module then
# if ldoc.description then
$(M(ldoc.description))
# end
# if ldoc.full_description then
$(M(ldoc.full_description))
#end
# for kind, mods in ldoc.kinds() do
# kind = kind:lower()
$(kind)
# for m in mods() do
# if m.summary then
$(M(m.summary))
# else
# end
# end
# for kind, items in module.kinds() do
# kind = kind:lower()
$(kind)
# for item in items() do
– $(M(item.summary))
$(M(item.description))
# if item.usage then
# local li,il = use_li(item.usage)
usage:
# for usage in iter(item.usage) do
$(li)
$(usage)
$(il)
# end
# end
# if item.params and #item.params > 0 then
# local subnames = module.kinds:type_of(item).subnames
# if subnames then
$(subnames:lower()):
# end
# for parm in iter(item.params) do
# local param,sublist = item:subparam(parm)
# for p in iter(param) do
# local name = item:display_name_of(p)
# local tp = ldoc.typename(item:type_of_param(p))
# local def = item:default_of_param(p)
# local desc = item.params.map[p]
# local col = desc and desc ~= "" and ":" or ""
$(M(desc,item))
# if def == true then
(optional)
# elseif def then
(default $(def))
# end
# end
# end
# end
# if item.retgroups then local groups = item.retgroups
returns:
# for i,group in ldoc.ipairs(groups) do
# for r in group:iter() do
# local type, ctypes = item:return_type(r)
# local rt = ldoc.typename(type)
# local col = r.text and r.text ~= "" and ":" or ""
# if rt ~= "" then
($(rt))$(col)
# end
$(M(r.text,item))
# if ctypes then