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

fix: doc generation in nature when iface is hilbish

This commit is contained in:
sammyette 2025-04-02 21:54:45 -04:00
parent c121356e0f
commit 24de9e5baf
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
7 changed files with 152 additions and 165 deletions

View File

@ -203,7 +203,6 @@ func setupDocType(mod string, typ *doc.Type) *docPiece {
Tags: tags, Tags: tags,
} }
fmt.Println(typeName, parentMod, interfaces)
typeTable[strings.ToLower(typeName)] = []string{parentMod, interfaces} typeTable[strings.ToLower(typeName)] = []string{parentMod, interfaces}
return dps return dps
@ -477,12 +476,9 @@ provided by Hilbish.
f, _ := os.Create(docPath) f, _ := os.Create(docPath)
f.WriteString(fmt.Sprintf(header, modOrIface, modname, modu.ShortDescription)) f.WriteString(fmt.Sprintf(header, modOrIface, modname, modu.ShortDescription))
typeTag, _ := regexp.Compile(`\B@\w+`) typeTag, _ := regexp.Compile(`\B@\w+`)
//fmt.Println(modu.Description)
modDescription := typeTag.ReplaceAllStringFunc(strings.Replace(strings.Replace(modu.Description, "<", `\<`, -1), "{{\\<", "{{<", -1), func(typ string) string { modDescription := typeTag.ReplaceAllStringFunc(strings.Replace(strings.Replace(modu.Description, "<", `\<`, -1), "{{\\<", "{{<", -1), func(typ string) string {
typName := typ[1:] typName := typ[1:]
fmt.Println("typ name", typName)
typLookup := typeTable[strings.ToLower(typName)] typLookup := typeTable[strings.ToLower(typName)]
fmt.Println(typLookup)
ifaces := typLookup[0] + "." + typLookup[1] + "/" ifaces := typLookup[0] + "." + typLookup[1] + "/"
if typLookup[1] == "" { if typLookup[1] == "" {
ifaces = "" ifaces = ""

View File

@ -15,7 +15,6 @@ for _, fname in ipairs(files) do
local mod = header:match(modpattern) local mod = header:match(modpattern)
if not mod then goto continue end if not mod then goto continue end
print(fname, mod)
pieces[mod] = {} pieces[mod] = {}
descriptions[mod] = {} descriptions[mod] = {}
@ -59,14 +58,12 @@ for _, fname in ipairs(files) do
if emmy then if emmy then
if emmy == 'param' then if emmy == 'param' then
print('bruh', emmythings[1], emmythings[2])
table.insert(dps.params, 1, { table.insert(dps.params, 1, {
name = emmythings[1], name = emmythings[1],
type = emmythings[2], type = emmythings[2],
-- the +1 accounts for space. -- the +1 accounts for space.
description = table.concat(emmythings, ' '):sub(emmythings[1]:len() + 1 + emmythings[2]:len() + 1) description = table.concat(emmythings, ' '):sub(emmythings[1]:len() + 1 + emmythings[2]:len() + 1)
}) })
print(table.concat(emmythings, '/'))
end end
else else
table.insert(dps.description, 1, docline) table.insert(dps.description, 1, docline)
@ -109,11 +106,15 @@ for iface, dps in pairs(pieces) do
docParent = "API" docParent = "API"
path = string.format('docs/api/%s/%s.md', mod, iface) path = string.format('docs/api/%s/%s.md', mod, iface)
end end
if iface == 'hilbish' then
docParent = "API"
path = string.format('docs/api/hilbish/_index.md', mod, iface)
end
fs.mkdir(fs.dir(path), true) fs.mkdir(fs.dir(path), true)
local exists = pcall(fs.stat, path) local exists = pcall(fs.stat, path)
local newOrNotNature = exists and mod ~= 'nature' local newOrNotNature = (exists and mod ~= 'nature') or iface == 'hilbish'
local f <close> = io.open(path, newOrNotNature and 'r+' or 'w+') local f <close> = io.open(path, newOrNotNature and 'r+' or 'w+')
local tocPos local tocPos
@ -129,9 +130,6 @@ for iface, dps in pairs(pieces) do
tocPos = f:seek() tocPos = f:seek()
end end
end end
print(f)
print('mod and path:', mod, path)
local tocSearch = false local tocSearch = false
for line in f:lines() do for line in f:lines() do

View File

@ -30,6 +30,7 @@ interfaces and functions which directly relate to shell functionality.
|<a href="#read">read(prompt) -> input (string)</a>|Read input from the user, using Hilbish's line editor/input reader.| |<a href="#read">read(prompt) -> input (string)</a>|Read input from the user, using Hilbish's line editor/input reader.|
|<a href="#timeout">timeout(cb, time) -> @Timer</a>|Executed the `cb` function after a period of `time`.| |<a href="#timeout">timeout(cb, time) -> @Timer</a>|Executed the `cb` function after a period of `time`.|
|<a href="#which">which(name) -> string</a>|Checks if `name` is a valid command.| |<a href="#which">which(name) -> string</a>|Checks if `name` is a valid command.|
|<a href="#runnerMode">runnerMode(mode)</a>|Sets the execution/runner mode for interactive Hilbish.|
## Static module fields ## Static module fields
||| |||
@ -447,3 +448,27 @@ Will return the path of the binary, or a basename if it's a commander.
</div> </div>
<hr>
<div id='runnerMode'>
<h4 class='heading'>
hilbish.runnerMode(mode)
<a href="#runnerMode" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
Sets the execution/runner mode for interactive Hilbish.
**NOTE: This function is deprecated and will be removed in 3.0**
Use `hilbish.runner.setCurrent` instead.
This determines whether Hilbish wll try to run input as Lua
and/or sh or only do one of either.
Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua),
sh, and lua. It also accepts a function, to which if it is passed one
will call it to execute user input instead.
Read [about runner mode](../features/runner-mode) for more information.
#### Parameters
`mode` **`string|function`**
</div>

View File

@ -56,13 +56,14 @@ end)
|----|----| |----|----|
|<a href="#runner.lua">lua(cmd)</a>|Evaluates `cmd` as Lua input. This is the same as using `dofile`| |<a href="#runner.lua">lua(cmd)</a>|Evaluates `cmd` as Lua input. This is the same as using `dofile`|
|<a href="#exec">exec(cmd, runnerName)</a>|Executes `cmd` with a runner.| |<a href="#exec">exec(cmd, runnerName)</a>|Executes `cmd` with a runner.|
|<a href="#run">run(input, priv)</a>|Runs `input` with the currently set Hilbish runner.|
|<a href="#getCurrent">getCurrent()</a>|Returns the current runner by name.|
|<a href="#setCurrent">setCurrent(name)</a>|Sets Hilbish's runner mode by name.|
|<a href="#setMode">setMode(mode)</a>|**NOTE: This function is deprecated and will be removed in 3.0**|
|<a href="#sh">sh()</a>|nil|
|<a href="#add">add(name, runner)</a>|Adds a runner to the table of available runners.|
|<a href="#set">set(name, runner)</a>|*Sets* a runner by name. The difference between this function and| |<a href="#set">set(name, runner)</a>|*Sets* a runner by name. The difference between this function and|
|<a href="#get">get(name)</a>|Get a runner by name.| |<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.|
|<a href="#setCurrent">setCurrent(name)</a>|Sets Hilbish's runner mode by name.|
|<a href="#getCurrent">getCurrent()</a>|Returns the current runner by name.|
|<a href="#run">run(input, priv)</a>|Runs `input` with the currently set Hilbish runner.|
|<a href="#sh">sh()</a>|nil|
<hr> <hr>
<div id='runner.lua'> <div id='runner.lua'>
@ -80,91 +81,6 @@ or `load`, but is appropriated for the runner interface.
`string` **`cmd`** `string` **`cmd`**
</div>
<hr>
<div id='sh'>
<h4 class='heading'>
hilbish.runner.sh()
<a href="#sh" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
#### Parameters
This function has no parameters.
</div>
<hr>
<div id='run'>
<h4 class='heading'>
hilbish.runner.run(input, priv)
<a href="#run" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
Runs `input` with the currently set Hilbish runner.
This method is how Hilbish executes commands.
`priv` is an optional boolean used to state if the input should be saved to history.
#### Parameters
`input` **`string`**
`priv` **`bool`**
</div>
<hr>
<div id='getCurrent'>
<h4 class='heading'>
hilbish.runner.getCurrent()
<a href="#getCurrent" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
Returns the current runner by name.
#### Parameters
This function has no parameters.
</div>
<hr>
<div id='setCurrent'>
<h4 class='heading'>
hilbish.runner.setCurrent(name)
<a href="#setCurrent" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
Sets Hilbish's runner mode by name.
#### Parameters
`name` **`string`**
</div>
<hr>
<div id='add'>
<h4 class='heading'>
hilbish.runner.add(name, runner)
<a href="#add" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
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`**
Name of the runner
`runner` **`function|table`**
</div> </div>
<hr> <hr>
@ -202,6 +118,111 @@ The runner table must have the run function in it.
`runner` **`table`** `runner` **`table`**
</div>
<hr>
<div id='add'>
<h4 class='heading'>
hilbish.runner.add(name, runner)
<a href="#add" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
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`**
Name of the runner
`runner` **`function|table`**
</div>
<hr>
<div id='sh'>
<h4 class='heading'>
hilbish.runner.sh()
<a href="#sh" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
#### Parameters
This function has no parameters.
</div>
<hr>
<div id='setMode'>
<h4 class='heading'>
hilbish.runner.setMode(mode)
<a href="#setMode" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
**NOTE: This function is deprecated and will be removed in 3.0**
Use `hilbish.runner.setCurrent` instead.
This is the same as the `hilbish.runnerMode` function.
It takes a callback, which will be used to execute all interactive input.
Or a string which names the runner mode to use.
#### Parameters
`mode` **`string|function`**
</div>
<hr>
<div id='setCurrent'>
<h4 class='heading'>
hilbish.runner.setCurrent(name)
<a href="#setCurrent" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
Sets Hilbish's runner mode by name.
#### Parameters
`name` **`string`**
</div>
<hr>
<div id='getCurrent'>
<h4 class='heading'>
hilbish.runner.getCurrent()
<a href="#getCurrent" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
Returns the current runner by name.
#### Parameters
This function has no parameters.
</div>
<hr>
<div id='run'>
<h4 class='heading'>
hilbish.runner.run(input, priv)
<a href="#run" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
Runs `input` with the currently set Hilbish runner.
This method is how Hilbish executes commands.
`priv` is an optional boolean used to state if the input should be saved to history.
#### Parameters
`input` **`string`**
`priv` **`bool`**
</div> </div>
<hr> <hr>

View File

@ -1,53 +0,0 @@
---
title: Module hilbish
description: No description.
layout: doc
menu:
docs:
parent: "Nature"
---
<hr>
<div id='runner'>
<h4 class='heading'>
hilbish.runner(mode)
<a href="#runner" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
**NOTE: This function is deprecated and will be removed in 3.0**
Use `hilbish.runner.setCurrent` instead.
This is the same as the `hilbish.runnerMode` function.
It takes a callback, which will be used to execute all interactive input.
Or a string which names the runner mode to use.
#### Parameters
`mode` **`string|function`**
</div>
<hr>
<div id='runnerMode'>
<h4 class='heading'>
hilbish.runnerMode(mode)
<a href="#runnerMode" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
**NOTE: This function is deprecated and will be removed in 3.0**
Use `hilbish.runner.setCurrent` instead.
Sets the execution/runner mode for interactive Hilbish.
This determines whether Hilbish wll try to run input as Lua
and/or sh or only do one of either.
Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua),
sh, and lua. It also accepts a function, to which if it is passed one
will call it to execute user input instead.
Read [about runner mode](../features/runner-mode) for more information.
#### Parameters
`mode` **`string|function`**
</div>

View File

@ -82,6 +82,16 @@ function hilbish.runner.getCurrent()
return currentRunner return currentRunner
end end
--- **NOTE: This function is deprecated and will be removed in 3.0**
--- Use `hilbish.runner.setCurrent` instead.
--- This is the same as the `hilbish.runnerMode` function.
--- It takes a callback, which will be used to execute all interactive input.
--- Or a string which names the runner mode to use.
-- @param mode string|function
function hilbish.runner.setMode(mode)
hilbish.runnerMode(mode)
end
local function finishExec(exitCode, input, priv) local function finishExec(exitCode, input, priv)
hilbish.exitCode = exitCode hilbish.exitCode = exitCode
bait.throw('command.exit', exitCode, input, priv) bait.throw('command.exit', exitCode, input, priv)

View File

@ -1,8 +1,8 @@
-- @module hilbish -- @module hilbish
--- Sets the execution/runner mode for interactive Hilbish.
--- **NOTE: This function is deprecated and will be removed in 3.0** --- **NOTE: This function is deprecated and will be removed in 3.0**
--- Use `hilbish.runner.setCurrent` instead. --- Use `hilbish.runner.setCurrent` instead.
--- Sets the execution/runner mode for interactive Hilbish.
--- This determines whether Hilbish wll try to run input as Lua --- This determines whether Hilbish wll try to run input as Lua
--- and/or sh or only do one of either. --- and/or sh or only do one of either.
--- Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua), --- Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua),
@ -22,13 +22,3 @@ function hilbish.runnerMode(mode)
error('expected runner mode type to be either string or function, got', type(mode)) error('expected runner mode type to be either string or function, got', type(mode))
end end
end end
--- **NOTE: This function is deprecated and will be removed in 3.0**
--- Use `hilbish.runner.setCurrent` instead.
--- This is the same as the `hilbish.runnerMode` function.
--- It takes a callback, which will be used to execute all interactive input.
--- Or a string which names the runner mode to use.
-- @param mode string|function
function hilbish.runner.setMode(mode)
hilbish.runnerMode(mode)
end