mirror of https://github.com/Hilbis/Hilbish
feat: use sinks for doc command
parent
c690691ede
commit
0e3fd1ff49
|
@ -2,7 +2,7 @@ local commander = require 'commander'
|
||||||
local fs = require 'fs'
|
local fs = require 'fs'
|
||||||
local lunacolors = require 'lunacolors'
|
local lunacolors = require 'lunacolors'
|
||||||
|
|
||||||
commander.register('doc', function(args)
|
commander.register('doc', function(args, sinks)
|
||||||
local moddocPath = hilbish.dataDir .. '/docs/'
|
local moddocPath = hilbish.dataDir .. '/docs/'
|
||||||
local apidocHeader = [[
|
local apidocHeader = [[
|
||||||
# %s
|
# %s
|
||||||
|
@ -30,7 +30,7 @@ commander.register('doc', function(args)
|
||||||
f = io.open(moddocPath .. subdocName .. '.md', 'rb')
|
f = io.open(moddocPath .. subdocName .. '.md', 'rb')
|
||||||
end
|
end
|
||||||
if not f then
|
if not f then
|
||||||
print('No documentation found for ' .. mod .. '.')
|
sinks.out:write('No documentation found for ' .. mod .. '.')
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -74,7 +74,7 @@ commander.register('doc', function(args)
|
||||||
end):gsub('#+.-\n', function(t)
|
end):gsub('#+.-\n', function(t)
|
||||||
return '{bold}{magenta}' .. t .. '{reset}'
|
return '{bold}{magenta}' .. t .. '{reset}'
|
||||||
end))
|
end))
|
||||||
print(formattedFuncs)
|
sinks.out:write(formattedFuncs)
|
||||||
f:close()
|
f:close()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -83,7 +83,7 @@ commander.register('doc', function(args)
|
||||||
return lunacolors.underline(lunacolors.blue(string.gsub(f, '.md', '')))
|
return lunacolors.underline(lunacolors.blue(string.gsub(f, '.md', '')))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
io.write [[
|
sinks.out:write [[
|
||||||
Welcome to Hilbish's doc tool! Here you can find documentation for builtin
|
Welcome to Hilbish's doc tool! Here you can find documentation for builtin
|
||||||
functions and other things.
|
functions and other things.
|
||||||
|
|
||||||
|
@ -91,7 +91,6 @@ Usage: doc <section> [subdoc]
|
||||||
A section is a module or a literal section and a subdoc is a subsection for it.
|
A section is a module or a literal section and a subdoc is a subsection for it.
|
||||||
|
|
||||||
Available sections: ]]
|
Available sections: ]]
|
||||||
io.flush()
|
|
||||||
|
|
||||||
print(table.concat(modules, ', '))
|
sinks.out:write(table.concat(modules, ', ') .. '\n')
|
||||||
end)
|
end)
|
||||||
|
|
Loading…
Reference in New Issue