Compare commits

..

No commits in common. "a7767d98532be6b8cf4e20351fc7ffa994ccffb8" and "90023ffa89c7f235dd6423fc18f221ae8eb5db87" have entirely different histories.

25 changed files with 31 additions and 257 deletions

View File

@ -2,26 +2,16 @@ name: Generate docs
on: on:
push: push:
branches: branches: [master]
- master
- docs-refactor
jobs: jobs:
gen: gen:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-go@v2 - uses: actions/setup-go@v2
- name: Download Task
run: 'sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d'
- name: Build
run: ./bin/task
- name: Run docgen - name: Run docgen
run: go run cmd/docgen/docgen.go run: go run cmd/docgen/docgen.go
- name: Run lua docgen
run: ./hilbish cmd/docgen/docgen.lua
- name: Commit new docs - name: Commit new docs
uses: stefanzweifel/git-auto-commit-action@v4 uses: stefanzweifel/git-auto-commit-action@v4
with: with:

1
.gitignore vendored
View File

@ -2,7 +2,6 @@
hilbish hilbish
!docs/api/hilbish !docs/api/hilbish
docgen docgen
!cmd/docgen
.vim .vim
petals/ petals/

View File

@ -13,12 +13,9 @@ import (
) )
var header = `--- var header = `---
title: %s %s name: %s %s
description: %s description: %s
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
` `

View File

@ -1,70 +0,0 @@
local fs = require 'fs'
local emmyPattern = '^%-%-%- (.+)'
local pieces = {}
local files = fs.readdir 'nature'
for _, fname in ipairs(files) do
local isScript = fname:match'%.lua$'
if not isScript then goto continue end
local f = io.open(string.format('nature/%s', fname))
local header = f:read '*l'
if not header:match(emmyPattern) then goto continue end
print(fname)
local iface = header:match(emmyPattern)
pieces[iface] = {}
local docPiece = {}
for line in f:lines() do
if line == header then goto continue2 end
if not line:match(emmyPattern) then
if line:match '^function' then
local pattern = (string.format('^function %s.', iface) .. '(%w+)')
local funcName = line:match(pattern)
pieces[iface][funcName] = docPiece
end
docPiece = {}
goto continue2
end
table.insert(docPiece, line)
::continue2::
end
::continue::
end
for iface, dps in pairs(pieces) do
local mod = iface:match '(%w+)%.'
local path = string.format('docs/api/%s/%s.md', mod, iface)
local f <close> = io.open(path, 'a+')
print(mod, path)
for func, docs in pairs(dps) do
local params = table.filter(docs, function(t)
return t:match '^%-%-%- @param'
end)
f:write(string.format('## %s(', func))
for i, str in ipairs(params) do
if i ~= 1 then
f:write ', '
end
f:write(str:match '^%-%-%- @param ([%w]+) ')
end
f:write(')\n')
for _, str in ipairs(docs) do
if not str:match '^%-%-%- @' then
f:write(str:match '^%-%-%- (.+)' .. '\n')
end
end
f:write('\n')
end
f:flush()
end

View File

@ -1,7 +0,0 @@
---
title: API
layout: doc
weight: -50
menu: docs
---

View File

@ -1,10 +1,7 @@
--- ---
title: Module bait name: Module bait
description: the event emitter description: the event emitter
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
## Introduction ## Introduction

View File

@ -1,10 +1,7 @@
--- ---
title: Module commander name: Module commander
description: library for custom commands description: library for custom commands
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
## Introduction ## Introduction

View File

@ -1,10 +1,7 @@
--- ---
title: Module fs name: Module fs
description: filesystem interaction and functionality library description: filesystem interaction and functionality library
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
## Introduction ## Introduction

View File

@ -1,10 +1,7 @@
--- ---
title: Module hilbish name: Module hilbish
description: the core Hilbish API description: the core Hilbish API
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
## Introduction ## Introduction

View File

@ -1,10 +1,7 @@
--- ---
title: Interface hilbish.aliases name: Interface hilbish.aliases
description: command aliasing description: command aliasing
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
## Introduction ## Introduction

View File

@ -1,10 +1,7 @@
--- ---
title: Interface hilbish.completions name: Interface hilbish.completions
description: tab completions description: tab completions
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
## Introduction ## Introduction

View File

@ -1,26 +0,0 @@
---
title: Interface hilbish.editor
description: interactions for Hilbish's line reader
layout: doc
menu:
docs:
parent: "API"
---
## Introduction
The hilbish.editor interface provides functions to
directly interact with the line editor in use.
## Functions
### getLine()
Returns the current input line.
### getVimRegister(register)
Returns the text that is at the register.
### insert(text)
Inserts text into the line.
### setVimRegister(register, text)
Sets the vim register at `register` to hold the passed text.

View File

@ -1,10 +1,7 @@
--- ---
title: Interface hilbish.history name: Interface hilbish.history
description: command history description: command history
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
## Introduction ## Introduction

View File

@ -1,15 +1,11 @@
--- ---
title: Interface hilbish.jobs name: Interface hilbish.jobs
description: background job management description: background job management
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
## Introduction ## Introduction
Manage interactive jobs in Hilbish via Lua.
Manage interactive jobs in Hilbish via Lua.
Jobs are the name of background tasks/commands. A job can be started via 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. interactive usage or with the functions defined below for use in external runners.

View File

@ -1,10 +1,7 @@
--- ---
title: Interface hilbish.os name: Interface hilbish.os
description: OS Info description: OS Info
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
## Introduction ## Introduction

View File

@ -1,10 +1,7 @@
--- ---
title: Interface hilbish.runner name: Interface hilbish.runner
description: interactive command runner customization description: interactive command runner customization
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
## Introduction ## Introduction

View File

@ -1,10 +1,7 @@
--- ---
title: Interface hilbish.timers name: Interface hilbish.timers
description: timeout and interval API description: timeout and interval API
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
## Introduction ## Introduction
@ -12,22 +9,7 @@ The timers interface si one to easily set timeouts and intervals
to run functions after a certain time or repeatedly without using to run functions after a certain time or repeatedly without using
odd tricks. odd tricks.
## Object properties
- `type`: What type of timer it is
- `running`: If the timer is running
- `duration`: The duration in milliseconds that the timer will run
## Functions ## Functions
### start()
Starts a timer.
### stop() ### stop()
Stops a timer. Stops a timer.
### create(type, time, callback)
Creates a timer that runs based on the specified `time` in milliseconds.
The `type` can either be interval (value of 0) or timeout (value of 1).
### get(id)
Retrieves a timer via its ID.

View File

@ -1,10 +1,7 @@
--- ---
title: Interface hilbish.userDir name: Interface hilbish.userDir
description: user-related directories description: user-related directories
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
## Introduction ## Introduction

View File

@ -1,10 +1,7 @@
--- ---
title: Module terminal name: Module terminal
description: low level terminal library description: low level terminal library
layout: doc layout: apidoc
menu:
docs:
parent: "API"
--- ---
## Introduction ## Introduction

View File

@ -6,10 +6,6 @@ import (
rt "github.com/arnodel/golua/runtime" rt "github.com/arnodel/golua/runtime"
) )
// #interface editor
// interactions for Hilbish's line reader
// The hilbish.editor interface provides functions to
// directly interact with the line editor in use.
func editorLoader(rtm *rt.Runtime) *rt.Table { func editorLoader(rtm *rt.Runtime) *rt.Table {
exports := map[string]util.LuaExport{ exports := map[string]util.LuaExport{
"insert": {editorInsert, 1, false}, "insert": {editorInsert, 1, false},
@ -24,9 +20,6 @@ func editorLoader(rtm *rt.Runtime) *rt.Table {
return mod return mod
} }
// #interface editor
// insert(text)
// Inserts text into the line.
func editorInsert(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func editorInsert(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
if err := c.Check1Arg(); err != nil { if err := c.Check1Arg(); err != nil {
return nil, err return nil, err
@ -42,9 +35,6 @@ func editorInsert(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
return c.Next(), nil return c.Next(), nil
} }
// #interface editor
// setVimRegister(register, text)
// Sets the vim register at `register` to hold the passed text.
func editorSetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func editorSetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
if err := c.Check1Arg(); err != nil { if err := c.Check1Arg(); err != nil {
return nil, err return nil, err
@ -65,9 +55,6 @@ func editorSetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
return c.Next(), nil return c.Next(), nil
} }
// #interface editor
// getVimRegister(register)
// Returns the text that is at the register.
func editorGetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func editorGetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
if err := c.Check1Arg(); err != nil { if err := c.Check1Arg(); err != nil {
return nil, err return nil, err
@ -83,9 +70,6 @@ func editorGetRegister(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
return c.PushingNext1(t.Runtime, rt.StringValue(string(buf))), nil return c.PushingNext1(t.Runtime, rt.StringValue(string(buf))), nil
} }
// #interface editor
// getLine()
// Returns the current input line.
func editorGetLine(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func editorGetLine(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
buf := lr.rl.GetLine() buf := lr.rl.GetLine()

View File

@ -22,18 +22,6 @@ function hilbish.completions.call(name, query, ctx, fields) end
--- You can check the completions doc for more info. --- You can check the completions doc for more info.
function hilbish.completions.handler(line, pos) end function hilbish.completions.handler(line, pos) end
--- Returns the current input line.
function hilbish.editor.getLine() end
--- Returns the text that is at the register.
function hilbish.editor.getVimRegister(register) end
--- Inserts text into the line.
function hilbish.editor.insert(text) end
--- Sets the vim register at `register` to hold the passed text.
function hilbish.editor.setVimRegister(register, text) end
--- Sets an alias of `cmd` to `orig` --- Sets an alias of `cmd` to `orig`
--- @param cmd string --- @param cmd string
--- @param orig string --- @param orig string
@ -167,9 +155,6 @@ function hilbish.jobs.stop() end
--- This is the equivalent of using `source`. --- This is the equivalent of using `source`.
function hilbish.runner.sh(cmd) end function hilbish.runner.sh(cmd) end
--- Starts a timer.
function hilbish.timers:start() end
--- Stops a timer. --- Stops a timer.
function hilbish.timers:stop() end function hilbish.timers:stop() end
@ -214,11 +199,4 @@ function hilbish.history.get(idx) end
--- @returns number --- @returns number
function hilbish.history.size() end function hilbish.history.size() end
--- Creates a timer that runs based on the specified `time` in milliseconds.
--- The `type` can either be interval (value of 0) or timeout (value of 1).
function hilbish.timers.create(type, time, callback) end
--- Retrieves a timer via its ID.
function hilbish.timers.get(id) end
return hilbish return hilbish

View File

@ -1,4 +1,3 @@
--- hilbish.runner
local currentRunner = 'hybrid' local currentRunner = 'hybrid'
local runners = {} local runners = {}

View File

@ -73,10 +73,6 @@ func (t *timer) stop() error {
return nil return nil
} }
// #interface timers
// #member
// start()
// Starts a timer.
func timerStart(thr *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func timerStart(thr *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
if err := c.Check1Arg(); err != nil { if err := c.Check1Arg(); err != nil {
return nil, err return nil, err

View File

@ -61,10 +61,6 @@ func (th *timersModule) get(id int) *timer {
return th.timers[id] return th.timers[id]
} }
// #interface timers
// create(type, time, callback)
// Creates a timer that runs based on the specified `time` in milliseconds.
// The `type` can either be interval (value of 0) or timeout (value of 1).
func (th *timersModule) luaCreate(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func (th *timersModule) luaCreate(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
if err := c.CheckNArgs(3); err != nil { if err := c.CheckNArgs(3); err != nil {
return nil, err return nil, err
@ -87,9 +83,6 @@ func (th *timersModule) luaCreate(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
return c.PushingNext1(t.Runtime, rt.UserDataValue(tmr.ud)), nil return c.PushingNext1(t.Runtime, rt.UserDataValue(tmr.ud)), nil
} }
// #interface timers
// get(id)
// Retrieves a timer via its ID.
func (th *timersModule) luaGet(thr *rt.Thread, c *rt.GoCont) (rt.Cont, error) { func (th *timersModule) luaGet(thr *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
if err := c.Check1Arg(); err != nil { if err := c.Check1Arg(); err != nil {
return nil, err return nil, err
@ -108,9 +101,6 @@ func (th *timersModule) luaGet(thr *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
} }
// #interface timers // #interface timers
// #property type What type of timer it is
// #property running If the timer is running
// #property duration The duration in milliseconds that the timer will run
// timeout and interval API // timeout and interval API
// The timers interface si one to easily set timeouts and intervals // The timers interface si one to easily set timeouts and intervals
// to run functions after a certain time or repeatedly without using // to run functions after a certain time or repeatedly without using

View File

@ -1 +0,0 @@
../../../docs/api/