Skip to content

Commit 5af9aa2

Browse files
committed
fix: toc appending
1 parent b7af617 commit 5af9aa2

File tree

2 files changed

+35
-12
lines changed

2 files changed

+35
-12
lines changed

cmd/docgen/docgen.lua

+5-6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ for _, fname in ipairs(files) do
1919
local docPiece = {}
2020
local lines = {}
2121
local lineno = 0
22-
local tocPos
23-
local tocSearch = false
2422
for line in f:lines() do
2523
lineno = lineno + 1
2624
lines[lineno] = line
@@ -137,11 +135,12 @@ for iface, dps in pairs(pieces) do
137135
sig = sig .. ')'
138136

139137
if tocPos then
140-
local pos = f:seek()
141138
f:seek('set', tocPos)
142-
f:write(string.format('|<a href="#%s">%s</a>|%s|\n', func, string.format('%s(%s)', func, params), docs.description[1]))
143-
tocPos = f:seek()
144-
f:seek('set', pos)
139+
local contents = f:read '*a'
140+
f:seek('set', tocPos)
141+
local tocLine = string.format('|<a href="#%s">%s</a>|%s|\n', func, string.format('%s(%s)', func, params), docs.description[1])
142+
f:write(tocLine .. contents)
143+
f:seek 'end'
145144
end
146145

147146
f:write(string.format('<hr>\n<div id=\'%s\'>\n', func))

docs/api/hilbish/hilbish.runner.md

+30-6
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,37 @@ end)
5757
|<a href="#runner.setMode">setMode(cb)</a>|This is the same as the `hilbish.runnerMode` function.|
5858
|<a href="#runner.lua">lua(cmd)</a>|Evaluates `cmd` as Lua input. This is the same as using `dofile`|
5959
|<a href="#runner.sh">sh(cmd)</a>|Runs a command in Hilbish's shell script interpreter.|
60-
|<a href="#getCurrent">getCurrent()</a>|Returns the current runner by name.|
61-
|<a href="#setCurrent">setCurrent(name)</a>|Sets the current interactive/command line runner mode.|
62-
|<a href="#add">add(name, runner)</a>|Adds a runner to the table of available runners. If runner is a table,|
63-
|<a href="#get">get(name)</a>|Get a runner by name.|
64-
|<a href="#set">set(name, runner)</a>|Sets a runner by name. The runner table must have the run function in it.|
6560
|<a href="#exec">exec(cmd, runnerName)</a>|Executes cmd with a runner. If runnerName isn't passed, it uses|
66-
d)
61+
|<a href="#set">set(name, runner)</a>|Sets a runner by name. The runner table must have the run function in it.|
62+
|<a href="#get">get(name)</a>|Get a runner by name.|
63+
|<a href="#add">add(name, runner)</a>|Adds a runner to the table of available runners. If runner is a table,|
64+
|<a href="#setCurrent">setCurrent(name)</a>|Sets the current interactive/command line runner mode.|
65+
|<a href="#getCurrent">getCurrent()</a>|Returns the current runner by name.|
66+
67+
<hr>
68+
<div id='runner.setMode'>
69+
<h4 class='heading'>
70+
hilbish.runner.setMode(cb)
71+
<a href="#runner.setMode" class='heading-link'>
72+
<i class="fas fa-paperclip"></i>
73+
</a>
74+
</h4>
75+
76+
This is the same as the `hilbish.runnerMode` function.
77+
It takes a callback, which will be used to execute all interactive input.
78+
In normal cases, neither callbacks should be overrided by the user,
79+
as the higher level functions listed below this will handle it.
80+
81+
#### Parameters
82+
`function` **`cb`**
83+
84+
85+
</div>
86+
87+
<hr>
88+
<div id='runner.lua'>
89+
<h4 class='heading'>
90+
hilbish.runner.lua(cmd)
6791
<a href="#runner.lua" class='heading-link'>
6892
<i class="fas fa-paperclip"></i>
6993
</a>

0 commit comments

Comments
 (0)