Add config & script for generating HTML documentation with LDoc

This commit is contained in:
Jordan Irwin 2021-05-08 21:17:55 -07:00
parent 6205ae4031
commit 62175d6a75
2 changed files with 71 additions and 0 deletions

58
docs/config.ld Normal file

@ -0,0 +1,58 @@
title = "Sneeker mod for Minetest"
project = "sneeker"
format = "markdown"
not_luadoc = true
boilerplate = false
file = {"settings.lua",}
local function italic(value)
return "<i>" .. value .. "</i>"
end
new_type("setting", "Settings")
new_type("chatcmd", "Chat Commands", false, "chatparam")
custom_tags = {
{"type2",
title = "Type",
format = italic,
},
{"dfield",
title = "Definition Fields",
},
{"chatparam",
title = "Parameters",
},
{"option",
title = "Options",
},
{"settype",
title = "Type",
format = italic,
},
{"default",
title = "Default",
format = italic,
},
{"note",
title = "Notes",
format = italic,
},
}
local function chatcmd_handler(item)
local output = item.name
for i, p in ipairs(item.tags.chatparam) do
output = output .. " " .. p
end
return output
end
function custom_display_name_handler(item, default_handler)
if item.type == "chatcmd" then
return chatcmd_handler(item)
end
return default_handler(item)
end

13
docs/gendoc.sh Normal file

@ -0,0 +1,13 @@
#!/bin/bash
DOCS="$(dirname $(readlink -f $0))"
ROOT="$(dirname ${DOCS})"
CONFIG="${DOCS}/config.ld"
cd "${ROOT}"
# Clean old files
rm -rf "${DOCS}/api.html" "${DOCS}/scripts" "${DOCS}/modules"
# Create new files
ldoc -c "${CONFIG}" -d "${DOCS}" -o "api" "${ROOT}"