docs: push fixed docs

docs-refactor
TorchedSammy 2022-12-03 16:54:34 -04:00
parent c05b1b6168
commit 23d18ef11c
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
4 changed files with 61 additions and 244 deletions

View File

@ -1,91 +1,31 @@
--- ---
name: Module bait name: Module bait
description: the core Hilbish API description: the event emitter
layout: apidoc layout: apidoc
--- ---
## Introduction ## Introduction
The Hilbish module includes the core API, containing Bait is the event emitter for Hilbish. Why name it bait? Why not.
interfaces and functions which directly relate to shell functionality. It throws hooks that you can catch. This is what you will use if
you want to listen in on hooks to know when certain things have
happened, like when you've changed directory, a command has failed,
etc. To find all available hooks thrown by Hilbish, see doc hooks.
## Functions ## Functions
### alias(cmd, orig) ### catch(name, cb)
Sets an alias of `cmd` to `orig` Catches a hook with `name`. Runs the `cb` when it is thrown
### appendPath(dir) ### catchOnce(name, cb)
Appends `dir` to $PATH Same as catch, but only runs the `cb` once and then removes the hook
### complete(scope, cb) ### hooks(name) -> {cb, cb...}
Registers a completion handler for `scope`. Returns a table with hooks on the event with `name`.
A `scope` is currently only expected to be `command.<cmd>`,
replacing <cmd> with the name of the command (for example `command.git`).
`cb` must be a function that returns a table of "completion groups."
Check `doc completions` for more information.
### cwd() ### release(name, catcher)
Returns the current directory of the shell Removes the `catcher` for the event with `name`
For this to work, `catcher` has to be the same function used to catch
an event, like one saved to a variable.
### exec(cmd) ### throw(name, ...args)
Replaces running hilbish with `cmd` Throws a hook with `name` with the provided `args`
### goro(fn)
Puts `fn` in a goroutine
### highlighter(line)
Line highlighter handler. This is mainly for syntax highlighting, but in
reality could set the input of the prompt to *display* anything. The
callback is passed the current line and is expected to return a line that
will be used as the input display.
### hinter(line, pos)
The command line hint handler. It gets called on every key insert to
determine what text to use as an inline hint. It is passed the current
line and cursor position. It is expected to return a string which is used
as the text for the hint. This is by default a shim. To set hints,
override this function with your custom handler.
### inputMode(mode)
Sets the input mode for Hilbish's line reader. Accepts either emacs or vim
### interval(cb, time)
Runs the `cb` function every `time` milliseconds.
Returns a `timer` object (see `doc timers`).
### multiprompt(str)
Changes the continued line prompt to `str`
### prependPath(dir)
Prepends `dir` to $PATH
### prompt(str, typ?)
Changes the shell prompt to `str`
There are a few verbs that can be used in the prompt text.
These will be formatted and replaced with the appropriate values.
`%d` - Current working directory
`%u` - Name of current user
`%h` - Hostname of device
### read(prompt?) -> input?
Read input from the user, using Hilbish's line editor/input reader.
This is a separate instance from the one Hilbish actually uses.
Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
### run(cmd, returnOut) -> exitCode, stdout, stderr
Runs `cmd` in Hilbish's sh interpreter.
If returnOut is true, the outputs of `cmd` will be returned as the 2nd and
3rd values instead of being outputted to the terminal.
### runnerMode(mode)
Sets the execution/runner mode for interactive Hilbish. This determines whether
Hilbish wll try to run input as Lua and/or sh or only do one of either.
Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua),
sh, and lua. It also accepts a function, to which if it is passed one
will call it to execute user input instead.
### timeout(cb, time)
Runs the `cb` function after `time` in milliseconds
Returns a `timer` object (see `doc timers`).
### which(name)
Checks if `name` is a valid command

View File

@ -1,23 +1,16 @@
--- ---
name: Module commander name: Module commander
description: low level terminal library description: library for custom commands
layout: apidoc layout: apidoc
--- ---
## Introduction ## Introduction
The terminal library is a simple and lower level library for certain terminal interactions. Commander is a library for writing custom commands in Lua.
## Functions ## Functions
### restoreState() ### deregister(name)
Restores the last saved state of the terminal Deregisters any command registered with `name`
### saveState() ### register(name, cb)
Saves the current state of the terminal Register a command with `name` that runs `cb` when ran
### setRaw()
Puts the terminal in raw mode
### size()
Gets the dimensions of the terminal. Returns a table with `width` and `height`
Note: this is not the size in relation to the dimensions of the display

View File

@ -1,91 +1,43 @@
--- ---
name: Module fs name: Module fs
description: the core Hilbish API description: filesystem interaction and functionality library
layout: apidoc layout: apidoc
--- ---
## Introduction ## Introduction
The Hilbish module includes the core API, containing The fs module provides easy and simple access to filesystem functions
interfaces and functions which directly relate to shell functionality. and other things, and acts an addition to the Lua standard library's
I/O and filesystem functions.
## Functions ## Functions
### alias(cmd, orig) ### abs(path)
Sets an alias of `cmd` to `orig` Gives an absolute version of `path`.
### appendPath(dir) ### basename(path)
Appends `dir` to $PATH Gives the basename of `path`. For the rules,
see Go's filepath.Base
### complete(scope, cb) ### cd(dir)
Registers a completion handler for `scope`. Changes directory to `dir`
A `scope` is currently only expected to be `command.<cmd>`,
replacing <cmd> with the name of the command (for example `command.git`).
`cb` must be a function that returns a table of "completion groups."
Check `doc completions` for more information.
### cwd() ### dir(path)
Returns the current directory of the shell Returns the directory part of `path`. For the rules, see Go's
filepath.Dir
### exec(cmd) ### glob(pattern)
Replaces running hilbish with `cmd` Glob all files and directories that match the pattern.
For the rules, see Go's filepath.Glob
### goro(fn) ### join(paths...)
Puts `fn` in a goroutine Takes paths and joins them together with the OS's
directory separator (forward or backward slash).
### highlighter(line) ### mkdir(name, recursive)
Line highlighter handler. This is mainly for syntax highlighting, but in Makes a directory called `name`. If `recursive` is true, it will create its parent directories.
reality could set the input of the prompt to *display* anything. The
callback is passed the current line and is expected to return a line that
will be used as the input display.
### hinter(line, pos) ### readdir(dir)
The command line hint handler. It gets called on every key insert to Returns a table of files in `dir`
determine what text to use as an inline hint. It is passed the current
line and cursor position. It is expected to return a string which is used
as the text for the hint. This is by default a shim. To set hints,
override this function with your custom handler.
### inputMode(mode) ### stat(path)
Sets the input mode for Hilbish's line reader. Accepts either emacs or vim Returns info about `path`
### interval(cb, time)
Runs the `cb` function every `time` milliseconds.
Returns a `timer` object (see `doc timers`).
### multiprompt(str)
Changes the continued line prompt to `str`
### prependPath(dir)
Prepends `dir` to $PATH
### prompt(str, typ?)
Changes the shell prompt to `str`
There are a few verbs that can be used in the prompt text.
These will be formatted and replaced with the appropriate values.
`%d` - Current working directory
`%u` - Name of current user
`%h` - Hostname of device
### read(prompt?) -> input?
Read input from the user, using Hilbish's line editor/input reader.
This is a separate instance from the one Hilbish actually uses.
Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
### run(cmd, returnOut) -> exitCode, stdout, stderr
Runs `cmd` in Hilbish's sh interpreter.
If returnOut is true, the outputs of `cmd` will be returned as the 2nd and
3rd values instead of being outputted to the terminal.
### runnerMode(mode)
Sets the execution/runner mode for interactive Hilbish. This determines whether
Hilbish wll try to run input as Lua and/or sh or only do one of either.
Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua),
sh, and lua. It also accepts a function, to which if it is passed one
will call it to execute user input instead.
### timeout(cb, time)
Runs the `cb` function after `time` in milliseconds
Returns a `timer` object (see `doc timers`).
### which(name)
Checks if `name` is a valid command

View File

@ -1,91 +1,23 @@
--- ---
name: Module terminal name: Module terminal
description: the core Hilbish API description: low level terminal library
layout: apidoc layout: apidoc
--- ---
## Introduction ## Introduction
The Hilbish module includes the core API, containing The terminal library is a simple and lower level library for certain terminal interactions.
interfaces and functions which directly relate to shell functionality.
## Functions ## Functions
### alias(cmd, orig) ### restoreState()
Sets an alias of `cmd` to `orig` Restores the last saved state of the terminal
### appendPath(dir) ### saveState()
Appends `dir` to $PATH Saves the current state of the terminal
### complete(scope, cb) ### setRaw()
Registers a completion handler for `scope`. Puts the terminal in raw mode
A `scope` is currently only expected to be `command.<cmd>`,
replacing <cmd> with the name of the command (for example `command.git`).
`cb` must be a function that returns a table of "completion groups."
Check `doc completions` for more information.
### cwd() ### size()
Returns the current directory of the shell Gets the dimensions of the terminal. Returns a table with `width` and `height`
Note: this is not the size in relation to the dimensions of the display
### exec(cmd)
Replaces running hilbish with `cmd`
### goro(fn)
Puts `fn` in a goroutine
### highlighter(line)
Line highlighter handler. This is mainly for syntax highlighting, but in
reality could set the input of the prompt to *display* anything. The
callback is passed the current line and is expected to return a line that
will be used as the input display.
### hinter(line, pos)
The command line hint handler. It gets called on every key insert to
determine what text to use as an inline hint. It is passed the current
line and cursor position. It is expected to return a string which is used
as the text for the hint. This is by default a shim. To set hints,
override this function with your custom handler.
### inputMode(mode)
Sets the input mode for Hilbish's line reader. Accepts either emacs or vim
### interval(cb, time)
Runs the `cb` function every `time` milliseconds.
Returns a `timer` object (see `doc timers`).
### multiprompt(str)
Changes the continued line prompt to `str`
### prependPath(dir)
Prepends `dir` to $PATH
### prompt(str, typ?)
Changes the shell prompt to `str`
There are a few verbs that can be used in the prompt text.
These will be formatted and replaced with the appropriate values.
`%d` - Current working directory
`%u` - Name of current user
`%h` - Hostname of device
### read(prompt?) -> input?
Read input from the user, using Hilbish's line editor/input reader.
This is a separate instance from the one Hilbish actually uses.
Returns `input`, will be nil if ctrl + d is pressed, or an error occurs (which shouldn't happen)
### run(cmd, returnOut) -> exitCode, stdout, stderr
Runs `cmd` in Hilbish's sh interpreter.
If returnOut is true, the outputs of `cmd` will be returned as the 2nd and
3rd values instead of being outputted to the terminal.
### runnerMode(mode)
Sets the execution/runner mode for interactive Hilbish. This determines whether
Hilbish wll try to run input as Lua and/or sh or only do one of either.
Accepted values for mode are hybrid (the default), hybridRev (sh first then Lua),
sh, and lua. It also accepts a function, to which if it is passed one
will call it to execute user input instead.
### timeout(cb, time)
Runs the `cb` function after `time` in milliseconds
Returns a `timer` object (see `doc timers`).
### which(name)
Checks if `name` is a valid command