Start on #55, but because Minetest blocks our read attempts to Chat-Command-Reference (symlinks don't help), we can't continue this

This commit is contained in:
Starbeamrainbowlabs 2021-05-30 16:18:08 +01:00
parent 0474f5a0ee
commit 5083ea05ca
No known key found for this signature in database
GPG Key ID: 1BE5172E637709C2
3 changed files with 75 additions and 0 deletions

@ -0,0 +1,18 @@
-- ██████ ██████ ██████ ███████
-- ██ ██ ██ ██ ██ ██
-- ██ ██ ██ ██ ██ ███████
-- ██ ██ ██ ██ ██ ██
-- ██████ ██████ ██████ ███████
-- This directory contains support for the doc mod:
-- https://content.minetest.net/packages/Wuzzy/doc/
-- API docs: https://repo.or.cz/minetest_doc.git/blob/HEAD:/API.md
-- The strategy here is not to have duplicate content, but to pull data from
-- existing sources.
-- Long-form article descriptions: Chat-Command-Reference.md
-- Short descriptions: Undecided, but maybe worldedit.registered_commands
worldeditadditions.doc = {}
dofile(worldeditadditions_commands.modpath.."/doc/parse_reference.lua")

@ -0,0 +1,45 @@
local function get_reference()
local lines = {}
for line in io.lines(worldeditadditions_commands.modpath.."/Chat-Command-Reference.md") do
table.insert(lines, line)
end
return lines
end
local function group_by_heading(lines, max_level)
local groups = {}
local acc = {}
for i,line in ipairs(lines) do
if worldeditadditions.str_starts(line, "#") then
local _, _, heading, headingtext = line:find("(#+)%s*(.*)")
if #heading <= max_level then
table.insert(groups, {
level = #heading,
heading = headingtext,
text = table.concat(acc, "\n")
})
acc = {}
end
else
table.insert(acc, line)
end
end
return groups
end
function worldeditadditions.doc.parse_reference()
local lines = get_reference()
local headings = worldeditadditions.table_filter(
group_by_heading(lines, 2),
function(item, i) return item.level ~= 2 end
)
for i,value in ipairs(headings) do
print(i, "level", level, "heading", heading, "text", text)
end
end
worldeditadditions.doc.parse_reference()

@ -62,6 +62,18 @@ else
minetest.log("action", "[WorldEditAdditions] bonemeal mod not detected: //bonemeal and //forest commands not registered (if you see this message and you're using an alternative mod that provides bonemeal, please get in touch by opening an issue)")
end
-- Minetest doesn't allow you to read from files outside the mod
-- directory - even if you're part of a modpack you can't read from the main
-- modpack directory. Furthermore, symlinks don't help.
-- If you have a solution to this issue, please comment on this GitHub issue:
-- https://github.com/sbrl/Minetest-WorldEditAdditions/issues/55
-- NOTE TO SELF: When uncommenting this, also add "doc?" to depends.txt
-- if minetest.get_modpath("doc") then
-- dofile(we_c.modpath.."/doc/init.lua")
-- else
-- minetest.log("action", "[WorldEditAdditions] doc mod not detected: not registering doc category with extended help")
-- end
worldedit.alias_command("smoothadv", "convolve")
worldedit.alias_command("conv", "convolve")