mirror of
https://github.com/Hilbis/Hilbish
synced 2025-04-20 20:43:23 +00:00
fix: add description for lua doc'd modules, remove duplicate docs
This commit is contained in:
parent
d592e1d862
commit
04daebb3a6
@ -299,7 +299,25 @@ start:
|
||||
func main() {
|
||||
fset := token.NewFileSet()
|
||||
os.Mkdir("docs", 0777)
|
||||
os.RemoveAll("docs/api")
|
||||
os.Mkdir("docs/api", 0777)
|
||||
|
||||
f, err := os.Create("docs/api/_index.md")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
f.WriteString(`---
|
||||
title: API
|
||||
layout: doc
|
||||
weight: -100
|
||||
menu: docs
|
||||
---
|
||||
|
||||
Welcome to the API documentation for Hilbish. This documents Lua functions
|
||||
provided by Hilbish.
|
||||
`)
|
||||
f.Close()
|
||||
|
||||
os.Mkdir("emmyLuaDocs", 0777)
|
||||
|
||||
dirs := []string{"./"}
|
||||
|
@ -1,7 +1,9 @@
|
||||
local fs = require 'fs'
|
||||
local emmyPattern = '^%-%-%- (.+)'
|
||||
local emmyPattern2 = '^%-%- (.+)'
|
||||
local modpattern = '^%-+ @module (.+)'
|
||||
local pieces = {}
|
||||
local descriptions = {}
|
||||
|
||||
local files = fs.readdir 'nature'
|
||||
for _, fname in ipairs(files) do
|
||||
@ -15,16 +17,24 @@ for _, fname in ipairs(files) do
|
||||
|
||||
print(fname, mod)
|
||||
pieces[mod] = {}
|
||||
descriptions[mod] = {}
|
||||
|
||||
local docPiece = {}
|
||||
local lines = {}
|
||||
local lineno = 0
|
||||
local doingDescription = true
|
||||
|
||||
for line in f:lines() do
|
||||
lineno = lineno + 1
|
||||
lines[lineno] = line
|
||||
|
||||
if line == header then goto continue2 end
|
||||
if not line:match(emmyPattern) then
|
||||
if line:match(emmyPattern) or line:match(emmyPattern2) then
|
||||
if doingDescription then
|
||||
table.insert(descriptions[mod], line:match(emmyPattern) or line:match(emmyPattern2))
|
||||
end
|
||||
else
|
||||
doingDescription = false
|
||||
if line:match '^function' then
|
||||
local pattern = (string.format('^function %s%%.', mod) .. '(%w+)')
|
||||
local funcName = line:match(pattern)
|
||||
@ -107,7 +117,12 @@ for iface, dps in pairs(pieces) do
|
||||
|
||||
local f <close> = io.open(path, newOrNotNature and 'r+' or 'w+')
|
||||
if not newOrNotNature then
|
||||
f:write(string.format(header, 'Module', iface, '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
|
||||
table.remove(descriptions[iface], 1)
|
||||
f:write(string.format('\n## Introduction\n%s\n\n', table.concat(descriptions[iface], '\n')))
|
||||
f:write('## Functions\n')
|
||||
end
|
||||
end
|
||||
print(f)
|
||||
|
||||
|
@ -1,146 +0,0 @@
|
||||
---
|
||||
title: Module hilbish.jobs
|
||||
description: background job management
|
||||
layout: doc
|
||||
menu:
|
||||
docs:
|
||||
parent: "API"
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
Manage interactive jobs in Hilbish via Lua.
|
||||
|
||||
Jobs are the name of background tasks/commands. A job can be started via
|
||||
interactive usage or with the functions defined below for use in external runners.
|
||||
|
||||
## Functions
|
||||
|||
|
||||
|----|----|
|
||||
|<a href="#jobs.add">add(cmdstr, args, execPath)</a>|Creates a new job. This function does not run the job. This function is intended to be|
|
||||
|<a href="#jobs.all">all() -> table[@Job]</a>|Returns a table of all job objects.|
|
||||
|<a href="#jobs.disown">disown(id)</a>|Disowns a job. This simply deletes it from the list of jobs without stopping it.|
|
||||
|<a href="#jobs.get">get(id) -> @Job</a>|Get a job object via its ID.|
|
||||
|<a href="#jobs.last">last() -> @Job</a>|Returns the last added job to the table.|
|
||||
|
||||
<hr>
|
||||
<div id='jobs.add'>
|
||||
<h4 class='heading'>
|
||||
hilbish.jobs.add(cmdstr, args, execPath)
|
||||
<a href="#jobs.add" class='heading-link'>
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
|
||||
Creates a new job. This function does not run the job. This function is intended to be
|
||||
used by runners, but can also be used to create jobs via Lua. Commanders cannot be ran as jobs.
|
||||
|
||||
#### Parameters
|
||||
`string` **`cmdstr`**
|
||||
String that a user would write for the job
|
||||
|
||||
`table` **`args`**
|
||||
Arguments for the commands. Has to include the name of the command.
|
||||
|
||||
`string` **`execPath`**
|
||||
Binary to use to run the command. Needs to be an absolute path.
|
||||
|
||||
#### Example
|
||||
```lua
|
||||
hilbish.jobs.add('go build', {'go', 'build'}, '/usr/bin/go')
|
||||
```
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div id='jobs.all'>
|
||||
<h4 class='heading'>
|
||||
hilbish.jobs.all() -> table[<a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>]
|
||||
<a href="#jobs.all" class='heading-link'>
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
|
||||
Returns a table of all job objects.
|
||||
|
||||
#### Parameters
|
||||
This function has no parameters.
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div id='jobs.disown'>
|
||||
<h4 class='heading'>
|
||||
hilbish.jobs.disown(id)
|
||||
<a href="#jobs.disown" class='heading-link'>
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
|
||||
Disowns a job. This simply deletes it from the list of jobs without stopping it.
|
||||
|
||||
#### Parameters
|
||||
`number` **`id`**
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div id='jobs.get'>
|
||||
<h4 class='heading'>
|
||||
hilbish.jobs.get(id) -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>
|
||||
<a href="#jobs.get" class='heading-link'>
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
|
||||
Get a job object via its ID.
|
||||
|
||||
#### Parameters
|
||||
This function has no parameters.
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<div id='jobs.last'>
|
||||
<h4 class='heading'>
|
||||
hilbish.jobs.last() -> <a href="/Hilbish/docs/api/hilbish/hilbish.jobs/#job" style="text-decoration: none;" id="lol">Job</a>
|
||||
<a href="#jobs.last" class='heading-link'>
|
||||
<i class="fas fa-paperclip"></i>
|
||||
</a>
|
||||
</h4>
|
||||
|
||||
Returns the last added job to the table.
|
||||
|
||||
#### Parameters
|
||||
This function has no parameters.
|
||||
</div>
|
||||
|
||||
## Types
|
||||
<hr>
|
||||
|
||||
## Job
|
||||
The Job type describes a Hilbish job.
|
||||
## Object properties
|
||||
|||
|
||||
|----|----|
|
||||
|cmd|The user entered command string for the job.|
|
||||
|running|Whether the job is running or not.|
|
||||
|id|The ID of the job in the job table|
|
||||
|pid|The Process ID|
|
||||
|exitCode|The last exit code of the job.|
|
||||
|stdout|The standard output of the job. This just means the normal logs of the process.|
|
||||
|stderr|The standard error stream of the process. This (usually) includes error messages of the job.|
|
||||
|
||||
|
||||
### Methods
|
||||
#### background()
|
||||
Puts a job in the background. This acts the same as initially running a job.
|
||||
|
||||
#### foreground()
|
||||
Puts a job in the foreground. This will cause it to run like it was
|
||||
executed normally and wait for it to complete.
|
||||
|
||||
#### start()
|
||||
Starts running the job.
|
||||
|
||||
#### stop()
|
||||
Stops the job from running.
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,12 +1,18 @@
|
||||
---
|
||||
title: Module dirs
|
||||
description: No description.
|
||||
description: internal directory management
|
||||
layout: doc
|
||||
menu:
|
||||
docs:
|
||||
parent: "Nature"
|
||||
---
|
||||
|
||||
|
||||
## Introduction
|
||||
The dirs module defines a small set of functions to store and manage
|
||||
directories.
|
||||
|
||||
## Functions
|
||||
<hr>
|
||||
<div id='setOld'>
|
||||
<h4 class='heading'>
|
||||
|
@ -1,12 +1,20 @@
|
||||
---
|
||||
title: Module doc
|
||||
description: No description.
|
||||
description: command-line doc rendering
|
||||
layout: doc
|
||||
menu:
|
||||
docs:
|
||||
parent: "Nature"
|
||||
---
|
||||
|
||||
|
||||
## Introduction
|
||||
The doc module contains a small set of functions
|
||||
used by the Greenhouse pager to render parts of the documentation pages.
|
||||
This is only documented for the sake of it. It's only intended use
|
||||
is by the Greenhouse pager.
|
||||
|
||||
## Functions
|
||||
<hr>
|
||||
<div id='renderInfoBlock'>
|
||||
<h4 class='heading'>
|
||||
|
Loading…
x
Reference in New Issue
Block a user