diff --git a/cmd/docgen/docgen.lua b/cmd/docgen/docgen.lua index 207357a..5c7d155 100644 --- a/cmd/docgen/docgen.lua +++ b/cmd/docgen/docgen.lua @@ -1,6 +1,6 @@ local fs = require 'fs' local emmyPattern = '^%-%-%- (.+)' -local modpattern = '^%-+ @module (%w+)' +local modpattern = '^%-+ @module (.+)' local pieces = {} local files = fs.readdir 'nature' @@ -81,30 +81,70 @@ description: %s layout: doc menu: docs: - parent: "Nature" + parent: "%s" --- ]] for iface, dps in pairs(pieces) do local mod = iface:match '(%w+)%.' or 'nature' - local path = string.format('docs/%s/%s.md', mod, iface) + local docParent = 'Nature' + + path = string.format('docs/%s/%s.md', mod, iface) + if mod ~= 'nature' then + docParent = "API" + path = string.format('docs/api/%s/%s.md', mod, iface) + end + fs.mkdir(fs.dir(path), true) - local f = io.open(path, 'w') - f:write(string.format(header, 'Module', iface, 'No description.')) + + local exists = pcall(fs.stat, path) + local newOrNotNature = exists and mod ~= 'nature' + + local f = io.open(path, newOrNotNature and 'r+' or 'w+') + if not newOrNotNature then + f:write(string.format(header, 'Module', iface, 'No description.', docParent)) + end print(f) - print(mod, path) + print('mod and path:', mod, path) + + local tocSearch = false + local tocPos + for line in f:lines() do + if line:match '^## Functions' then + tocSearch = true + end + if tocSearch and line == '' then + tocSearch = false + tocPos = f:seek() - 1 + end + end for func, docs in pairs(dps) do - f:write(string.format('
\n
', func)) local sig = string.format('%s.%s(', iface, func) + local params = '' for idx, param in ipairs(docs.params) do - sig = sig .. ((param.name:gsub('%?$', ''))) - if idx ~= #docs.params then sig = sig .. ', ' end + sig = sig .. param.name:gsub('%?$', '') + params = params .. param.name:gsub('%?$', '') + if idx ~= #docs.params then + sig = sig .. ', ' + params = params .. ', ' + end end sig = sig .. ')' - f:write(string.format([[ + + if tocPos then + f:seek('set', tocPos) + local contents = f:read '*a' + f:seek('set', tocPos) + local tocLine = string.format('|%s|%s|\n', func, string.format('%s(%s)', func, params), docs.description[1]) + f:write(tocLine .. contents) + f:seek 'end' + end + + f:write(string.format('
\n
\n', func)) + f:write(string.format([[

%s diff --git a/docs/api/hilbish/hilbish.messages.md b/docs/api/hilbish/hilbish.messages.md new file mode 100644 index 0000000..1e37205 --- /dev/null +++ b/docs/api/hilbish/hilbish.messages.md @@ -0,0 +1,107 @@ +--- +title: Module hilbish.messages +description: No description. +layout: doc +menu: + docs: + parent: "API" +--- + +
+
+

+hilbish.messages.all() + + + +

+ + +#### Parameters +This function has no parameters. +
+ +
+
+

+hilbish.messages.clear() + + + +

+ + +#### Parameters +This function has no parameters. +
+ +
+
+

+hilbish.messages.delete() + + + +

+ + +#### Parameters +This function has no parameters. +
+ +
+
+

+hilbish.messages.read() + + + +

+ + +#### Parameters +This function has no parameters. +
+ +
+
+

+hilbish.messages.send(message) + + + +

+ +Sends a message. +#### Parameters +`message` **`hilbish.message`** +
+ +
+
+

+hilbish.messages.readAll() + + + +

+ + +#### Parameters +This function has no parameters. +
+ +
+
+

+hilbish.messages.unreadCount() + + + +

+ + +#### Parameters +This function has no parameters. +
+ diff --git a/docs/api/hilbish/hilbish.runner.md b/docs/api/hilbish/hilbish.runner.md index 8c89a52..a88985f 100644 --- a/docs/api/hilbish/hilbish.runner.md +++ b/docs/api/hilbish/hilbish.runner.md @@ -57,6 +57,12 @@ end) |setMode(cb)|This is the same as the `hilbish.runnerMode` function.| |lua(cmd)|Evaluates `cmd` as Lua input. This is the same as using `dofile`| |sh(cmd)|Runs a command in Hilbish's shell script interpreter.| +|exec(cmd, runnerName)|Executes cmd with a runner. If runnerName isn't passed, it uses| +|set(name, runner)|Sets a runner by name. The runner table must have the run function in it.| +|get(name)|Get a runner by name.| +|add(name, runner)|Adds a runner to the table of available runners. If runner is a table,| +|setCurrent(name)|Sets the current interactive/command line runner mode.| +|getCurrent()|Returns the current runner by name.|
@@ -114,3 +120,92 @@ This is the equivalent of using `source`.
+
+
+

+hilbish.runner.getCurrent() + + + +

+ +Returns the current runner by name. +#### Parameters +This function has no parameters. +
+ +
+
+

+hilbish.runner.setCurrent(name) + + + +

+ +Sets the current interactive/command line runner mode. +#### Parameters +`name` **`string`** +
+ +
+
+

+hilbish.runner.add(name, runner) + + + +

+ +Adds a runner to the table of available runners. If runner is a table, +it must have the run function in it. +#### Parameters +`name` **`string`** +`runner` **`function`** +
+ +
+
+

+hilbish.runner.get(name) + + + +

+ +Get a runner by name. +#### Parameters +`name` **`string`** +
+ +
+
+

+hilbish.runner.set(name, runner) + + + +

+ +Sets a runner by name. The runner table must have the run function in it. +#### Parameters +`name` **`string`** +`runner` **`table`** +
+ +
+
+

+hilbish.runner.exec(cmd, runnerName) + + + +

+ +Executes cmd with a runner. If runnerName isn't passed, it uses +the user's current runner. +#### Parameters +`cmd` **`string`** +`runnerName` **`string?`** +
+ diff --git a/docs/nature/dirs.md b/docs/nature/dirs.md index 3c707e6..2a0e966 100644 --- a/docs/nature/dirs.md +++ b/docs/nature/dirs.md @@ -8,7 +8,7 @@ menu: ---
-