diff --git a/api.go b/api.go index 142e410..b7afb3d 100644 --- a/api.go +++ b/api.go @@ -9,7 +9,7 @@ // #field interactive Is Hilbish in an interactive shell? // #field login Is Hilbish the login shell? // #field vimMode Current Vim input mode of Hilbish (will be nil if not in Vim input mode) -// #field exitCode xit code of the last executed command +// #field exitCode Exit code of the last executed command package main import ( diff --git a/cmd/docgen/docgen.go b/cmd/docgen/docgen.go index cbe6baa..5b452d7 100644 --- a/cmd/docgen/docgen.go +++ b/cmd/docgen/docgen.go @@ -11,6 +11,8 @@ import ( "strings" "os" "sync" + + md "github.com/atsushinee/go-markdown-generator/doc" ) var header = `--- @@ -43,6 +45,12 @@ type module struct { HasTypes bool } +type param struct{ + Name string + Type string + Doc []string +} + type docPiece struct { Doc []string FuncSig string @@ -55,6 +63,7 @@ type docPiece struct { IsType bool Fields []docPiece Properties []docPiece + Params []param } type tag struct { @@ -215,6 +224,17 @@ start: fields := docPieceTag("field", tags) properties := docPieceTag("property", tags) + var params []param + if paramsRaw := tags["param"]; paramsRaw != nil { + params = make([]param, len(paramsRaw)) + for i, p := range paramsRaw { + params[i] = param{ + Name: p.id, + Type: p.fields[0], + Doc: p.fields[1:], + } + } + } for _, d := range doc { if strings.HasPrefix(d, "---") { @@ -252,6 +272,7 @@ start: ParentModule: parentMod, Fields: fields, Properties: properties, + Params: params, } if strings.HasSuffix(dps.GoFuncName, strings.ToLower("loader")) { dps.Doc = parts @@ -412,13 +433,14 @@ func main() { defer wg.Done() modOrIface := "Module" if modu.ParentModule != "" { - modOrIface = "Interface" + modOrIface = "Module" } + lastHeader := "" f, _ := os.Create(docPath) f.WriteString(fmt.Sprintf(header, modOrIface, modname, modu.ShortDescription)) typeTag, _ := regexp.Compile(`\B@\w+`) - modDescription := typeTag.ReplaceAllStringFunc(strings.Replace(modu.Description, "<", `\<`, -1), func(typ string) string { + modDescription := typeTag.ReplaceAllStringFunc(strings.Replace(strings.Replace(modu.Description, "<", `\<`, -1), "{{\\<", "{{<", -1), func(typ string) string { typName := typ[1:] typLookup := typeTable[strings.ToLower(typName)] ifaces := typLookup[0] + "." + typLookup[1] + "/" @@ -429,32 +451,77 @@ func main() { return fmt.Sprintf(`%s`, linkedTyp, typName) }) f.WriteString(fmt.Sprintf("## Introduction\n%s\n\n", modDescription)) - if len(modu.Fields) != 0 { - f.WriteString("## Interface fields\n") - for _, dps := range modu.Fields { - f.WriteString(fmt.Sprintf("- `%s`: ", dps.FuncName)) - f.WriteString(strings.Join(dps.Doc, " ")) - f.WriteString("\n") - } - f.WriteString("\n") - } - if len(modu.Properties) != 0 { - f.WriteString("## Object properties\n") - for _, dps := range modu.Properties { - f.WriteString(fmt.Sprintf("- `%s`: ", dps.FuncName)) - f.WriteString(strings.Join(dps.Doc, " ")) - f.WriteString("\n") - } - f.WriteString("\n") - } - if len(modu.Docs) != 0 { - f.WriteString("## Functions\n") + funcCount := 0 for _, dps := range modu.Docs { if dps.IsMember { continue } - htmlSig := typeTag.ReplaceAllStringFunc(strings.Replace(dps.FuncSig, "<", `\<`, -1), func(typ string) string { + funcCount++ + } + + f.WriteString("## Functions\n") + lastHeader = "functions" + + mdTable := md.NewTable(funcCount, 2) + mdTable.SetTitle(0, "") + mdTable.SetTitle(1, "") + + diff := 0 + for i, dps := range modu.Docs { + if dps.IsMember { + diff++ + continue + } + + mdTable.SetContent(i - diff, 0, fmt.Sprintf(`%s`, dps.FuncName, dps.FuncSig)) + mdTable.SetContent(i - diff, 1, dps.Doc[0]) + } + f.WriteString(mdTable.String()) + f.WriteString("\n") + } + + if len(modu.Fields) != 0 { + f.WriteString("## Static module fields\n") + + mdTable := md.NewTable(len(modu.Fields), 2) + mdTable.SetTitle(0, "") + mdTable.SetTitle(1, "") + + + for i, dps := range modu.Fields { + mdTable.SetContent(i, 0, dps.FuncName) + mdTable.SetContent(i, 1, strings.Join(dps.Doc, " ")) + } + f.WriteString(mdTable.String()) + f.WriteString("\n") + } + if len(modu.Properties) != 0 { + f.WriteString("## Object properties\n") + + mdTable := md.NewTable(len(modu.Fields), 2) + mdTable.SetTitle(0, "") + mdTable.SetTitle(1, "") + + + for i, dps := range modu.Properties { + mdTable.SetContent(i, 0, dps.FuncName) + mdTable.SetContent(i, 1, strings.Join(dps.Doc, " ")) + } + f.WriteString(mdTable.String()) + f.WriteString("\n") + } + + if len(modu.Docs) != 0 { + if lastHeader != "functions" { + f.WriteString("## Functions\n") + } + for _, dps := range modu.Docs { + if dps.IsMember { + continue + } + f.WriteString(fmt.Sprintf("
", dps.FuncName)) + htmlSig := typeTag.ReplaceAllStringFunc(strings.Replace(modname + "." + dps.FuncSig, "<", `\<`, -1), func(typ string) string { typName := typ[1:] typLookup := typeTable[strings.ToLower(typName)] ifaces := typLookup[0] + "." + typLookup[1] + "/" @@ -462,21 +529,51 @@ func main() { ifaces = "" } linkedTyp := fmt.Sprintf("/Hilbish/docs/api/%s/%s#%s", typLookup[0], ifaces, strings.ToLower(typName)) - return fmt.Sprintf(`%s`, linkedTyp, typName) + return fmt.Sprintf(`%s`, linkedTyp, typName) }) - f.WriteString(fmt.Sprintf("### %s\n", htmlSig)) + f.WriteString(fmt.Sprintf(` +

+%s + + + +

+ +`, htmlSig, dps.FuncName)) for _, doc := range dps.Doc { if !strings.HasPrefix(doc, "---") { f.WriteString(doc + "\n") } } - f.WriteString("\n") + f.WriteString("#### Parameters\n") + if len(dps.Params) == 0 { + f.WriteString("This function has no parameters. \n") + } + for _, p := range dps.Params { + isVariadic := false + typ := p.Type + if strings.HasPrefix(p.Type, "...") { + isVariadic = true + typ = p.Type[3:] + } + + f.WriteString(fmt.Sprintf("`%s` **`%s`**", typ, p.Name)) + if isVariadic { + f.WriteString(" (This type is variadic. You can pass an infinite amount of parameters with this type.)") + } + f.WriteString(" \n") + f.WriteString(strings.Join(p.Doc, " ")) + f.WriteString("\n\n") + } + f.WriteString("
") + f.WriteString("\n\n") } } if len(modu.Types) != 0 { f.WriteString("## Types\n") for _, dps := range modu.Types { + f.WriteString("
\n\n") f.WriteString(fmt.Sprintf("## %s\n", dps.FuncName)) for _, doc := range dps.Doc { if !strings.HasPrefix(doc, "---") { @@ -484,12 +581,18 @@ func main() { } } if len(dps.Properties) != 0 { - f.WriteString("### Properties\n") - for _, dps := range dps.Properties { - f.WriteString(fmt.Sprintf("- `%s`: ", dps.FuncName)) - f.WriteString(strings.Join(dps.Doc, " ")) - f.WriteString("\n") + f.WriteString("## Object properties\n") + + mdTable := md.NewTable(len(dps.Properties), 2) + mdTable.SetTitle(0, "") + mdTable.SetTitle(1, "") + + for i, d := range dps.Properties { + mdTable.SetContent(i, 0, d.FuncName) + mdTable.SetContent(i, 1, strings.Join(d.Doc, " ")) } + f.WriteString(mdTable.String()) + f.WriteString("\n") } f.WriteString("\n") f.WriteString("### Methods\n") diff --git a/website/content/docs/_index.md b/docs/_index.md similarity index 100% rename from website/content/docs/_index.md rename to docs/_index.md diff --git a/docs/api/bait.md b/docs/api/bait.md index a70eb17..91cfb31 100644 --- a/docs/api/bait.md +++ b/docs/api/bait.md @@ -8,27 +8,113 @@ menu: --- ## Introduction -Bait is the event emitter for Hilbish. Why name it bait? Why not. -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. + +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! + +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. + +Examples of this are in the Hilbish default config! +Consider this part of it: +```lua +bait.catch('command.exit', function(code) + running = false + doPrompt(code ~= 0) + doNotifyPrompt() +end) +``` + +What this does is, whenever the `command.exit` event is thrown, +this function will set the user prompt. ## Functions -### catch(name, cb) +||| +|----|----| +|catch(name, cb)|Catches a hook with `name`. Runs the `cb` when it is thrown| +|catchOnce(name, cb)|Same as catch, but only runs the `cb` once and then removes the hook| +|hooks(name) -> table|Returns a table with hooks (callback functions) on the event with `name`.| +|release(name, catcher)|Removes the `catcher` for the event with `name`.| +|throw(name, ...args)|Throws a hook with `name` with the provided `args`| + +
+

+bait.catch(name, cb) + + + +

+ Catches a hook with `name`. Runs the `cb` when it is thrown +#### Parameters +`string` **`name`** +ummm + +`function` **`cb`** +? + +
+ +
+

+bait.catchOnce(name, cb) + + + +

-### catchOnce(name, cb) Same as catch, but only runs the `cb` once and then removes the hook +#### Parameters +This function has no parameters. +
+ +
+

+bait.hooks(name) -> table + + + +

-### hooks(name) -> table Returns a table with hooks (callback functions) on the event with `name`. +#### Parameters +This function has no parameters. +
+ +
+

+bait.release(name, catcher) + + + +

-### release(name, catcher) 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. +#### Parameters +This function has no parameters. +
+ +
+

+bait.throw(name, ...args) + + + +

-### throw(name, ...args) Throws a hook with `name` with the provided `args` +#### Parameters +`string` **`name`** +The name of the hook. + +`any` **`args`** (This type is variadic. You can pass an infinite amount of parameters with this type.) +The arguments to pass to the hook. + +
diff --git a/docs/api/commander.md b/docs/api/commander.md index 341eeda..4d67c81 100644 --- a/docs/api/commander.md +++ b/docs/api/commander.md @@ -31,16 +31,41 @@ The `sinks` parameter is a table with 3 keys: `in`, `out`, and `err`. The values of these is a Sink. - `in` is the standard input. You can read from this sink -to get user input. (**This is currently unimplemented.**) +to get user input. - `out` is standard output. This is usually where text meant for output should go. - `err` is standard error. This sink is for writing errors, as the name would suggest. ## Functions -### deregister(name) +||| +|----|----| +|deregister(name)|Deregisters any command registered with `name`| +|register(name, cb)|Register a command with `name` that runs `cb` when ran| + +
+

+commander.deregister(name) + + + +

+ Deregisters any command registered with `name` +#### Parameters +This function has no parameters. +
+ +
+

+commander.register(name, cb) + + + +

-### register(name, cb) Register a command with `name` that runs `cb` when ran +#### Parameters +This function has no parameters. +
diff --git a/docs/api/fs.md b/docs/api/fs.md index ee6949f..37045eb 100644 --- a/docs/api/fs.md +++ b/docs/api/fs.md @@ -13,39 +13,141 @@ and other things, and acts an addition to the Lua standard library's I/O and filesystem functions. ## Functions -### abs(path) -> string -Gives an absolute version of `path`. +||| +|----|----| +|abs(path) -> string|Gives an absolute version of `path`.| +|basename(path) -> string|Gives the basename of `path`. For the rules,| +|cd(dir)|Changes directory to `dir`| +|dir(path) -> string|Returns the directory part of `path`. For the rules, see Go's| +|glob(pattern) -> matches (table)|Glob all files and directories that match the pattern.| +|join(...) -> string|Takes paths and joins them together with the OS's| +|mkdir(name, recursive)|Makes a directory called `name`. If `recursive` is true, it will create its parent directories.| +|readdir(dir) -> {}|Returns a table of files in `dir`.| +|stat(path) -> {}|Returns a table of info about the `path`.| + +
+

+fs.abs(path) -> string + + + +

+ +Gives an absolute version of `path`. +#### Parameters +This function has no parameters. +
+ +
+

+fs.basename(path) -> string + + + +

-### basename(path) -> string Gives the basename of `path`. For the rules, see Go's filepath.Base +#### Parameters +This function has no parameters. +
+ +
+

+fs.cd(dir) + + + +

-### cd(dir) Changes directory to `dir` +#### Parameters +This function has no parameters. +
+ +
+

+fs.dir(path) -> string + + + +

-### dir(path) -> string Returns the directory part of `path`. For the rules, see Go's filepath.Dir +#### Parameters +This function has no parameters. +
+ +
+

+fs.glob(pattern) -> matches (table) + + + +

-### glob(pattern) -> matches (table) Glob all files and directories that match the pattern. For the rules, see Go's filepath.Glob +#### Parameters +This function has no parameters. +
+ +
+

+fs.join(...) -> string + + + +

-### join(...) -> string Takes paths and joins them together with the OS's directory separator (forward or backward slash). +#### Parameters +This function has no parameters. +
+ +
+

+fs.mkdir(name, recursive) + + + +

-### mkdir(name, recursive) Makes a directory called `name`. If `recursive` is true, it will create its parent directories. +#### Parameters +This function has no parameters. +
+ +
+

+fs.readdir(dir) -> {} + + + +

-### readdir(dir) -> {} Returns a table of files in `dir`. +#### Parameters +This function has no parameters. +
+ +
+

+fs.stat(path) -> {} + + + +

-### stat(path) -> {} Returns a table of info about the `path`. It contains the following keys: name (string) - Name of the path size (number) - Size of the path mode (string) - Permission mode in an octal format string (with leading 0) isDir (boolean) - If the path is a directory +#### Parameters +This function has no parameters. +
diff --git a/docs/api/hilbish/_index.md b/docs/api/hilbish/_index.md index a683172..0cb17d5 100644 --- a/docs/api/hilbish/_index.md +++ b/docs/api/hilbish/_index.md @@ -11,41 +11,131 @@ menu: The Hilbish module includes the core API, containing interfaces and functions which directly relate to shell functionality. -## Interface fields -- `ver`: The version of Hilbish -- `goVersion`: The version of Go that Hilbish was compiled with -- `user`: Username of the user -- `host`: Hostname of the machine -- `dataDir`: Directory for Hilbish data files, including the docs and default modules -- `interactive`: Is Hilbish in an interactive shell? -- `login`: Is Hilbish the login shell? -- `vimMode`: Current Vim input mode of Hilbish (will be nil if not in Vim input mode) -- `exitCode`: xit code of the last executed command - ## Functions -### alias(cmd, orig) +||| +|----|----| +|alias(cmd, orig)|Sets an alias of `cmd` to `orig`| +|appendPath(dir)|Appends `dir` to $PATH| +|complete(scope, cb)|Registers a completion handler for `scope`.| +|cwd() -> string|Returns the current directory of the shell| +|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| +|hinter(line, pos)|The command line hint handler. It gets called on every key insert to| +|inputMode(mode)|Sets the input mode for Hilbish's line reader. Accepts either emacs or vim| +|interval(cb, time) -> @Timer|Runs the `cb` function every `time` milliseconds.| +|multiprompt(str)|Changes the continued line prompt to `str`| +|prependPath(dir)|Prepends `dir` to $PATH| +|prompt(str, typ)|Changes the shell prompt to `str`| +|read(prompt) -> input (string)|Read input from the user, using Hilbish's line editor/input reader.| +|run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string)|Runs `cmd` in Hilbish's sh interpreter.| +|runnerMode(mode)|Sets the execution/runner mode for interactive Hilbish. This determines whether| +|timeout(cb, time) -> @Timer|Runs the `cb` function after `time` in milliseconds.| +|which(name) -> string|Checks if `name` is a valid command.| + +## Static module fields +||| +|----|----| +|ver|The version of Hilbish| +|goVersion|The version of Go that Hilbish was compiled with| +|user|Username of the user| +|host|Hostname of the machine| +|dataDir|Directory for Hilbish data files, including the docs and default modules| +|interactive|Is Hilbish in an interactive shell?| +|login|Is Hilbish the login shell?| +|vimMode|Current Vim input mode of Hilbish (will be nil if not in Vim input mode)| +|exitCode|Exit code of the last executed command| + +
+

+hilbish.alias(cmd, orig) + + + +

+ Sets an alias of `cmd` to `orig` +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.appendPath(dir) + + + +

-### appendPath(dir) Appends `dir` to $PATH +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.complete(scope, cb) + + + +

-### complete(scope, cb) Registers a completion handler for `scope`. A `scope` is currently only expected to be `command.`, replacing 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. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.cwd() -> string + + + +

-### cwd() -> string Returns the current directory of the shell +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.exec(cmd) + + + +

-### exec(cmd) Replaces running hilbish with `cmd` +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.goro(fn) + + + +

-### goro(fn) Puts `fn` in a goroutine +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.highlighter(line) + + + +

-### 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 @@ -58,61 +148,176 @@ function hilbish.highlighter(line) end ``` This code will highlight all double quoted strings in green. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.hinter(line, pos) + + + +

-### 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. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.inputMode(mode) + + + +

-### inputMode(mode) Sets the input mode for Hilbish's line reader. Accepts either emacs or vim +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.interval(cb, time) -> Timer + + + +

-### interval(cb, time) -> Timer Runs the `cb` function every `time` milliseconds. This creates a timer that starts immediately. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.multiprompt(str) + + + +

-### multiprompt(str) Changes the continued line prompt to `str` +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.prependPath(dir) + + + +

-### prependPath(dir) Prepends `dir` to $PATH +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.prompt(str, typ) + + + +

-### 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 +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.read(prompt) -> input (string) + + + +

-### read(prompt) -> input (string) 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) +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string) + + + +

-### run(cmd, returnOut) -> exitCode (number), stdout (string), stderr (string) 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. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.runnerMode(mode) + + + +

-### 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. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.timeout(cb, time) -> Timer + + + +

-### timeout(cb, time) -> Timer Runs the `cb` function after `time` in milliseconds. This creates a timer that starts immediately. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.which(name) -> string + + + +

-### which(name) -> string Checks if `name` is a valid command. Will return the path of the binary, or a basename if it's a commander. +#### Parameters +This function has no parameters. +
## Types +
+ ## Sink A sink is a structure that has input and/or output to/from a desination. diff --git a/docs/api/hilbish/hilbish.aliases.md b/docs/api/hilbish/hilbish.aliases.md index bae5bfc..5274e04 100644 --- a/docs/api/hilbish/hilbish.aliases.md +++ b/docs/api/hilbish/hilbish.aliases.md @@ -1,5 +1,5 @@ --- -title: Interface hilbish.aliases +title: Module hilbish.aliases description: command aliasing layout: doc menu: @@ -11,15 +11,62 @@ menu: The alias interface deals with all command aliases in Hilbish. ## Functions -### add(alias, cmd) +||| +|----|----| +|add(alias, cmd)|This is an alias (ha) for the `hilbish.alias` function.| +|delete(name)|Removes an alias.| +|list() -> table|Get a table of all aliases, with string keys as the alias and the value as the command.| +|resolve(alias) -> command (string)|Tries to resolve an alias to its command.| + +
+

+hilbish.aliases.add(alias, cmd) + + + +

+ This is an alias (ha) for the `hilbish.alias` function. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.aliases.delete(name) + + + +

-### delete(name) Removes an alias. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.aliases.list() -> table\ + + + +

-### list() -> table\ Get a table of all aliases, with string keys as the alias and the value as the command. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.aliases.resolve(alias) -> command (string) + + + +

-### resolve(alias) -> command (string) Tries to resolve an alias to its command. +#### Parameters +This function has no parameters. +
diff --git a/docs/api/hilbish/hilbish.completions.md b/docs/api/hilbish/hilbish.completions.md index 6f8740f..790aeee 100644 --- a/docs/api/hilbish/hilbish.completions.md +++ b/docs/api/hilbish/hilbish.completions.md @@ -1,5 +1,5 @@ --- -title: Interface hilbish.completions +title: Module hilbish.completions description: tab completions layout: doc menu: @@ -11,19 +11,66 @@ menu: The completions interface deals with tab completions. ## Functions -### call(name, query, ctx, fields) -> completionGroups (table), prefix (string) +||| +|----|----| +|call(name, query, ctx, fields) -> completionGroups (table), prefix (string)|Calls a completer function. This is mainly used to call| +|handler(line, pos)|The handler function is the callback for tab completion in Hilbish.| +|bins(query, ctx, fields) -> entries (table), prefix (string)|Returns binary/executale completion candidates based on the provided query.| +|files(query, ctx, fields) -> entries (table), prefix (string)|Returns file completion candidates based on the provided query.| + +
+

+hilbish.completions.call(name, query, ctx, fields) -> completionGroups (table), prefix (string) + + + +

+ Calls a completer function. This is mainly used to call a command completer, which will have a `name` in the form of `command.name`, example: `command.git`. You can check `doc completions` for info on the `completionGroups` return value. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.completions.handler(line, pos) + + + +

-### handler(line, pos) The handler function is the callback for tab completion in Hilbish. You can check the completions doc for more info. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.completions.bins(query, ctx, fields) -> entries (table), prefix (string) + + + +

-### bins(query, ctx, fields) -> entries (table), prefix (string) Returns binary/executale completion candidates based on the provided query. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.completions.files(query, ctx, fields) -> entries (table), prefix (string) + + + +

-### files(query, ctx, fields) -> entries (table), prefix (string) Returns file completion candidates based on the provided query. +#### Parameters +This function has no parameters. +
diff --git a/docs/api/hilbish/hilbish.editor.md b/docs/api/hilbish/hilbish.editor.md index d75d4c2..3ded67a 100644 --- a/docs/api/hilbish/hilbish.editor.md +++ b/docs/api/hilbish/hilbish.editor.md @@ -1,5 +1,5 @@ --- -title: Interface hilbish.editor +title: Module hilbish.editor description: interactions for Hilbish's line reader layout: doc menu: @@ -12,19 +12,77 @@ The hilbish.editor interface provides functions to directly interact with the line editor in use. ## Functions -### getLine() -> string +||| +|----|----| +|getLine() -> string|Returns the current input line.| +|getVimRegister(register) -> string|Returns the text that is at the register.| +|insert(text)|Inserts text into the line.| +|getChar() -> string|Reads a keystroke from the user. This is in a format| +|setVimRegister(register, text)|Sets the vim register at `register` to hold the passed text.| + +
+

+hilbish.editor.getLine() -> string + + + +

+ Returns the current input line. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.editor.getVimRegister(register) -> string + + + +

-### getVimRegister(register) -> string Returns the text that is at the register. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.editor.insert(text) + + + +

-### insert(text) Inserts text into the line. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.editor.getChar() -> string + + + +

-### getChar() -> string Reads a keystroke from the user. This is in a format of something like Ctrl-L.. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.editor.setVimRegister(register, text) + + + +

-### setVimRegister(register, text) Sets the vim register at `register` to hold the passed text. +#### Parameters +This function has no parameters. +
diff --git a/docs/api/hilbish/hilbish.history.md b/docs/api/hilbish/hilbish.history.md index 9fa9b01..3d9b856 100644 --- a/docs/api/hilbish/hilbish.history.md +++ b/docs/api/hilbish/hilbish.history.md @@ -1,5 +1,5 @@ --- -title: Interface hilbish.history +title: Module hilbish.history description: command history layout: doc menu: @@ -13,18 +13,76 @@ This includes the ability to override functions to change the main method of saving history. ## Functions -### add(cmd) +||| +|----|----| +|add(cmd)|Adds a command to the history.| +|all() -> table|Retrieves all history.| +|clear()|Deletes all commands from the history.| +|get(idx)|Retrieves a command from the history based on the `idx`.| +|size() -> number|Returns the amount of commands in the history.| + +
+

+hilbish.history.add(cmd) + + + +

+ Adds a command to the history. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.history.all() -> table + + + +

-### all() -> table Retrieves all history. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.history.clear() + + + +

-### clear() Deletes all commands from the history. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.history.get(idx) + + + +

-### get(idx) Retrieves a command from the history based on the `idx`. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.history.size() -> number + + + +

-### size() -> number Returns the amount of commands in the history. +#### Parameters +This function has no parameters. +
diff --git a/docs/api/hilbish/hilbish.jobs.md b/docs/api/hilbish/hilbish.jobs.md index e41be2c..bb1af1e 100644 --- a/docs/api/hilbish/hilbish.jobs.md +++ b/docs/api/hilbish/hilbish.jobs.md @@ -1,5 +1,5 @@ --- -title: Interface hilbish.jobs +title: Module hilbish.jobs description: background job management layout: doc menu: @@ -15,32 +15,95 @@ 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. ## Functions -### add(cmdstr, args, execPath) +||| +|----|----| +|add(cmdstr, args, execPath)|Adds a new job to the job table. Note that this does not immediately run it.| +|all() -> table<@Job>|Returns a table of all job objects.| +|disown(id)|Disowns a job. This deletes it from the job table.| +|get(id) -> @Job|Get a job object via its ID.| +|last() -> @Job|Returns the last added job from the table.| + +
+

+hilbish.jobs.add(cmdstr, args, execPath) + + + +

+ Adds a new job to the job table. Note that this does not immediately run it. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.jobs.all() -> table\<Job> + + + +

-### all() -> table\<Job> Returns a table of all job objects. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.jobs.disown(id) + + + +

-### disown(id) Disowns a job. This deletes it from the job table. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.jobs.get(id) -> Job + + + +

-### get(id) -> Job Get a job object via its ID. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.jobs.last() -> Job + + + +

-### last() -> Job Returns the last added job from the table. +#### Parameters +This function has no parameters. +
## Types +
+ ## Job The Job type describes a Hilbish job. -### Properties -- `cmd`: The user entered command string for the job. -- `running`: Whether the job is running or not. -- `id`: The ID of the job in the job table -- `pid`: The Process ID -- `exitCode`: The last exit code of the job. -- `stdout`: The standard output of the job. This just means the normal logs of the process. -- `stderr`: The standard error stream of the process. This (usually) includes error messages of the job. +## Object properties +||| +|----|----| +|cmd|The user entered command string for the job.| +|running|Whether the job is running or not.| +|id|The ID of the job in the job table| +|pid|The Process ID| +|exitCode|The last exit code of the job.| +|stdout|The standard output of the job. This just means the normal logs of the process.| +|stderr|The standard error stream of the process. This (usually) includes error messages of the job.| + ### Methods #### background() diff --git a/docs/api/hilbish/hilbish.module.md b/docs/api/hilbish/hilbish.module.md index e88ac2c..9a0af12 100644 --- a/docs/api/hilbish/hilbish.module.md +++ b/docs/api/hilbish/hilbish.module.md @@ -1,5 +1,5 @@ --- -title: Interface hilbish.module +title: Module hilbish.module description: native module loading layout: doc menu: @@ -43,11 +43,27 @@ func Loader(rtm *rt.Runtime) rt.Value { This can be compiled with `go build -buildmode=plugin plugin.go`. If you attempt to require and print the result (`print(require 'plugin')`), it will show "hello world!" -## Interface fields -- `paths`: A list of paths to search when loading native modules. This is in the style of Lua search paths and will be used when requiring native modules. Example: `?.so;?/?.so` - ## Functions -### load(path) +||| +|----|----| +|load(path)|Loads a module at the designated `path`.| + +## Static module fields +||| +|----|----| +|paths|A list of paths to search when loading native modules. This is in the style of Lua search paths and will be used when requiring native modules. Example: `?.so;?/?.so`| + +
+

+hilbish.module.load(path) + + + +

+ Loads a module at the designated `path`. It will throw if any error occurs. +#### Parameters +This function has no parameters. +
diff --git a/docs/api/hilbish/hilbish.os.md b/docs/api/hilbish/hilbish.os.md index aa2198e..7749e3d 100644 --- a/docs/api/hilbish/hilbish.os.md +++ b/docs/api/hilbish/hilbish.os.md @@ -1,5 +1,5 @@ --- -title: Interface hilbish.os +title: Module hilbish.os description: OS Info layout: doc menu: @@ -12,8 +12,10 @@ The `os` interface provides simple text information properties about the current OS on the systen. This mainly includes the name and version. -## Interface fields -- `family`: Family name of the current OS -- `name`: Pretty name of the current OS -- `version`: Version of the current OS +## Static module fields +||| +|----|----| +|family|Family name of the current OS| +|name|Pretty name of the current OS| +|version|Version of the current OS| diff --git a/docs/api/hilbish/hilbish.runner.md b/docs/api/hilbish/hilbish.runner.md index 68ffdc6..5528195 100644 --- a/docs/api/hilbish/hilbish.runner.md +++ b/docs/api/hilbish/hilbish.runner.md @@ -1,5 +1,5 @@ --- -title: Interface hilbish.runner +title: Module hilbish.runner description: interactive command runner customization layout: doc menu: @@ -15,17 +15,53 @@ language or script of their choosing. A good example is using it to write command in Fennel. ## Functions -### setMode(cb) +||| +|----|----| +|setMode(cb)|This is the same as the `hilbish.runnerMode` function. It takes a callback,| +|lua(cmd)|Evaluates `cmd` as Lua input. This is the same as using `dofile`| +|sh(cmd)|Runs a command in Hilbish's shell script interpreter.| + +
+

+hilbish.runner.setMode(cb) + + + +

+ This is the same as the `hilbish.runnerMode` function. It takes a callback, which will be used to execute all interactive input. In normal cases, neither callbacks should be overrided by the user, as the higher level functions listed below this will handle it. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.runner.lua(cmd) + + + +

-### lua(cmd) Evaluates `cmd` as Lua input. This is the same as using `dofile` or `load`, but is appropriated for the runner interface. +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.runner.sh(cmd) + + + +

-### sh(cmd) Runs a command in Hilbish's shell script interpreter. This is the equivalent of using `source`. +#### Parameters +This function has no parameters. +
diff --git a/docs/api/hilbish/hilbish.timers.md b/docs/api/hilbish/hilbish.timers.md index e899d1d..dae7782 100644 --- a/docs/api/hilbish/hilbish.timers.md +++ b/docs/api/hilbish/hilbish.timers.md @@ -1,5 +1,5 @@ --- -title: Interface hilbish.timers +title: Module hilbish.timers description: timeout and interval API layout: doc menu: @@ -30,25 +30,57 @@ t:start() print(t.running) // true ``` -## Interface fields -- `INTERVAL`: Constant for an interval timer type -- `TIMEOUT`: Constant for a timeout timer type - ## Functions -### create(type, time, callback) -> Timer +||| +|----|----| +|create(type, time, callback) -> @Timer|Creates a timer that runs based on the specified `time` in milliseconds.| +|get(id) -> @Timer|Retrieves a timer via its ID.| + +## Static module fields +||| +|----|----| +|INTERVAL|Constant for an interval timer type| +|TIMEOUT|Constant for a timeout timer type| + +
+

+hilbish.timers.create(type, time, callback) -> Timer + + + +

+ Creates a timer that runs based on the specified `time` in milliseconds. The `type` can either be `hilbish.timers.INTERVAL` or `hilbish.timers.TIMEOUT` +#### Parameters +This function has no parameters. +
+ +
+

+hilbish.timers.get(id) -> Timer + + + +

-### get(id) -> Timer Retrieves a timer via its ID. +#### Parameters +This function has no parameters. +
## Types +
+ ## Timer The Job type describes a Hilbish timer. -### Properties -- `type`: What type of timer it is -- `running`: If the timer is running -- `duration`: The duration in milliseconds that the timer will run +## 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| + ### Methods #### start() diff --git a/docs/api/hilbish/hilbish.userDir.md b/docs/api/hilbish/hilbish.userDir.md index 0b95057..a2b7337 100644 --- a/docs/api/hilbish/hilbish.userDir.md +++ b/docs/api/hilbish/hilbish.userDir.md @@ -1,5 +1,5 @@ --- -title: Interface hilbish.userDir +title: Module hilbish.userDir description: user-related directories layout: doc menu: @@ -12,7 +12,9 @@ This interface just contains properties to know about certain user directories. It is equivalent to XDG on Linux and gets the user's preferred directories for configs and data. -## Interface fields -- `config`: The user's config directory -- `data`: The user's directory for program data +## Static module fields +||| +|----|----| +|config|The user's config directory| +|data|The user's directory for program data| diff --git a/docs/api/terminal.md b/docs/api/terminal.md index 99d4b49..4977e97 100644 --- a/docs/api/terminal.md +++ b/docs/api/terminal.md @@ -11,16 +11,63 @@ menu: The terminal library is a simple and lower level library for certain terminal interactions. ## Functions -### restoreState() +||| +|----|----| +|restoreState()|Restores the last saved state of the terminal| +|saveState()|Saves the current state of the terminal| +|setRaw()|Puts the terminal in raw mode| +|size()|Gets the dimensions of the terminal. Returns a table with `width` and `height`| + +
+

+terminal.restoreState() + + + +

+ Restores the last saved state of the terminal +#### Parameters +This function has no parameters. +
+ +
+

+terminal.saveState() + + + +

-### saveState() Saves the current state of the terminal +#### Parameters +This function has no parameters. +
+ +
+

+terminal.setRaw() + + + +

-### setRaw() Puts the terminal in raw mode +#### Parameters +This function has no parameters. +
+ +
+

+terminal.size() + + + +

-### 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 +#### Parameters +This function has no parameters. +
diff --git a/website/content/docs/faq.md b/docs/faq.md similarity index 74% rename from website/content/docs/faq.md rename to docs/faq.md index 997fbaa..f89f269 100644 --- a/website/content/docs/faq.md +++ b/docs/faq.md @@ -15,11 +15,12 @@ It compiles for Windows (CI ensures it does), but otherwise it is not directly supported. If you'd like to improve this situation, checkout [the discussion](https://github.com/Rosettea/Hilbish/discussions/165). -# Where is the API documentation? -The builtin `doc` command supplies all documentation of Hilbish provided -APIs. You can also check the sidebar. - # Why? Hilbish emerged from the desire of a Lua configured shell. It was the initial reason that it was created, but now it's more: to be hyper extensible, simpler and more user friendly. + +# Does it have "autocompletion" or "tab completion" +Of course! This is a modern shell. Hilbish provides a way for users +to write tab completion for any command and/or the whole shell. +Inline hinting and syntax highlighting are also available. diff --git a/website/content/docs/features/_index.md b/docs/features/_index.md similarity index 100% rename from website/content/docs/features/_index.md rename to docs/features/_index.md diff --git a/website/content/docs/features/notifications.md b/docs/features/notifications.md similarity index 100% rename from website/content/docs/features/notifications.md rename to docs/features/notifications.md diff --git a/website/content/docs/features/runner-mode.md b/docs/features/runner-mode.md similarity index 100% rename from website/content/docs/features/runner-mode.md rename to docs/features/runner-mode.md diff --git a/website/content/docs/getting-started.md b/docs/getting-started.md similarity index 100% rename from website/content/docs/getting-started.md rename to docs/getting-started.md diff --git a/docs/hooks/_index.md b/docs/hooks/_index.md index 6616b05..500b6e6 100644 --- a/docs/hooks/_index.md +++ b/docs/hooks/_index.md @@ -1,10 +1,19 @@ +--- +title: Hooks +description: +layout: doc +weight: -50 +menu: + docs +--- + Here is a list of bait hooks that are thrown by Hilbish. If a hook is related to a command, it will have the `command` scope, as example. Here is the format for a doc for a hook: -+ -> > ++ {hook name} -> args > description -`` just means the arguments of the hook. If a hook doc has the format +`{args}` just means the arguments of the hook. If a hook doc has the format of `arg...`, it means the hook can take/recieve any number of `arg`. + error -> eventName, handler, err > Emitted when there is an error in diff --git a/docs/hooks/command.md b/docs/hooks/command.md index 2d29f4b..ee47db7 100644 --- a/docs/hooks/command.md +++ b/docs/hooks/command.md @@ -1,12 +1,21 @@ -+ `command.preexec` -> input, cmdStr > Thrown before a command +--- +title: Command +description: +layout: doc +menu: + docs: + parent: "Hooks" +--- + +- `command.preexec` -> input, cmdStr > Thrown before a command is executed. The `input` is the user written command, while `cmdStr` is what will be executed (`input` will have aliases while `cmdStr` will have alias resolved input). -+ `command.exit` -> code, cmdStr > Thrown when a command exits. +- `command.exit` -> code, cmdStr > Thrown when a command exits. `code` is the exit code of the command, and `cmdStr` is the command that was run. -+ `command.not-found` -> cmdStr > Thrown when a command is not found. +- `command.not-found` -> cmdStr > Thrown when a command is not found. -+ `command.not-executable` -> cmdStr > Thrown when Hilbish attempts to run a file +- `command.not-executable` -> cmdStr > Thrown when Hilbish attempts to run a file that is not executable. diff --git a/docs/hooks/hilbish.md b/docs/hooks/hilbish.md index 7118901..b240683 100644 --- a/docs/hooks/hilbish.md +++ b/docs/hooks/hilbish.md @@ -1,3 +1,12 @@ +--- +title: Hilbish +description: +layout: doc +menu: + docs: + parent: "Hooks" +--- + + `hilbish.exit` > Sent when Hilbish is about to exit. + `hilbish.vimMode` -> modeName > Sent when Hilbish's Vim mode is changed (example insert to normal mode), diff --git a/docs/hooks/signal.md b/docs/hooks/signal.md index ac5deed..317ab79 100644 --- a/docs/hooks/signal.md +++ b/docs/hooks/signal.md @@ -1,3 +1,12 @@ +--- +title: Signal +description: +layout: doc +menu: + docs: + parent: "Hooks" +--- + + `signal.sigint` > Sent when Hilbish receives SIGINT (on Ctrl-C). + `signal.resize` > Sent when the terminal is resized. diff --git a/emmyLuaDocs/bait.lua b/emmyLuaDocs/bait.lua index 35a37ed..6ca76ab 100644 --- a/emmyLuaDocs/bait.lua +++ b/emmyLuaDocs/bait.lua @@ -3,8 +3,6 @@ local bait = {} --- Catches a hook with `name`. Runs the `cb` when it is thrown ---- @param name string ---- @param cb function function bait.catch(name, cb) end --- Same as catch, but only runs the `cb` once and then removes the hook diff --git a/go.mod b/go.mod index 1549f76..7bf5efd 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.17 require ( github.com/arnodel/golua v0.0.0-20220221163911-dfcf252b6f86 + github.com/atsushinee/go-markdown-generator v0.0.0-20191121114853-83f9e1f68504 github.com/blackfireio/osinfo v1.0.3 github.com/maxlandon/readline v0.1.0-beta.0.20211027085530-2b76cabb8036 github.com/pborman/getopt v1.1.0 diff --git a/go.sum b/go.sum index 7c36fa0..f82ef01 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,8 @@ github.com/arnodel/edit v0.0.0-20220202110212-dfc8d7a13890/go.mod h1:AcpttpuZBaL github.com/arnodel/strftime v0.1.6 h1:0hc0pUvk8KhEMXE+htyaOUV42zNcf/csIbjzEFCJqsw= github.com/arnodel/strftime v0.1.6/go.mod h1:5NbK5XqYK8QpRZpqKNt4OlxLtIB8cotkLk4KTKzJfWs= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= +github.com/atsushinee/go-markdown-generator v0.0.0-20191121114853-83f9e1f68504 h1:R1/AOzdMbopSliUTTEHvHbyNmnZ3YxY5GvdhTkpPsSY= +github.com/atsushinee/go-markdown-generator v0.0.0-20191121114853-83f9e1f68504/go.mod h1:kHBCvAXJIatTX1pw6tLiOspjGc3MhUDRlog9yrCUS+k= github.com/blackfireio/osinfo v1.0.3 h1:Yk2t2GTPjBcESv6nDSWZKO87bGMQgO+Hi9OoXPpxX8c= github.com/blackfireio/osinfo v1.0.3/go.mod h1:Pd987poVNmd5Wsx6PRPw4+w7kLlf9iJxoRKPtPAjOrA= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= diff --git a/golibs/bait/bait.go b/golibs/bait/bait.go index 3f3c34e..dca3773 100644 --- a/golibs/bait/bait.go +++ b/golibs/bait/bait.go @@ -1,9 +1,28 @@ // the event emitter -// Bait is the event emitter for Hilbish. Why name it bait? Why not. -// 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. +/* +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! + +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. + +Examples of this are in the Hilbish default config! +Consider this part of it: +```lua +bait.catch('command.exit', function(code) + running = false + doPrompt(code ~= 0) + doNotifyPrompt() +end) +``` + +What this does is, whenever the `command.exit` event is thrown, +this function will set the user prompt. +*/ package bait import ( @@ -229,6 +248,8 @@ func handleHook(t *rt.Thread, c *rt.GoCont, name string, catcher *rt.Closure, ar } // throw(name, ...args) +// #param name string The name of the hook. +// #param args ...any The arguments to pass to the hook. // Throws a hook with `name` with the provided `args` // --- @param name string // --- @vararg any @@ -251,8 +272,8 @@ func (b *Bait) bthrow(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { // catch(name, cb) // Catches a hook with `name`. Runs the `cb` when it is thrown -// --- @param name string -// --- @param cb function +// #param name string ummm +// #param cb function ? func (b *Bait) bcatch(t *rt.Thread, c *rt.GoCont) (rt.Cont, error) { name, catcher, err := util.HandleStrCallback(t, c) if err != nil { diff --git a/golibs/commander/commander.go b/golibs/commander/commander.go index c639cf9..a21de1c 100644 --- a/golibs/commander/commander.go +++ b/golibs/commander/commander.go @@ -22,7 +22,7 @@ The `sinks` parameter is a table with 3 keys: `in`, `out`, and `err`. The values of these is a @Sink. - `in` is the standard input. You can read from this sink -to get user input. (**This is currently unimplemented.**) +to get user input. - `out` is standard output. This is usually where text meant for output should go. - `err` is standard error. This sink is for writing errors, as the diff --git a/nature/commands/doc.lua b/nature/commands/doc.lua index ee1e37c..fc12a4f 100644 --- a/nature/commands/doc.lua +++ b/nature/commands/doc.lua @@ -89,7 +89,7 @@ Available sections: ]] .. table.concat(modules, ', ') local size = terminal.size() self.region = { width = size.width, - height = size.height - 3 + height = size.height - 2 } end gh:resize() @@ -102,7 +102,8 @@ Available sections: ]] .. table.concat(modules, ', ') workingPage = self.specialPage end - self.sink:write(ansikit.getCSI(self.region.height + 2 .. ';1', 'H')) + self.sink:write(ansikit.getCSI(self.region.height + 1 .. ';1', 'H')) + self.sink:write(ansikit.getCSI(0, 'J')) if not self.isSpecial then if args[1] == 'api' then self.sink:writeln(lunacolors.reset(string.format('%s', workingPage.title))) diff --git a/website/config.toml b/website/config.toml index 31f42d5..0ae7ff2 100644 --- a/website/config.toml +++ b/website/config.toml @@ -29,6 +29,9 @@ enableGitInfo = true [markup.goldmark.renderer] unsafe = true +[markup.highlight] +style = 'pastie' + [author] [author.sammyette] name = 'sammyette' diff --git a/website/content/docs b/website/content/docs new file mode 120000 index 0000000..92a7f82 --- /dev/null +++ b/website/content/docs @@ -0,0 +1 @@ +../../docs \ No newline at end of file diff --git a/website/content/docs/api b/website/content/docs/api deleted file mode 120000 index 1c5c360..0000000 --- a/website/content/docs/api +++ /dev/null @@ -1 +0,0 @@ -../../../docs/api/ \ No newline at end of file diff --git a/website/themes/hsh/assets/css/syntax.css b/website/themes/hsh/assets/css/syntax.css new file mode 100644 index 0000000..021dcb3 --- /dev/null +++ b/website/themes/hsh/assets/css/syntax.css @@ -0,0 +1,85 @@ +/* Background */ .bg { background-color: #edfdff; } +/* PreWrapper */ .chroma { background-color: #edfdff; } +/* Other */ .chroma .x { } +/* Error */ .chroma .err { color: #a61717; background-color: #e3d2d2 } +/* CodeLine */ .chroma .cl { } +/* LineTableTD */ .chroma .lntd { vertical-align: top; padding: 0; margin: 0; border: 0; } +/* LineTable */ .chroma .lntable { border-spacing: 0; padding: 0; margin: 0; border: 0; } +/* LineHighlight */ .chroma .hl { background-color: #edfdff } +/* LineNumbersTable */ .chroma .lnt { white-space: pre; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f } +/* LineNumbers */ .chroma .ln { white-space: pre; user-select: none; margin-right: 0.4em; padding: 0 0.4em 0 0.4em;color: #7f7f7f } +/* Line */ .chroma .line { display: flex; } +/* Keyword */ .chroma .k { color: #008800; font-weight: bold } +/* KeywordConstant */ .chroma .kc { color: #008800; font-weight: bold } +/* KeywordDeclaration */ .chroma .kd { color: #008800; font-weight: bold } +/* KeywordNamespace */ .chroma .kn { color: #008800; font-weight: bold } +/* KeywordPseudo */ .chroma .kp { color: #008800 } +/* KeywordReserved */ .chroma .kr { color: #008800; font-weight: bold } +/* KeywordType */ .chroma .kt { color: #888888; font-weight: bold } +/* Name */ .chroma .n { } +/* NameAttribute */ .chroma .na { color: #336699 } +/* NameBuiltin */ .chroma .nb { color: #003388 } +/* NameBuiltinPseudo */ .chroma .bp { } +/* NameClass */ .chroma .nc { color: #bb0066; font-weight: bold } +/* NameConstant */ .chroma .no { color: #003366; font-weight: bold } +/* NameDecorator */ .chroma .nd { color: #555555 } +/* NameEntity */ .chroma .ni { } +/* NameException */ .chroma .ne { color: #bb0066; font-weight: bold } +/* NameFunction */ .chroma .nf { color: #0066bb; font-weight: bold } +/* NameFunctionMagic */ .chroma .fm { } +/* NameLabel */ .chroma .nl { color: #336699; font-style: italic } +/* NameNamespace */ .chroma .nn { color: #bb0066; font-weight: bold } +/* NameOther */ .chroma .nx { } +/* NameProperty */ .chroma .py { color: #336699; font-weight: bold } +/* NameTag */ .chroma .nt { color: #bb0066; font-weight: bold } +/* NameVariable */ .chroma .nv { color: #336699 } +/* NameVariableClass */ .chroma .vc { color: #336699 } +/* NameVariableGlobal */ .chroma .vg { color: #dd7700 } +/* NameVariableInstance */ .chroma .vi { color: #3333bb } +/* NameVariableMagic */ .chroma .vm { } +/* Literal */ .chroma .l { } +/* LiteralDate */ .chroma .ld { } +/* LiteralString */ .chroma .s { color: #dd2200; background-color: #fff0f0 } +/* LiteralStringAffix */ .chroma .sa { color: #dd2200; background-color: #fff0f0 } +/* LiteralStringBacktick */ .chroma .sb { color: #dd2200; background-color: #fff0f0 } +/* LiteralStringChar */ .chroma .sc { color: #dd2200; background-color: #fff0f0 } +/* LiteralStringDelimiter */ .chroma .dl { color: #dd2200; background-color: #fff0f0 } +/* LiteralStringDoc */ .chroma .sd { color: #dd2200; background-color: #fff0f0 } +/* LiteralStringDouble */ .chroma .s2 { color: #dd2200; background-color: #fff0f0 } +/* LiteralStringEscape */ .chroma .se { color: #0044dd; background-color: #fff0f0 } +/* LiteralStringHeredoc */ .chroma .sh { color: #dd2200; background-color: #fff0f0 } +/* LiteralStringInterpol */ .chroma .si { color: #3333bb; background-color: #fff0f0 } +/* LiteralStringOther */ .chroma .sx { color: #22bb22; background-color: #f0fff0 } +/* LiteralStringRegex */ .chroma .sr { color: #008800; background-color: #fff0ff } +/* LiteralStringSingle */ .chroma .s1 { color: #dd2200; background-color: #fff0f0 } +/* LiteralStringSymbol */ .chroma .ss { color: #aa6600; background-color: #fff0f0 } +/* LiteralNumber */ .chroma .m { color: #0000dd; font-weight: bold } +/* LiteralNumberBin */ .chroma .mb { color: #0000dd; font-weight: bold } +/* LiteralNumberFloat */ .chroma .mf { color: #0000dd; font-weight: bold } +/* LiteralNumberHex */ .chroma .mh { color: #0000dd; font-weight: bold } +/* LiteralNumberInteger */ .chroma .mi { color: #0000dd; font-weight: bold } +/* LiteralNumberIntegerLong */ .chroma .il { color: #0000dd; font-weight: bold } +/* LiteralNumberOct */ .chroma .mo { color: #0000dd; font-weight: bold } +/* Operator */ .chroma .o { } +/* OperatorWord */ .chroma .ow { color: #008800 } +/* Punctuation */ .chroma .p { } +/* Comment */ .chroma .c { color: #888888 } +/* CommentHashbang */ .chroma .ch { color: #888888 } +/* CommentMultiline */ .chroma .cm { color: #888888 } +/* CommentSingle */ .chroma .c1 { color: #888888 } +/* CommentSpecial */ .chroma .cs { color: #cc0000; background-color: #fff0f0; font-weight: bold } +/* CommentPreproc */ .chroma .cp { color: #cc0000; font-weight: bold } +/* CommentPreprocFile */ .chroma .cpf { color: #cc0000; font-weight: bold } +/* Generic */ .chroma .g { } +/* GenericDeleted */ .chroma .gd { color: #000000; background-color: #ffdddd } +/* GenericEmph */ .chroma .ge { font-style: italic } +/* GenericError */ .chroma .gr { color: #aa0000 } +/* GenericHeading */ .chroma .gh { color: #333333 } +/* GenericInserted */ .chroma .gi { color: #000000; background-color: #ddffdd } +/* GenericOutput */ .chroma .go { color: #888888 } +/* GenericPrompt */ .chroma .gp { color: #555555 } +/* GenericStrong */ .chroma .gs { font-weight: bold } +/* GenericSubheading */ .chroma .gu { color: #666666 } +/* GenericTraceback */ .chroma .gt { color: #aa0000 } +/* GenericUnderline */ .chroma .gl { text-decoration: underline } +/* TextWhitespace */ .chroma .w { color: #bbbbbb } diff --git a/website/themes/hsh/layouts/partials/head.html b/website/themes/hsh/layouts/partials/head.html index fca4558..6109fb5 100644 --- a/website/themes/hsh/layouts/partials/head.html +++ b/website/themes/hsh/layouts/partials/head.html @@ -23,7 +23,10 @@ + {{ $syntax := resources.Get "css/syntax.css" | resources.Minify | resources.Fingerprint }} + +