From 4b28efe6399dfe592364e4c24e94b4cb0eeab5ca Mon Sep 17 00:00:00 2001 From: sammy-ette Date: Sun, 22 Jun 2025 18:51:57 -0400 Subject: [PATCH] fix: doc descriptions, add short description, make things scroll nicer --- cmd/docgen/docgen.go | 5 +- defs/bait.json | 2 +- defs/commander.json | 2 +- defs/hilbish.json | 386 +++++++++++++++++++++++----------- docs/api/bait.md | 15 +- docs/api/commander.md | 23 +- docs/api/fs.md | 10 + docs/api/hilbish.md | 68 +++++- docs/api/readline.md | 1 + docs/api/snail.md | 1 + docs/api/terminal.md | 4 + docs/api/yarn.md | 1 + golibs/bait/bait.go | 67 +++--- golibs/commander/commander.go | 34 ++- website/content/install.md | 24 +-- website/src/pages/doc.gleam | 31 +-- website/src/post.gleam | 1 + website/src/util.gleam | 72 +++++++ website/src/website.gleam | 107 +++------- 19 files changed, 555 insertions(+), 299 deletions(-) diff --git a/cmd/docgen/docgen.go b/cmd/docgen/docgen.go index c148ce9e..3af014d3 100644 --- a/cmd/docgen/docgen.go +++ b/cmd/docgen/docgen.go @@ -403,7 +403,7 @@ func main() { shortDesc := piece.Doc[0] desc := piece.Doc[1:] interfaceModules[modname].ShortDescription = shortDesc - interfaceModules[modname].Description = strings.Join(desc, "\n") + interfaceModules[modname].Description = strings.Replace(strings.Join(desc, "\n"), "", "\\\n \\", -1) interfaceModules[modname].Fields = piece.Fields interfaceModules[modname].Properties = piece.Properties continue @@ -441,7 +441,7 @@ func main() { Types: filteredTypePieces, Docs: filteredPieces, ShortDescription: shortDesc, - Description: strings.Join(desc, "\n"), + Description: strings.Replace(strings.Join(desc, "\n"), "", "\\\n \\", -1), HasInterfaces: hasInterfaces, Properties: docPieceTag("property", tags), Fields: docPieceTag("field", tags), @@ -627,6 +627,7 @@ func generateFile(v module) { + `, htmlSig, dps.FuncName)) f.WriteString("```\n\n") diff --git a/defs/bait.json b/defs/bait.json index 212d6e48..4114e680 100644 --- a/defs/bait.json +++ b/defs/bait.json @@ -1,7 +1,7 @@ { "name": "bait", "shortDescription": "the event emitter", - "description": "\nBait is the event emitter for Hilbish. Much like Node.js and\nits `events` system, many actions in Hilbish emit events.\nUnlike Node.js, Hilbish events are global. So make sure to\npick a unique name!\n\nUsage of the Bait module consists of userstanding\nevent-driven architecture, but it's pretty simple:\nIf you want to act on a certain event, you can `catch` it.\nYou can act on events via callback functions.\n\nExamples of this are in the Hilbish default config!\nConsider this part of it:\n```lua\nbait.catch('command.exit', function(code)\n\trunning = false\n\tdoPrompt(code ~= 0)\n\tdoNotifyPrompt()\nend)\n```\n\nWhat this does is, whenever the `command.exit` event is thrown,\nthis function will set the user prompt.", + "description": "\nBait is the event emitter for Hilbish. Much like Node.js and\nits `events` system, many actions in Hilbish emit events.\nUnlike Node.js, Hilbish events are global. So make sure to\npick a unique name!\\\n \\\n\nUsage of the Bait module consists of userstanding\nevent-driven architecture, but it's pretty simple:\nIf you want to act on a certain event, you can `catch` it.\nYou can act on events via callback functions.\\\n \\\n\nExamples of this are in the Hilbish default config!\nConsider this part of it:\\\n \\\n\n```lua\nbait.catch('command.exit', function(code)\n\trunning = false\n\tdoPrompt(code ~= 0)\n\tdoNotifyPrompt()\nend)\n```\n\nWhat this does is, whenever the `command.exit` event is thrown,\nthis function will set the user prompt.", "properties": [], "fields": [], "docs": [ diff --git a/defs/commander.json b/defs/commander.json index 8a5caed9..6d94813c 100644 --- a/defs/commander.json +++ b/defs/commander.json @@ -1,7 +1,7 @@ { "name": "commander", "shortDescription": "library for custom commands", - "description": "\nCommander is the library which handles Hilbish commands. This makes\nthe user able to add Lua-written commands to their shell without making\na separate script in a bin folder. Instead, you may simply use the Commander\nlibrary in your Hilbish config.\n\n```lua\nlocal commander = require 'commander'\n\ncommander.register('hello', function(args, sinks)\n\tsinks.out:writeln 'Hello world!'\nend)\n```\n\nIn this example, a command with the name of `hello` is created\nthat will print `Hello world!` to output. One question you may\nhave is: What is the `sinks` parameter?\n\nThe `sinks` parameter is a table with 3 keys: `input`, `out`, and `err`.\nThere is an `in` alias to `input`, but it requires using the string accessor syntax (`sinks['in']`)\nas `in` is also a Lua keyword, so `input` is preferred for use.\nAll of them are a @Sink.\nIn the future, `sinks.in` will be removed.\n\n- `in` is the standard input.\nYou may use the read functions on this sink to get input from the user.\n- `out` is standard output.\nThis is usually where command output should go.\n- `err` is standard error.\nThis sink is for writing errors, as the name would suggest.", + "description": "\nCommander is the library which handles Hilbish commands. This makes\nthe user able to add Lua-written commands to their shell without making\na separate script in a bin folder. Instead, you may simply use the Commander\nlibrary in your Hilbish config.\\\n \\\n```lua\nlocal commander = require 'commander'\n\ncommander.register('hello', function(args, sinks)\n\tsinks.out:writeln 'Hello world!'\nend)\n```\n\nIn this example, a command with the name of `hello` is created\nthat will print `Hello world!` to output. One question you may\nhave is: What is the `sinks` parameter?\\\n \\\nThe `sinks` parameter is a table with 3 keys: `input`, `out`, and `err`.\nThere is an `in` alias to `input`, but it requires using the string accessor syntax (`sinks['in']`)\nas `in` is also a Lua keyword, so `input` is preferred for use.\nAll of them are a @Sink.\nIn the future, `sinks.in` will be removed.\\\n \\\n\n- `in` is the standard input. You may use the read functions on this sink to get input from the user.\n- `out` is standard output. This is usually where command output should go.\n- `err` is standard error. This sink is for writing errors, as the name would suggest.", "properties": [], "fields": [], "docs": [ diff --git a/defs/hilbish.json b/defs/hilbish.json index f765506c..c22a4228 100644 --- a/defs/hilbish.json +++ b/defs/hilbish.json @@ -1,9 +1,147 @@ { "name": "hilbish", - "shortDescription": "", - "description": "", + "shortDescription": "the core Hilbish API", + "description": "The Hilbish module includes the core API, containing\ninterfaces and functions which directly relate to shell functionality.", "properties": [], - "fields": [], + "fields": [ + { + "name": "ver", + "description": [ + "The", + "version", + "of", + "Hilbish" + ], + "isInterface": false, + "isMember": false, + "isType": false + }, + { + "name": "goVersion", + "description": [ + "The", + "version", + "of", + "Go", + "that", + "Hilbish", + "was", + "compiled", + "with" + ], + "isInterface": false, + "isMember": false, + "isType": false + }, + { + "name": "user", + "description": [ + "Username", + "of", + "the", + "user" + ], + "isInterface": false, + "isMember": false, + "isType": false + }, + { + "name": "host", + "description": [ + "Hostname", + "of", + "the", + "machine" + ], + "isInterface": false, + "isMember": false, + "isType": false + }, + { + "name": "dataDir", + "description": [ + "Directory", + "for", + "Hilbish", + "data", + "files,", + "including", + "the", + "docs", + "and", + "default", + "modules" + ], + "isInterface": false, + "isMember": false, + "isType": false + }, + { + "name": "interactive", + "description": [ + "Is", + "Hilbish", + "in", + "an", + "interactive", + "shell?" + ], + "isInterface": false, + "isMember": false, + "isType": false + }, + { + "name": "login", + "description": [ + "Is", + "Hilbish", + "the", + "login", + "shell?" + ], + "isInterface": false, + "isMember": false, + "isType": false + }, + { + "name": "vimMode", + "description": [ + "Current", + "Vim", + "input", + "mode", + "of", + "Hilbish", + "(will", + "be", + "nil", + "if", + "not", + "in", + "Vim", + "input", + "mode)" + ], + "isInterface": false, + "isMember": false, + "isType": false + }, + { + "name": "exitCode", + "description": [ + "Exit", + "code", + "of", + "the", + "last", + "executed", + "command" + ], + "isInterface": false, + "isMember": false, + "isType": false + } + ], "types": [ { "name": "Sink", @@ -26,6 +164,127 @@ } ], "docs": [ + { + "name": "luaSinkAutoFlush", + "description": [ + "Sets/toggles the option of automatically flushing output.", + "A call with no argument will toggle the value." + ], + "signature": "autoFlush(auto)", + "goFuncName": "luasinkautoflush", + "isInterface": false, + "isMember": true, + "isType": false, + "tags": { + "member": [ + { + "id": "", + "fields": null, + "startIdx": 0 + } + ] + } + }, + { + "name": "luaSinkFlush", + "description": [ + "Flush writes all buffered input to the sink." + ], + "signature": "flush()", + "goFuncName": "luasinkflush", + "isInterface": false, + "isMember": true, + "isType": false, + "tags": { + "member": [ + { + "id": "", + "fields": null, + "startIdx": 0 + } + ] + } + }, + { + "name": "luaSinkRead", + "description": [ + "Reads a liine of input from the sink." + ], + "signature": "read() -\u003e string", + "goFuncName": "luasinkread", + "isInterface": false, + "isMember": true, + "isType": false, + "tags": { + "member": [ + { + "id": "", + "fields": null, + "startIdx": 0 + } + ] + } + }, + { + "name": "luaSinkReadAll", + "description": [ + "Reads all input from the sink." + ], + "signature": "readAll() -\u003e string", + "goFuncName": "luasinkreadall", + "isInterface": false, + "isMember": true, + "isType": false, + "tags": { + "member": [ + { + "id": "", + "fields": null, + "startIdx": 0 + } + ] + } + }, + { + "name": "luaSinkWrite", + "description": [ + "Writes data to a sink." + ], + "signature": "write(str)", + "goFuncName": "luasinkwrite", + "isInterface": false, + "isMember": true, + "isType": false, + "tags": { + "member": [ + { + "id": "", + "fields": null, + "startIdx": 0 + } + ] + } + }, + { + "name": "luaSinkWriteln", + "description": [ + "Writes data to a sink with a newline at the end." + ], + "signature": "writeln(str)", + "goFuncName": "luasinkwriteln", + "isInterface": false, + "isMember": true, + "isType": false, + "tags": { + "member": [ + { + "id": "", + "fields": null, + "startIdx": 0 + } + ] + } + }, { "name": "alias", "description": [ @@ -869,127 +1128,6 @@ } ] } - }, - { - "name": "luaSinkAutoFlush", - "description": [ - "Sets/toggles the option of automatically flushing output.", - "A call with no argument will toggle the value." - ], - "signature": "autoFlush(auto)", - "goFuncName": "luasinkautoflush", - "isInterface": false, - "isMember": true, - "isType": false, - "tags": { - "member": [ - { - "id": "", - "fields": null, - "startIdx": 0 - } - ] - } - }, - { - "name": "luaSinkFlush", - "description": [ - "Flush writes all buffered input to the sink." - ], - "signature": "flush()", - "goFuncName": "luasinkflush", - "isInterface": false, - "isMember": true, - "isType": false, - "tags": { - "member": [ - { - "id": "", - "fields": null, - "startIdx": 0 - } - ] - } - }, - { - "name": "luaSinkRead", - "description": [ - "Reads a liine of input from the sink." - ], - "signature": "read() -\u003e string", - "goFuncName": "luasinkread", - "isInterface": false, - "isMember": true, - "isType": false, - "tags": { - "member": [ - { - "id": "", - "fields": null, - "startIdx": 0 - } - ] - } - }, - { - "name": "luaSinkReadAll", - "description": [ - "Reads all input from the sink." - ], - "signature": "readAll() -\u003e string", - "goFuncName": "luasinkreadall", - "isInterface": false, - "isMember": true, - "isType": false, - "tags": { - "member": [ - { - "id": "", - "fields": null, - "startIdx": 0 - } - ] - } - }, - { - "name": "luaSinkWrite", - "description": [ - "Writes data to a sink." - ], - "signature": "write(str)", - "goFuncName": "luasinkwrite", - "isInterface": false, - "isMember": true, - "isType": false, - "tags": { - "member": [ - { - "id": "", - "fields": null, - "startIdx": 0 - } - ] - } - }, - { - "name": "luaSinkWriteln", - "description": [ - "Writes data to a sink with a newline at the end." - ], - "signature": "writeln(str)", - "goFuncName": "luasinkwriteln", - "isInterface": false, - "isMember": true, - "isType": false, - "tags": { - "member": [ - { - "id": "", - "fields": null, - "startIdx": 0 - } - ] - } } ], "interfaces": { diff --git a/docs/api/bait.md b/docs/api/bait.md index 8a9857f9..1043c53a 100644 --- a/docs/api/bait.md +++ b/docs/api/bait.md @@ -13,15 +13,19 @@ menu: Bait is the event emitter for Hilbish. Much like Node.js and its `events` system, many actions in Hilbish emit events. Unlike Node.js, Hilbish events are global. So make sure to -pick a unique name! +pick a unique name!\ + \ Usage of the Bait module consists of userstanding event-driven architecture, but it's pretty simple: If you want to act on a certain event, you can `catch` it. -You can act on events via callback functions. +You can act on events via callback functions.\ + \ Examples of this are in the Hilbish default config! -Consider this part of it: +Consider this part of it:\ + \ + ```lua bait.catch('command.exit', function(code) running = false @@ -75,6 +79,7 @@ bait.catch(name, cb) + ``` @@ -106,6 +111,7 @@ bait.catchOnce(name, cb) + ``` @@ -130,6 +136,7 @@ bait.hooks(name) -> table + ``` @@ -151,6 +158,7 @@ bait.release(name, catcher) + ``` @@ -188,6 +196,7 @@ bait.throw(name, ...args) + ``` diff --git a/docs/api/commander.md b/docs/api/commander.md index 0462c612..389ec162 100644 --- a/docs/api/commander.md +++ b/docs/api/commander.md @@ -13,8 +13,8 @@ menu: Commander is the library which handles Hilbish commands. This makes the user able to add Lua-written commands to their shell without making a separate script in a bin folder. Instead, you may simply use the Commander -library in your Hilbish config. - +library in your Hilbish config.\ + \ ```lua local commander = require 'commander' @@ -25,20 +25,18 @@ end) In this example, a command with the name of `hello` is created that will print `Hello world!` to output. One question you may -have is: What is the `sinks` parameter? - +have is: What is the `sinks` parameter?\ + \ The `sinks` parameter is a table with 3 keys: `input`, `out`, and `err`. There is an `in` alias to `input`, but it requires using the string accessor syntax (`sinks['in']`) as `in` is also a Lua keyword, so `input` is preferred for use. All of them are a @Sink. -In the future, `sinks.in` will be removed. +In the future, `sinks.in` will be removed.\ + \ -- `in` is the standard input. -You may use the read functions on this sink to get input from the user. -- `out` is standard output. -This is usually where command output should go. -- `err` is standard error. -This sink is for writing errors, as the name would suggest. +- `in` is the standard input. You may use the read functions on this sink to get input from the user. +- `out` is standard output. This is usually where command output should go. +- `err` is standard error. This sink is for writing errors, as the name would suggest. ## Functions @@ -74,6 +72,7 @@ commander.deregister(name) + ``` @@ -95,6 +94,7 @@ commander.register(name, cb) + ``` @@ -132,6 +132,7 @@ commander.registry() -> table + ``` diff --git a/docs/api/fs.md b/docs/api/fs.md index cb1f2d11..12bcfad5 100644 --- a/docs/api/fs.md +++ b/docs/api/fs.md @@ -91,6 +91,7 @@ fs.abs(path) -> string + ``` @@ -113,6 +114,7 @@ fs.basename(path) -> string + ``` @@ -135,6 +137,7 @@ fs.cd(dir) + ``` @@ -156,6 +159,7 @@ fs.dir(path) -> string + ``` @@ -178,6 +182,7 @@ fs.glob(pattern) -> matches (table) + ``` @@ -214,6 +219,7 @@ fs.join(...path) -> string + ``` @@ -242,6 +248,7 @@ fs.mkdir(name, recursive) + ``` @@ -274,6 +281,7 @@ fs.fpipe() -> File, File + ``` @@ -294,6 +302,7 @@ fs.readdir(path) -> table[string] + ``` @@ -315,6 +324,7 @@ fs.stat(path) -> {} + ``` diff --git a/docs/api/hilbish.md b/docs/api/hilbish.md index 1afd2bf8..acb95f53 100644 --- a/docs/api/hilbish.md +++ b/docs/api/hilbish.md @@ -1,6 +1,6 @@ --- title: Module hilbish -description: +description: the core Hilbish API layout: doc menu: docs: @@ -9,7 +9,8 @@ menu: ## Introduction - +The Hilbish module includes the core API, containing +interfaces and functions which directly relate to shell functionality. ## Functions @@ -86,6 +87,53 @@ menu: ``` +## Static module fields + +``` =html +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
verThe version of Hilbish
goVersionThe version of Go that Hilbish was compiled with
userUsername of the user
hostHostname of the machine
dataDirDirectory for Hilbish data files, including the docs and default modules
interactiveIs Hilbish in an interactive shell?
loginIs Hilbish the login shell?
vimModeCurrent Vim input mode of Hilbish (will be nil if not in Vim input mode)
exitCodeExit code of the last executed command
+
+``` + ## Functions ``` =html @@ -97,6 +145,7 @@ hilbish.alias(cmd, orig) + ``` @@ -131,6 +180,7 @@ hilbish.appendPath(dir) + ``` @@ -164,6 +214,7 @@ hilbish.complete(scope, cb) + ``` @@ -219,6 +270,7 @@ hilbish.cwd() -> string + ``` @@ -238,6 +290,7 @@ hilbish.exec(cmd) + ``` @@ -260,6 +313,7 @@ hilbish.goro(fn) + ``` @@ -284,6 +338,7 @@ hilbish.highlighter(line) + ``` @@ -319,6 +374,7 @@ hilbish.hinter(line, pos) + ``` @@ -355,6 +411,7 @@ hilbish.inputMode(mode) + ``` @@ -378,6 +435,7 @@ hilbish.interval(cb, time) -> @Timer + ``` @@ -403,6 +461,7 @@ hilbish.multiprompt(str) + ``` @@ -444,6 +503,7 @@ hilbish.prependPath(dir) + ``` @@ -465,6 +525,7 @@ hilbish.prompt(str, typ) + ``` @@ -503,6 +564,7 @@ hilbish.read(prompt) -> input (string) + ``` @@ -526,6 +588,7 @@ hilbish.timeout(cb, time) -> @Timer + ``` @@ -551,6 +614,7 @@ hilbish.which(name) -> string + ``` diff --git a/docs/api/readline.md b/docs/api/readline.md index 27d7650d..203569e8 100644 --- a/docs/api/readline.md +++ b/docs/api/readline.md @@ -41,6 +41,7 @@ readline.new() -> @Readline + ``` diff --git a/docs/api/snail.md b/docs/api/snail.md index ea032606..d1b3714c 100644 --- a/docs/api/snail.md +++ b/docs/api/snail.md @@ -40,6 +40,7 @@ snail.new() -> @Snail + ``` diff --git a/docs/api/terminal.md b/docs/api/terminal.md index 496e451d..c4bdc142 100644 --- a/docs/api/terminal.md +++ b/docs/api/terminal.md @@ -49,6 +49,7 @@ terminal.restoreState() + ``` @@ -68,6 +69,7 @@ terminal.saveState() + ``` @@ -87,6 +89,7 @@ terminal.setRaw() + ``` @@ -106,6 +109,7 @@ terminal.size() + ``` diff --git a/docs/api/yarn.md b/docs/api/yarn.md index cd2b72d1..b676a26a 100644 --- a/docs/api/yarn.md +++ b/docs/api/yarn.md @@ -49,6 +49,7 @@ yarn.thread(fun) -> @Thread + ``` diff --git a/golibs/bait/bait.go b/golibs/bait/bait.go index 9a38d02f..b042de71 100644 --- a/golibs/bait/bait.go +++ b/golibs/bait/bait.go @@ -3,15 +3,14 @@ Bait is the event emitter for Hilbish. Much like Node.js and its `events` system, many actions in Hilbish emit events. Unlike Node.js, Hilbish events are global. So make sure to -pick a unique name! - +pick a unique name! Usage of the Bait module consists of userstanding event-driven architecture, but it's pretty simple: If you want to act on a certain event, you can `catch` it. -You can act on events via callback functions. - +You can act on events via callback functions. Examples of this are in the Hilbish default config! -Consider this part of it: +Consider this part of it: + ```lua bait.catch('command.exit', function(code) running = false @@ -30,11 +29,12 @@ import ( "hilbish/util" - rt "github.com/arnodel/golua/runtime" "github.com/arnodel/golua/lib/packagelib" + rt "github.com/arnodel/golua/runtime" ) type listenerType int + const ( goListener listenerType = iota luaListener @@ -44,25 +44,25 @@ const ( type Recoverer func(event string, handler *Listener, err interface{}) // Listener is a struct that holds the handler for an event. -type Listener struct{ - typ listenerType - once bool - caller func(...interface{}) rt.Value +type Listener struct { + typ listenerType + once bool + caller func(...interface{}) rt.Value luaCaller *rt.Closure } -type Bait struct{ - Loader packagelib.Loader +type Bait struct { + Loader packagelib.Loader recoverer Recoverer - handlers map[string][]*Listener - rtm *rt.Runtime + handlers map[string][]*Listener + rtm *rt.Runtime } // New creates a new Bait instance. func New(rtm *rt.Runtime) *Bait { b := &Bait{ handlers: make(map[string][]*Listener), - rtm: rtm, + rtm: rtm, } b.Loader = packagelib.Loader{ Load: b.loaderFunc, @@ -93,8 +93,10 @@ func (b *Bait) Emit(event string, args ...interface{}) []rt.Value { for _, arg := range args { var luarg rt.Value switch arg.(type) { - case rt.Value: luarg = arg.(rt.Value) - default: luarg = rt.AsValue(arg) + case rt.Value: + luarg = arg.(rt.Value) + default: + luarg = rt.AsValue(arg) } luaArgs = append(luaArgs, luarg) } @@ -130,7 +132,7 @@ func (b *Bait) Emit(event string, args ...interface{}) []rt.Value { // On adds a Go function handler for an event. func (b *Bait) On(event string, handler func(...interface{}) rt.Value) *Listener { listener := &Listener{ - typ: goListener, + typ: goListener, caller: handler, } @@ -141,7 +143,7 @@ func (b *Bait) On(event string, handler func(...interface{}) rt.Value) *Listener // OnLua adds a Lua function handler for an event. func (b *Bait) OnLua(event string, handler *rt.Closure) *Listener { listener := &Listener{ - typ: luaListener, + typ: luaListener, luaCaller: handler, } b.addListener(event, listener) @@ -174,8 +176,8 @@ func (b *Bait) OffLua(event string, handler *rt.Closure) { // Once adds a Go function listener for an event that only runs once. func (b *Bait) Once(event string, handler func(...interface{}) rt.Value) *Listener { listener := &Listener{ - typ: goListener, - once: true, + typ: goListener, + once: true, caller: handler, } b.addListener(event, listener) @@ -186,8 +188,8 @@ func (b *Bait) Once(event string, handler func(...interface{}) rt.Value) *Listen // OnceLua adds a Lua function listener for an event that only runs once. func (b *Bait) OnceLua(event string, handler *rt.Closure) *Listener { listener := &Listener{ - typ: luaListener, - once: true, + typ: luaListener, + once: true, luaCaller: handler, } b.addListener(event, listener) @@ -208,11 +210,10 @@ func (b *Bait) addListener(event string, listener *Listener) { b.handlers[event] = append(b.handlers[event], listener) } - func (b *Bait) removeListener(event string, idx int) { - b.handlers[event][idx] = b.handlers[event][len(b.handlers[event]) - 1] + b.handlers[event][idx] = b.handlers[event][len(b.handlers[event])-1] - b.handlers[event] = b.handlers[event][:len(b.handlers[event]) - 1] + b.handlers[event] = b.handlers[event][:len(b.handlers[event])-1] } func (b *Bait) callRecoverer(event string, handler *Listener, err interface{}) { @@ -224,11 +225,11 @@ func (b *Bait) callRecoverer(event string, handler *Listener, err interface{}) { func (b *Bait) loaderFunc(rtm *rt.Runtime) (rt.Value, func()) { exports := map[string]util.LuaExport{ - "catch": util.LuaExport{b.bcatch, 2, false}, + "catch": util.LuaExport{b.bcatch, 2, false}, "catchOnce": util.LuaExport{b.bcatchOnce, 2, false}, - "throw": util.LuaExport{b.bthrow, 1, true}, - "release": util.LuaExport{b.brelease, 2, false}, - "hooks": util.LuaExport{b.bhooks, 1, false}, + "throw": util.LuaExport{b.bthrow, 1, true}, + "release": util.LuaExport{b.brelease, 2, false}, + "hooks": util.LuaExport{b.bhooks, 1, false}, } mod := rt.NewTable() util.SetExports(rtm, mod, exports) @@ -294,8 +295,10 @@ func (b *Bait) bhooks(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { luaHandlers := rt.NewTable() for _, handler := range handlers { - if handler.typ != luaListener { continue } - luaHandlers.Set(rt.IntValue(luaHandlers.Len() + 1), rt.FunctionValue(handler.luaCaller)) + if handler.typ != luaListener { + continue + } + luaHandlers.Set(rt.IntValue(luaHandlers.Len()+1), rt.FunctionValue(handler.luaCaller)) } if luaHandlers.Len() == 0 { diff --git a/golibs/commander/commander.go b/golibs/commander/commander.go index 840aaa19..660a0e76 100644 --- a/golibs/commander/commander.go +++ b/golibs/commander/commander.go @@ -3,8 +3,7 @@ Commander is the library which handles Hilbish commands. This makes the user able to add Lua-written commands to their shell without making a separate script in a bin folder. Instead, you may simply use the Commander -library in your Hilbish config. - +library in your Hilbish config. ```lua local commander = require 'commander' @@ -15,40 +14,35 @@ end) In this example, a command with the name of `hello` is created that will print `Hello world!` to output. One question you may -have is: What is the `sinks` parameter? - +have is: What is the `sinks` parameter? The `sinks` parameter is a table with 3 keys: `input`, `out`, and `err`. There is an `in` alias to `input`, but it requires using the string accessor syntax (`sinks['in']`) as `in` is also a Lua keyword, so `input` is preferred for use. All of them are a @Sink. -In the future, `sinks.in` will be removed. - -- `in` is the standard input. -You may use the read functions on this sink to get input from the user. -- `out` is standard output. -This is usually where command output should go. -- `err` is standard error. -This sink is for writing errors, as the name would suggest. +In the future, `sinks.in` will be removed. +- `in` is the standard input. You may use the read functions on this sink to get input from the user. +- `out` is standard output. This is usually where command output should go. +- `err` is standard error. This sink is for writing errors, as the name would suggest. */ package commander import ( - "hilbish/util" "hilbish/golibs/bait" + "hilbish/util" - rt "github.com/arnodel/golua/runtime" "github.com/arnodel/golua/lib/packagelib" + rt "github.com/arnodel/golua/runtime" ) -type Commander struct{ - Events *bait.Bait - Loader packagelib.Loader +type Commander struct { + Events *bait.Bait + Loader packagelib.Loader Commands map[string]*rt.Closure } func New(rtm *rt.Runtime) *Commander { c := &Commander{ - Events: bait.New(rtm), + Events: bait.New(rtm), Commands: make(map[string]*rt.Closure), } c.Loader = packagelib.Loader{ @@ -61,9 +55,9 @@ func New(rtm *rt.Runtime) *Commander { func (c *Commander) loaderFunc(rtm *rt.Runtime) (rt.Value, func()) { exports := map[string]util.LuaExport{ - "register": util.LuaExport{c.cregister, 2, false}, + "register": util.LuaExport{c.cregister, 2, false}, "deregister": util.LuaExport{c.cderegister, 1, false}, - "registry": util.LuaExport{c.cregistry, 0, false}, + "registry": util.LuaExport{c.cregistry, 0, false}, } mod := rt.NewTable() util.SetExports(rtm, mod, exports) diff --git a/website/content/install.md b/website/content/install.md index 1460f0c9..04aba125 100644 --- a/website/content/install.md +++ b/website/content/install.md @@ -4,23 +4,17 @@ description: Steps on how to install Hilbish on all the OSes and distros support layout: page --- +There are a small amount of ways to grab Hilbish. You can download the releases from GitHub, use your package manager, or build from source. + ## Official Binaries -The best way to get Hilbish is to get a build directly from GitHub. - +The easiest way to get Hilbish is to get a build directly from GitHub. At any time, there are 2 versions of Hilbish available to install: -the latest stable release, and development builds from the master branch. +the latest stable release, and development builds from the master branch.\ +You can download both at any time, but note that the development builds may have breaking changes.\ +To download the latest stable release, [see here](https://github.com/Rosettea/Hilbish/releases/latest) -You can download both at any time, but note that the development builds may -have breaking changes. - -For the latest *stable release*, check here: https://github.com/Rosettea/Hilbish/releases/latest - -For a *development build*: https://nightly.link/Rosettea/Hilbish/workflows/build/master - -## Compiling - -To read the steps for compiling Hilbish, head over to the [GitHub repository.](https://github.com/Rosettea/Hilbish#build) +For the latest development build, [click here](https://nightly.link/Rosettea/Hilbish/workflows/build/master) ## Package Repositories @@ -47,3 +41,7 @@ Or, from master branch: `yay -S hilbish-git` Hilbish is currentlty in the testing/edge repository for Alpine. Follow the steps [here](https://wiki.alpinelinux.org/wiki/Enable_Community_Repository) (using testing repositories) and install: `apk add hilbish` + +## Compiling From Source + +To see steps on compiling Hilbish from source, [visit the GitHub repository](https://github.com/Rosettea/Hilbish#build) diff --git a/website/src/pages/doc.gleam b/website/src/pages/doc.gleam index 9362ca84..3faef667 100644 --- a/website/src/pages/doc.gleam +++ b/website/src/pages/doc.gleam @@ -21,7 +21,7 @@ pub fn page( this_slug: String, doc_pages_list, ) -> element.Element(a) { - html.div([attribute.class("flex-auto flex flex-col overflow-none")], [ + html.div([attribute.class("flex-1 flex flex-col overflow-hidden")], [ html.div( [ attribute.class( @@ -43,7 +43,7 @@ pub fn page( html.span([attribute.class("font-bold")], [element.text(p.title)]), ], ), - html.div([attribute.class("h-full sm:flex grid")], [ + html.div([attribute.class("flex-1 sm:flex grid overflow-hidden")], [ html.input([ attribute.type_("checkbox"), attribute.id("sidebar-toggle"), @@ -52,7 +52,7 @@ pub fn page( html.div( [ attribute.class( - "p-4 sm:border-r sm:border-r-zinc-300 col-start-1 row-start-1 bg-neutral-100 dark:bg-neutral-950 basis-2/10 transition-transform duration-300 -translate-x-full peer-checked:translate-x-0 sm:translate-x-0 z-30", + "overflow-y-scroll p-4 sm:border-r sm:border-r-zinc-300 col-start-1 row-start-1 bg-neutral-100 dark:bg-neutral-950 basis-2/10 transition-transform duration-300 -translate-x-full peer-checked:translate-x-0 sm:translate-x-0 z-30", ), ], [ @@ -187,18 +187,24 @@ pub fn page( html.main( [ attribute.class( - "mb-4 h-full overflow-y-auto basis-7/7 col-start-1 row-start-1 transition-all duration-300 peer-checked:filter peer-checked:blur-sm peer-checked:bg-black/30 px-4 pt-2", + "flex-1 flex justify-center basis-7/7 col-start-1 row-start-1 transition-all duration-300 peer-checked:filter peer-checked:blur-sm peer-checked:bg-black/30", ), ], [ - html.h1([attribute.class("my-3 font-bold text-4xl")], [ - element.text(p.title), + html.div([attribute.class("flex-1 flex flex-col overflow-y-auto")], [ + // todo: add date of publishing + //html.time([], []) + //html.small([], [element.text({{p.contents |> string.split(" ") |> list.length} / 200} |> int.to_string <> " min read")]), + //element.unsafe_raw_html("namespace", "Tag", [], render_doc(p.contents)) + html.div([attribute.class("flex-1 w-3/4 self-center p-8")], [ + html.h1([attribute.class("my-3 font-bold text-4xl")], [ + element.text(p.title), + ]), + html.i([], [element.text(p.description)]), + ..render_doc(p.contents) + ]), + util.footer(), ]), - // todo: add date of publishing - //html.time([], []) - //html.small([], [element.text({{p.contents |> string.split(" ") |> list.length} / 200} |> int.to_string <> " min read")]), - //element.unsafe_raw_html("namespace", "Tag", [], render_doc(p.contents)) - ..render_doc(p.contents) ], ), ]), @@ -218,7 +224,8 @@ fn render_doc(md: String) { } let margin = case level { - 1 -> "my-2" + 1 -> "my-4" + 2 -> "my-2" _ -> "my-1" } diff --git a/website/src/post.gleam b/website/src/post.gleam index 84bd648d..ef0b4635 100644 --- a/website/src/post.gleam +++ b/website/src/post.gleam @@ -4,6 +4,7 @@ import gleam/option pub type Post { Post( name: String, + description: String, title: String, slug: String, metadata: option.Option(glaml.Document), diff --git a/website/src/util.gleam b/website/src/util.gleam index cbc8b8da..1303bb96 100644 --- a/website/src/util.gleam +++ b/website/src/util.gleam @@ -6,6 +6,7 @@ import lustre/attribute import lustre/element import lustre/element/html +import conf import glaml import post @@ -68,3 +69,74 @@ pub fn link(url: String, text: String, out: Bool) { ], ) } + +pub fn nav() -> element.Element(a) { + html.nav( + [ + attribute.class( + "bg-stone-100/80 dark:bg-neutral-950/80 flex justify-around sticky items-center top-0 w-full z-50 border-b border-b-zinc-300 backdrop-blur-md h-12", + ), + ], + [ + html.div([attribute.class("flex my-auto px-2")], [ + html.div([], [ + html.a( + [attribute.href("/"), attribute.class("flex items-center gap-1")], + [ + html.img([ + attribute.src(conf.base_url_join("/hilbish-flower.png")), + attribute.class("h-8"), + ]), + html.span([attribute.class("self-center text-3xl font-medium")], [ + element.text("Hilbish"), + ]), + ], + ), + ]), + ]), + html.div([attribute.class("flex gap-3")], [ + link(conf.base_url_join("/install"), "Install", False), + link(conf.base_url_join("/docs"), "Docs", False), + link(conf.base_url_join("/blog"), "Blog", False), + ]), + ], + ) +} + +pub fn footer() -> element.Element(a) { + html.footer( + [ + attribute.class( + "py-4 px-6 flex flex-row justify-around border-t border-t-zinc-300", + ), + ], + [ + html.div([attribute.class("flex flex-col")], [ + html.a( + [ + attribute.href(conf.base_url), + attribute.class("flex items-center gap-1"), + ], + [ + html.img([ + attribute.src(conf.base_url_join("/hilbish-flower.png")), + attribute.class("h-24"), + ]), + html.span([attribute.class("self-center text-6xl")], [ + element.text("Hilbish"), + ]), + ], + ), + html.span([attribute.class("text-xl")], [ + element.text("The Moon-powered shell!"), + ]), + html.span([attribute.class("text-light text-neutral-500")], [ + element.text("MIT License, copyright sammyette 2025"), + ]), + ]), + html.div([attribute.class("flex flex-col")], [ + link("https://github.com/Rosettea/Hilbish", "GitHub", True), + ]), + ], + ) +} diff --git a/website/src/website.gleam b/website/src/website.gleam index 7eea0cf3..eebd8127 100644 --- a/website/src/website.gleam +++ b/website/src/website.gleam @@ -56,8 +56,20 @@ pub fn main() { option.None -> "" } + let description = case metadata { + option.Some(metadata) -> { + case + glaml.select_sugar(glaml.document_root(metadata), "description") + { + Ok(glaml.NodeStr(s)) -> s + _ -> "" + } + } + option.None -> "" + } + let assert Ok(filename) = path |> string.split("/") |> list.last - #(slug, post.Post(name, title, slug, metadata, content)) + #(slug, post.Post(name, description, title, slug, metadata, content)) }) let doc_pages = @@ -78,14 +90,18 @@ pub fn main() { let build = ssg.new("./public") |> ssg.add_static_dir("static") - |> ssg.add_static_route("/", create_page(index.page())) + |> ssg.add_static_route("/", create_page(index.page(), False)) |> list.fold(posts, _, fn(config, post) { let page = case is_doc_page(post.0) { True -> doc.page(post.1, post.0, doc_pages) False -> doc.page(post.1, post.0, doc_pages) } //io.debug(post.0) - ssg.add_static_route(config, post.0, create_page(page)) + ssg.add_static_route( + config, + post.0, + create_page(page, is_doc_page(post.0)), + ) }) |> ssg.use_index_routes |> ssg.build @@ -106,78 +122,10 @@ fn is_doc_page(slug: String) { } } -fn nav() -> element.Element(a) { - html.nav( - [ - attribute.class( - "bg-stone-100/80 dark:bg-neutral-950/80 flex justify-around sticky items-center top-0 w-full z-50 border-b border-b-zinc-300 backdrop-blur-md h-12", - ), - ], - [ - html.div([attribute.class("flex my-auto px-2")], [ - html.div([], [ - html.a( - [attribute.href("/"), attribute.class("flex items-center gap-1")], - [ - html.img([ - attribute.src(conf.base_url_join("/hilbish-flower.png")), - attribute.class("h-8"), - ]), - html.span([attribute.class("self-center text-3xl font-medium")], [ - element.text("Hilbish"), - ]), - ], - ), - ]), - ]), - html.div([attribute.class("flex gap-3")], [ - util.link(conf.base_url_join("/install"), "Install", False), - util.link(conf.base_url_join("/docs"), "Docs", False), - util.link(conf.base_url_join("/blog"), "Blog", False), - ]), - ], - ) -} - -fn footer() -> element.Element(a) { - html.footer( - [ - attribute.class( - "py-4 px-6 flex flex-row justify-around border-t border-t-zinc-300", - ), - ], - [ - html.div([attribute.class("flex flex-col")], [ - html.a( - [ - attribute.href(conf.base_url), - attribute.class("flex items-center gap-1"), - ], - [ - html.img([ - attribute.src(conf.base_url_join("/hilbish-flower.png")), - attribute.class("h-24"), - ]), - html.span([attribute.class("self-center text-6xl")], [ - element.text("Hilbish"), - ]), - ], - ), - html.span([attribute.class("text-xl")], [ - element.text("The Moon-powered shell!"), - ]), - html.span([attribute.class("text-light text-neutral-500")], [ - element.text("MIT License, copyright sammyette 2025"), - ]), - ]), - html.div([attribute.class("flex flex-col")], [ - util.link("https://github.com/Rosettea/Hilbish", "GitHub", True), - ]), - ], - ) -} - -fn create_page(content: element.Element(a)) -> element.Element(a) { +fn create_page( + content: element.Element(a), + doc_page: Bool, +) -> element.Element(a) { let description = "Something Unique. Hilbish is the new interactive shell for Lua fans. Extensible, scriptable, configurable: All in Lua." @@ -236,10 +184,13 @@ fn create_page(content: element.Element(a)) -> element.Element(a) { attribute.attribute("property", "og:url"), ]), ]), - html.body([attribute.class("min-h-screen flex flex-col")], [ - nav(), + html.body([attribute.class("h-screen flex flex-col")], [ + util.nav(), content, - footer(), + case doc_page { + True -> element.none() + False -> util.footer() + }, ]), ], )