fix: toc appending

document-lua
sammyette 2025-01-12 17:53:05 -04:00
parent b7af6177ba
commit 5af9aa281e
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
2 changed files with 35 additions and 12 deletions

View File

@ -19,8 +19,6 @@ for _, fname in ipairs(files) do
local docPiece = {}
local lines = {}
local lineno = 0
local tocPos
local tocSearch = false
for line in f:lines() do
lineno = lineno + 1
lines[lineno] = line
@ -137,11 +135,12 @@ for iface, dps in pairs(pieces) do
sig = sig .. ')'
if tocPos then
local pos = f:seek()
f:seek('set', tocPos)
f:write(string.format('|<a href="#%s">%s</a>|%s|\n', func, string.format('%s(%s)', func, params), docs.description[1]))
tocPos = f:seek()
f:seek('set', pos)
local contents = f:read '*a'
f:seek('set', tocPos)
local tocLine = string.format('|<a href="#%s">%s</a>|%s|\n', func, string.format('%s(%s)', func, params), docs.description[1])
f:write(tocLine .. contents)
f:seek 'end'
end
f:write(string.format('<hr>\n<div id=\'%s\'>\n', func))

View File

@ -57,13 +57,37 @@ end)
|<a href="#runner.setMode">setMode(cb)</a>|This is the same as the `hilbish.runnerMode` function.|
|<a href="#runner.lua">lua(cmd)</a>|Evaluates `cmd` as Lua input. This is the same as using `dofile`|
|<a href="#runner.sh">sh(cmd)</a>|Runs a command in Hilbish's shell script interpreter.|
|<a href="#getCurrent">getCurrent()</a>|Returns the current runner by name.|
|<a href="#setCurrent">setCurrent(name)</a>|Sets the current interactive/command line runner mode.|
|<a href="#add">add(name, runner)</a>|Adds a runner to the table of available runners. If runner is a table,|
|<a href="#get">get(name)</a>|Get a runner by name.|
|<a href="#set">set(name, runner)</a>|Sets a runner by name. The runner table must have the run function in it.|
|<a href="#exec">exec(cmd, runnerName)</a>|Executes cmd with a runner. If runnerName isn't passed, it uses|
d)
|<a href="#set">set(name, runner)</a>|Sets a runner by name. The runner table must have the run function in it.|
|<a href="#get">get(name)</a>|Get a runner by name.|
|<a href="#add">add(name, runner)</a>|Adds a runner to the table of available runners. If runner is a table,|
|<a href="#setCurrent">setCurrent(name)</a>|Sets the current interactive/command line runner mode.|
|<a href="#getCurrent">getCurrent()</a>|Returns the current runner by name.|
<hr>
<div id='runner.setMode'>
<h4 class='heading'>
hilbish.runner.setMode(cb)
<a href="#runner.setMode" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
This is the same as the `hilbish.runnerMode` function.
It takes a callback, which will be used to execute all interactive input.
In normal cases, neither callbacks should be overrided by the user,
as the higher level functions listed below this will handle it.
#### Parameters
`function` **`cb`**
</div>
<hr>
<div id='runner.lua'>
<h4 class='heading'>
hilbish.runner.lua(cmd)
<a href="#runner.lua" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>