From 62175d6a75cb0ba812a671c1b831658c6782ab16 Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Sat, 8 May 2021 21:17:55 -0700 Subject: [PATCH] Add config & script for generating HTML documentation with LDoc --- docs/config.ld | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++ docs/gendoc.sh | 13 +++++++++++ 2 files changed, 71 insertions(+) create mode 100644 docs/config.ld create mode 100644 docs/gendoc.sh diff --git a/docs/config.ld b/docs/config.ld new file mode 100644 index 0000000..765a1f9 --- /dev/null +++ b/docs/config.ld @@ -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 "" .. value .. "" +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 diff --git a/docs/gendoc.sh b/docs/gendoc.sh new file mode 100644 index 0000000..7ed4130 --- /dev/null +++ b/docs/gendoc.sh @@ -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}"