From 681d45f8922f08e7a34a0cb4ac78686a8b989b8f Mon Sep 17 00:00:00 2001 From: sammyette Date: Wed, 19 Mar 2025 22:06:18 -0400 Subject: [PATCH] feat: generate toc for lua modules --- cmd/docgen/docgen.lua | 3 ++- docs/api/hilbish/hilbish.messages.md | 14 ++++++++++++++ docs/api/hilbish/hilbish.runner.md | 6 ++++++ docs/nature/dirs.md | 10 ++++++++++ docs/nature/doc.md | 6 ++++++ 5 files changed, 38 insertions(+), 1 deletion(-) diff --git a/cmd/docgen/docgen.lua b/cmd/docgen/docgen.lua index 5f25937..3a28926 100644 --- a/cmd/docgen/docgen.lua +++ b/cmd/docgen/docgen.lua @@ -116,12 +116,14 @@ for iface, dps in pairs(pieces) do local newOrNotNature = exists and mod ~= 'nature' local f = io.open(path, newOrNotNature and 'r+' or 'w+') + local tocPos 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)) if descriptions[iface] and #descriptions[iface] > 0 then table.remove(descriptions[iface], 1) f:write(string.format('\n## Introduction\n%s\n\n', table.concat(descriptions[iface], '\n'))) f:write('## Functions\n') + tocPos = f:seek() end end print(f) @@ -129,7 +131,6 @@ for iface, dps in pairs(pieces) do print('mod and path:', mod, path) local tocSearch = false - local tocPos for line in f:lines() do if line:match '^## Functions' then tocSearch = true diff --git a/docs/api/hilbish/hilbish.messages.md b/docs/api/hilbish/hilbish.messages.md index e36119b..023b87c 100644 --- a/docs/api/hilbish/hilbish.messages.md +++ b/docs/api/hilbish/hilbish.messages.md @@ -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. ## Functions +|unreadCount()|Returns the amount of unread messages.| +|readAll()|Marks all messages as read.| +|send(message)|Sends a message.| +|read(idx)|Marks a message at `idx` as read.| +|delete(idx)|Deletes the message at `idx`.| +|clear()|Deletes all messages.| +|all()|Returns all messages.| +

@@ -34,6 +42,7 @@ Returns all messages. This function has no parameters.

+

@@ -48,6 +57,7 @@ Deletes all messages. This function has no parameters.

+

@@ -64,6 +74,7 @@ Deletes the message at `idx`.

+

@@ -80,6 +91,7 @@ Marks a message at `idx` as read.

+

@@ -96,6 +108,7 @@ Sends a message.

+

@@ -110,6 +123,7 @@ Marks all messages as read. This function has no parameters.

+

diff --git a/docs/api/hilbish/hilbish.runner.md b/docs/api/hilbish/hilbish.runner.md index c4cfbe4..0bbc268 100644 --- a/docs/api/hilbish/hilbish.runner.md +++ b/docs/api/hilbish/hilbish.runner.md @@ -120,6 +120,7 @@ This is the equivalent of using `source`.

+

@@ -134,6 +135,7 @@ Returns the current runner by name. This function has no parameters.

+

@@ -150,6 +152,7 @@ Sets Hilbish's runner mode by name.

+

@@ -170,6 +173,7 @@ If runner is a table, it must have the run function in it.

+

@@ -186,6 +190,7 @@ Get a runner by name.

+

@@ -207,6 +212,7 @@ The runner table must have the run function in it.

+

diff --git a/docs/nature/dirs.md b/docs/nature/dirs.md index 27540ce..d2dc5d0 100644 --- a/docs/nature/dirs.md +++ b/docs/nature/dirs.md @@ -13,6 +13,12 @@ The dirs module defines a small set of functions to store and manage directories. ## Functions +|recent(idx)|Get entry from recent directories list based on index.| +|pop(num)|Remove the specified amount of dirs from the recent directories list.| +|peak(num)|Look at `num` amount of recent directories, starting from the latest.| +|push(dir)|Add `dir` to the recent directories list.| +|setOld(d)|Sets the old directory string.| +

@@ -29,6 +35,7 @@ Sets the old directory string.

+

@@ -45,6 +52,7 @@ Add `dir` to the recent directories list.

+

@@ -62,6 +70,7 @@ This returns a table of recent directories, up to the `num` amount.

+

@@ -78,6 +87,7 @@ Remove the specified amount of dirs from the recent directories list.

+

diff --git a/docs/nature/doc.md b/docs/nature/doc.md index 15cc6d1..bbad7b2 100644 --- a/docs/nature/doc.md +++ b/docs/nature/doc.md @@ -15,6 +15,10 @@ This is only documented for the sake of it. It's only intended use is by the Greenhouse pager. ## Functions +|renderCodeBlock(text)|Assembles and renders a code block. This returns| +|highlight(text)|Performs basic Lua code highlighting.| +|renderInfoBlock(type, text)|Renders an info block. An info block is a block of text with| +

@@ -35,6 +39,7 @@ an icon and styled text block.

+

@@ -51,6 +56,7 @@ Performs basic Lua code highlighting.

+