fix(commands/doc): strip html in headings

docs-types
sammyette 2023-01-07 14:10:15 -04:00
parent 1226801a78
commit b594c4c30b
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
1 changed files with 23 additions and 28 deletions

View File

@ -10,6 +10,16 @@ commander.register('doc', function(args)
]] ]]
local modules = table.map(fs.readdir(moddocPath), function(f)
return lunacolors.underline(lunacolors.blue(string.gsub(f, '.md', '')))
end)
local doc = [[
Welcome to Hilbish's documentation viewer! Here you can find
documentation for builtin functions and other things related
to Hilbish.
Usage: doc <section> [subdoc]
Available sections: ]] .. table.concat(modules, ', ')
if #args > 0 then if #args > 0 then
local mod = args[1] local mod = args[1]
@ -63,8 +73,12 @@ commander.register('doc', function(args)
if mod == 'api' then if mod == 'api' then
funcdocs = string.format(apidocHeader, vals.title, vals.description or 'no description.') .. funcdocs funcdocs = string.format(apidocHeader, vals.title, vals.description or 'no description.') .. funcdocs
end end
doc = funcdocs:sub(1, #funcdocs - 1)
f:close()
end
local backtickOccurence = 0 local backtickOccurence = 0
local formattedFuncs = lunacolors.format(funcdocs:sub(1, #funcdocs - 1):gsub('`', function() print(lunacolors.format(doc:gsub('`', function()
backtickOccurence = backtickOccurence + 1 backtickOccurence = backtickOccurence + 1
if backtickOccurence % 2 == 0 then if backtickOccurence % 2 == 0 then
return '{reset}' return '{reset}'
@ -72,26 +86,7 @@ commander.register('doc', function(args)
return '{underline}{green}' return '{underline}{green}'
end end
end):gsub('#+.-\n', function(t) end):gsub('#+.-\n', function(t)
return '{bold}{magenta}' .. t .. '{reset}' local signature = t:gsub('<.->(.-)</.->', '{underline}%1'):gsub('\\', '<')
end)) return '{bold}{yellow}' .. signature .. '{reset}'
print(formattedFuncs) end)))
f:close()
return
end
local modules = table.map(fs.readdir(moddocPath), function(f)
return lunacolors.underline(lunacolors.blue(string.gsub(f, '.md', '')))
end)
io.write [[
Welcome to Hilbish's doc tool! Here you can find documentation for builtin
functions and other things.
Usage: doc <section> [subdoc]
A section is a module or a literal section and a subdoc is a subsection for it.
Available sections: ]]
io.flush()
print(table.concat(modules, ', '))
end) end)