2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-04-20 20:43:23 +00:00

feat: generate toc for lua modules

This commit is contained in:
sammyette 2025-03-19 22:06:18 -04:00
parent 6514c8c937
commit 681d45f892
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
5 changed files with 38 additions and 1 deletions

View File

@ -116,12 +116,14 @@ for iface, dps in pairs(pieces) do
local newOrNotNature = exists and mod ~= 'nature' local newOrNotNature = exists and mod ~= 'nature'
local f <close> = io.open(path, newOrNotNature and 'r+' or 'w+') local f <close> = io.open(path, newOrNotNature and 'r+' or 'w+')
local tocPos
if not newOrNotNature then if not newOrNotNature then
f:write(string.format(header, 'Module', iface, (descriptions[iface] and #descriptions[iface] > 0) and descriptions[iface][1] or 'No description.', docParent)) f:write(string.format(header, 'Module', iface, (descriptions[iface] and #descriptions[iface] > 0) and descriptions[iface][1] or 'No description.', docParent))
if descriptions[iface] and #descriptions[iface] > 0 then if descriptions[iface] and #descriptions[iface] > 0 then
table.remove(descriptions[iface], 1) table.remove(descriptions[iface], 1)
f:write(string.format('\n## Introduction\n%s\n\n', table.concat(descriptions[iface], '\n'))) f:write(string.format('\n## Introduction\n%s\n\n', table.concat(descriptions[iface], '\n')))
f:write('## Functions\n') f:write('## Functions\n')
tocPos = f:seek()
end end
end end
print(f) print(f)
@ -129,7 +131,6 @@ for iface, dps in pairs(pieces) do
print('mod and path:', mod, path) print('mod and path:', mod, path)
local tocSearch = false local tocSearch = false
local tocPos
for line in f:lines() do for line in f:lines() do
if line:match '^## Functions' then if line:match '^## Functions' then
tocSearch = true tocSearch = true

View File

@ -20,6 +20,14 @@ The `hilbish.message` type is a table with the following keys:
`read` (boolean): Whether the full message has been read or not. `read` (boolean): Whether the full message has been read or not.
## Functions ## Functions
|<a href="#unreadCount">unreadCount()</a>|Returns the amount of unread messages.|
|<a href="#readAll">readAll()</a>|Marks all messages as read.|
|<a href="#send">send(message)</a>|Sends a message.|
|<a href="#read">read(idx)</a>|Marks a message at `idx` as read.|
|<a href="#delete">delete(idx)</a>|Deletes the message at `idx`.|
|<a href="#clear">clear()</a>|Deletes all messages.|
|<a href="#all">all()</a>|Returns all messages.|
<hr> <hr>
<div id='all'> <div id='all'>
<h4 class='heading'> <h4 class='heading'>
@ -34,6 +42,7 @@ Returns all messages.
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr>
<div id='clear'> <div id='clear'>
<h4 class='heading'> <h4 class='heading'>
@ -48,6 +57,7 @@ Deletes all messages.
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr>
<div id='delete'> <div id='delete'>
<h4 class='heading'> <h4 class='heading'>
@ -64,6 +74,7 @@ Deletes the message at `idx`.
</div> </div>
<hr> <hr>
<div id='read'> <div id='read'>
<h4 class='heading'> <h4 class='heading'>
@ -80,6 +91,7 @@ Marks a message at `idx` as read.
</div> </div>
<hr> <hr>
<div id='send'> <div id='send'>
<h4 class='heading'> <h4 class='heading'>
@ -96,6 +108,7 @@ Sends a message.
</div> </div>
<hr> <hr>
<div id='readAll'> <div id='readAll'>
<h4 class='heading'> <h4 class='heading'>
@ -110,6 +123,7 @@ Marks all messages as read.
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr>
<div id='unreadCount'> <div id='unreadCount'>
<h4 class='heading'> <h4 class='heading'>

View File

@ -120,6 +120,7 @@ This is the equivalent of using `source`.
</div> </div>
<hr> <hr>
<div id='getCurrent'> <div id='getCurrent'>
<h4 class='heading'> <h4 class='heading'>
@ -134,6 +135,7 @@ Returns the current runner by name.
This function has no parameters. This function has no parameters.
</div> </div>
<hr> <hr>
<div id='setCurrent'> <div id='setCurrent'>
<h4 class='heading'> <h4 class='heading'>
@ -150,6 +152,7 @@ Sets Hilbish's runner mode by name.
</div> </div>
<hr> <hr>
<div id='add'> <div id='add'>
<h4 class='heading'> <h4 class='heading'>
@ -170,6 +173,7 @@ If runner is a table, it must have the run function in it.
</div> </div>
<hr> <hr>
<div id='get'> <div id='get'>
<h4 class='heading'> <h4 class='heading'>
@ -186,6 +190,7 @@ Get a runner by name.
</div> </div>
<hr> <hr>
<div id='set'> <div id='set'>
<h4 class='heading'> <h4 class='heading'>
@ -207,6 +212,7 @@ The runner table must have the run function in it.
</div> </div>
<hr> <hr>
<div id='exec'> <div id='exec'>
<h4 class='heading'> <h4 class='heading'>

View File

@ -13,6 +13,12 @@ The dirs module defines a small set of functions to store and manage
directories. directories.
## Functions ## Functions
|<a href="#recent">recent(idx)</a>|Get entry from recent directories list based on index.|
|<a href="#pop">pop(num)</a>|Remove the specified amount of dirs from the recent directories list.|
|<a href="#peak">peak(num)</a>|Look at `num` amount of recent directories, starting from the latest.|
|<a href="#push">push(dir)</a>|Add `dir` to the recent directories list.|
|<a href="#setOld">setOld(d)</a>|Sets the old directory string.|
<hr> <hr>
<div id='setOld'> <div id='setOld'>
<h4 class='heading'> <h4 class='heading'>
@ -29,6 +35,7 @@ Sets the old directory string.
</div> </div>
<hr> <hr>
<div id='push'> <div id='push'>
<h4 class='heading'> <h4 class='heading'>
@ -45,6 +52,7 @@ Add `dir` to the recent directories list.
</div> </div>
<hr> <hr>
<div id='peak'> <div id='peak'>
<h4 class='heading'> <h4 class='heading'>
@ -62,6 +70,7 @@ This returns a table of recent directories, up to the `num` amount.
</div> </div>
<hr> <hr>
<div id='pop'> <div id='pop'>
<h4 class='heading'> <h4 class='heading'>
@ -78,6 +87,7 @@ Remove the specified amount of dirs from the recent directories list.
</div> </div>
<hr> <hr>
<div id='recent'> <div id='recent'>
<h4 class='heading'> <h4 class='heading'>

View File

@ -15,6 +15,10 @@ This is only documented for the sake of it. It's only intended use
is by the Greenhouse pager. is by the Greenhouse pager.
## Functions ## Functions
|<a href="#renderCodeBlock">renderCodeBlock(text)</a>|Assembles and renders a code block. This returns|
|<a href="#highlight">highlight(text)</a>|Performs basic Lua code highlighting.|
|<a href="#renderInfoBlock">renderInfoBlock(type, text)</a>|Renders an info block. An info block is a block of text with|
<hr> <hr>
<div id='renderInfoBlock'> <div id='renderInfoBlock'>
<h4 class='heading'> <h4 class='heading'>
@ -35,6 +39,7 @@ an icon and styled text block.
</div> </div>
<hr> <hr>
<div id='highlight'> <div id='highlight'>
<h4 class='heading'> <h4 class='heading'>
@ -51,6 +56,7 @@ Performs basic Lua code highlighting.
</div> </div>
<hr> <hr>
<div id='renderCodeBlock'> <div id='renderCodeBlock'>
<h4 class='heading'> <h4 class='heading'>