2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-07-01 08:42:04 +00:00

docs: document stuff

This commit is contained in:
sammyette 2025-06-15 16:07:11 -04:00
parent 002282f186
commit 5e1e39d5aa
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
5 changed files with 120 additions and 4 deletions

View File

@ -229,7 +229,9 @@ Note that to set a highlighter, one has to override this function.
```lua
--This code will highlight all double quoted strings in green.
function hilbish.highlighter(line)
return line:gsub('"%w+"', function(c) return lunacolors.green(c) end)
end
```
</div>

View File

@ -0,0 +1,39 @@
---
title: Module hilbish.processors
description: No description.
layout: doc
menu:
docs:
parent: "API"
---
<hr>
<div id='add'>
<h4 class='heading'>
hilbish.processors.add()
<a href="#add" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
#### Parameters
This function has no parameters.
</div>
<hr>
<div id='execute'>
<h4 class='heading'>
hilbish.processors.execute()
<a href="#execute" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
Run all command processors, in order by priority.
It returns the processed command (which may be the same as the passed command)
and a boolean which states whether to proceed with command execution.
#### Parameters
This function has no parameters.
</div>

50
docs/api/yarn.md Normal file
View File

@ -0,0 +1,50 @@
---
title: Module yarn
description: multi threading library
layout: doc
menu:
docs:
parent: "API"
---
## Introduction
Yarn is a simple multithreading library. Threads are individual Lua states,
so they do NOT share the same environment as the code that runs the thread.
Example:
```lua
local yarn = require 'yarn'
-- calling t will run the yarn thread.
local t = yarn.thread(print)
t 'printing from another lua state!'
```
## Functions
|||
|----|----|
|<a href="#yarnthread">thread(fun) -> @Thread</a>|Creates a new, fresh Yarn thread.|
<hr>
<div id='yarnthread'>
<h4 class='heading'>
yarn.thread(fun) -> <a href="/Hilbish/docs/api/yarn/#thread" style="text-decoration: none;" id="lol">Thread</a>
<a href="#yarnthread" class='heading-link'>
<i class="fas fa-paperclip"></i>
</a>
</h4>
Creates a new, fresh Yarn thread.
`fun` is the function that will run in the thread.
#### Parameters
This function has no parameters.
</div>
## Types
<hr>
## Thread
### Methods

9
emmyLuaDocs/yarn.lua Normal file
View File

@ -0,0 +1,9 @@
--- @meta
local yarn = {}
--- Creates a new, fresh Yarn thread.
--- `fun` is the function that will run in the thread.
function yarn.thread(fun) end
return yarn

View File

@ -1,3 +1,17 @@
// multi threading library
// Yarn is a simple multithreading library. Threads are individual Lua states,
// so they do NOT share the same environment as the code that runs the thread.
/*
Example:
```lua
local yarn = require 'yarn'
-- calling t will run the yarn thread.
local t = yarn.thread(print)
t 'printing from another lua state!'
```
*/
package yarn
import (
@ -17,6 +31,7 @@ type Yarn struct {
Loader packagelib.Loader
}
// #type
type Thread struct {
rtm *rt.Runtime
f rt.Callable
@ -43,7 +58,7 @@ func (y *Yarn) loaderFunc(rtm *rt.Runtime) (rt.Value, func()) {
exports := map[string]util.LuaExport{
"thread": {
Function: yarncreate,
Function: yarnthread,
ArgNum: 1,
Variadic: false,
},
@ -59,9 +74,10 @@ func (y *Yarn) init(th *Thread) {
y.initializer(th.rtm)
}
// create(fun)
// thread(fun) -> @Thread
// Creates a new, fresh Yarn thread.
func yarncreate(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
// `fun` is the function that will run in the thread.
func yarnthread(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) {
if err := c.Check1Arg(); err != nil {
return nil, err
}