mirror of
https://github.com/sbrl/Minetest-WorldEditAdditions.git
synced 2024-12-22 19:45:02 +00:00
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:
parent
0474f5a0ee
commit
5083ea05ca
3 changed files with 75 additions and 0 deletions
18
worldeditadditions_commands/doc/init.lua
Normal file
18
worldeditadditions_commands/doc/init.lua
Normal file
|
@ -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")
|
45
worldeditadditions_commands/doc/parse_reference.lua
Normal file
45
worldeditadditions_commands/doc/parse_reference.lua
Normal file
|
@ -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")
|
||||
|
|
Loading…
Reference in a new issue