diff --git a/.ldoc/config.ld b/.ldoc/config.ld
index b85f38b..313ff11 100644
--- a/.ldoc/config.ld
+++ b/.ldoc/config.ld
@@ -1,6 +1,7 @@
-local print, error, type, table, ipairs, string, tostring
+local dofile, print, error, type, table, ipairs, string, tostring
if import then
+ dofile = import("dofile")
print = import("print")
error = import("error")
type = import("type")
@@ -38,43 +39,9 @@ local function video_frame(src)
.. ' allow="fullscreen;">'
end
-custom_tags = {
- {
- "privs",
- title = "Required Privileges",
- },
- {
- "video",
- title = "Video",
- format = video_frame,
- },
- {
- "youtube",
- title = "Video",
- format = function(value)
- return video_frame("https://www.youtube.com/embed/" .. value)
- end,
- },
- -- settings
- {
- "settype",
- title = "Setting Type",
- hidden = true,
- },
- {
- "default",
- title = "Default Value",
- hidden = true,
- },
- -- craft items/tools
- {
- "img",
- title = "Image",
- format = function(value)
- return "
"
- end,
- },
-}
+
+local tags
+tags, custom_tags = dofile(".ldoc/tags.ld")
-- START: handling items to prevent re-parsing
@@ -172,6 +139,27 @@ local function chatcmd_handler(item)
item.description = item.description .. "\n\n### Parameters:"
end
+ if item.tags.chatparam then
+ local pstring = "### Parameters:\n"
+ for _, cp in ipairs(item.tags.chatparam) do
+ local idx, key, desc = cp:find(" ")
+ if idx then
+ key = cp:sub(1, idx-1)
+ value = cp:sub(idx)
+ else
+ key = cp
+ end
+
+ pstring = pstring .. '\n- '
+ .. key .. ''
+ if value then
+ pstring = pstring .. value
+ end
+
+ item.description = item.description .. "\n\n" .. pstring
+ end
+ end
+
return item
end
@@ -182,10 +170,27 @@ function custom_display_name_handler(item, default_handler)
elseif item.type == "chatcmd" then
item = chatcmd_handler(item)
end
+
+ local parse_tags = {"priv", "note"}
+ for _, pt in ipairs(parse_tags) do
+ local tvalues = item.tags[pt]
+ if tvalues then
+ local tstring = ""
+
+ local title = tags.get_title(pt)
+ if title then
+ tstring = tstring .. "\n\n### " .. title .. ":\n"
+ end
+
+ for _, tv in ipairs(tvalues) do
+ tstring = tstring .. "\n- " .. tags.format(pt, tv)
+ end
+
+ item.description = item.description .. tstring
+ end
+ end
end
- if item then
- register(item)
- return default_handler(item)
- end
+ register(item)
+ return default_handler(item)
end
diff --git a/.ldoc/tags.ld b/.ldoc/tags.ld
new file mode 100644
index 0000000..91ab6dd
--- /dev/null
+++ b/.ldoc/tags.ld
@@ -0,0 +1,81 @@
+
+local tags = {}
+local tag_list = {}
+local custom_tags = {}
+
+local register_tag = function(name, tag)
+ local new_tag = {name, title=tag.title, hidden=tag.hidden, format=tag.format}
+ table.insert(custom_tags, new_tag)
+ tag_list[name] = {title=tag.title, format=tag.format}
+end
+
+tags.get_title = function(tname)
+ local t = tag_list[tname]
+ if t then
+ return t.title
+ end
+end
+
+tags.format = function(tname, value)
+ local t = tag_list[tname]
+ if t then
+ if type(t.format) == "function" then
+ value = t.format(value)
+ end
+ end
+
+ return value
+end
+
+
+local new_tags = {
+ ["priv"] = {
+ title = "Required Privileges",
+ hidden = true,
+ },
+ ["note"] = {
+ title = "Notes",
+ hidden = true,
+ format = function(value)
+ return "*" .. value .. "*"
+ end,
+ },
+ ["video"] = {
+ title = "Video",
+ format = video_frame,
+ },
+ ["youtube"] = {
+ title = "Video",
+ format = function(value)
+ return video_frame("https://www.youtube.com/embed/" .. value)
+ end,
+ },
+ -- settings
+ ["settype"] = {
+ title = "Setting Type",
+ hidden = true,
+ },
+ ["default"] = {
+ title = "Default Value",
+ hidden = true,
+ },
+ -- craft items/tools
+ ["img"] = {
+ title = "Image",
+ format = function(value)
+ return "
"
+ end,
+ },
+ -- chat commands
+ ["chatparam"] = {
+ title = "Parameters",
+ hidden = true,
+ },
+}
+
+for k, v in pairs(new_tags) do
+ register_tag(k, v)
+end
+
+
+return tags, custom_tags