From 5e1e39d5aa085bd284126c114cb144966e0517c5 Mon Sep 17 00:00:00 2001 From: sammy-ette Date: Sun, 15 Jun 2025 16:07:11 -0400 Subject: [PATCH] docs: document stuff --- docs/api/hilbish/_index.md | 4 ++- docs/api/hilbish/hilbish.processors.md | 39 ++++++++++++++++++++ docs/api/yarn.md | 50 ++++++++++++++++++++++++++ emmyLuaDocs/yarn.lua | 9 +++++ golibs/yarn/yarn.go | 22 ++++++++++-- 5 files changed, 120 insertions(+), 4 deletions(-) create mode 100644 docs/api/hilbish/hilbish.processors.md create mode 100644 docs/api/yarn.md create mode 100644 emmyLuaDocs/yarn.lua diff --git a/docs/api/hilbish/_index.md b/docs/api/hilbish/_index.md index 5aa7045b..a5d31270 100644 --- a/docs/api/hilbish/_index.md +++ b/docs/api/hilbish/_index.md @@ -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) + + return line:gsub('"%w+"', function(c) return lunacolors.green(c) end) + end ``` diff --git a/docs/api/hilbish/hilbish.processors.md b/docs/api/hilbish/hilbish.processors.md new file mode 100644 index 00000000..43dfecb4 --- /dev/null +++ b/docs/api/hilbish/hilbish.processors.md @@ -0,0 +1,39 @@ +--- +title: Module hilbish.processors +description: No description. +layout: doc +menu: + docs: + parent: "API" +--- + +
+
+

+hilbish.processors.add() + + + +

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

+hilbish.processors.execute() + + + +

+ +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. +
+ diff --git a/docs/api/yarn.md b/docs/api/yarn.md new file mode 100644 index 00000000..2d007812 --- /dev/null +++ b/docs/api/yarn.md @@ -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 +||| +|----|----| +|thread(fun) -> @Thread|Creates a new, fresh Yarn thread.| + +
+
+

+yarn.thread(fun) -> Thread + + + +

+ +Creates a new, fresh Yarn thread. +`fun` is the function that will run in the thread. + +#### Parameters +This function has no parameters. +
+ +## Types +
+ +## Thread + +### Methods diff --git a/emmyLuaDocs/yarn.lua b/emmyLuaDocs/yarn.lua new file mode 100644 index 00000000..3fa4f431 --- /dev/null +++ b/emmyLuaDocs/yarn.lua @@ -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 diff --git a/golibs/yarn/yarn.go b/golibs/yarn/yarn.go index 247566c9..0a3d5114 100644 --- a/golibs/yarn/yarn.go +++ b/golibs/yarn/yarn.go @@ -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 }