diff --git a/api.go b/api.go index 500cbcc..93e29d0 100644 --- a/api.go +++ b/api.go @@ -403,7 +403,7 @@ hilbish.appendPath '~/go/bin' -- Will add ~/go/bin to the command path. -- Or do multiple: -hilbush.appendPath { +hilbish.appendPath { '~/go/bin', '~/.local/bin' } diff --git a/cmd/docgen/docgen.go b/cmd/docgen/docgen.go index 4d09b82..537c39e 100644 --- a/cmd/docgen/docgen.go +++ b/cmd/docgen/docgen.go @@ -533,7 +533,7 @@ func main() { if dps.IsMember { continue } - f.WriteString(fmt.Sprintf("
", dps.FuncName)) + f.WriteString(fmt.Sprintf("
\n
", dps.FuncName)) htmlSig := typeTag.ReplaceAllStringFunc(strings.Replace(modname + "." + dps.FuncSig, "<", `\<`, -1), func(typ string) string { typName := typ[1:] typLookup := typeTable[strings.ToLower(typName)] diff --git a/docs/api/bait.md b/docs/api/bait.md index b33441c..62e1493 100644 --- a/docs/api/bait.md +++ b/docs/api/bait.md @@ -41,7 +41,8 @@ this function will set the user prompt. |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) @@ -67,7 +68,8 @@ end) ```

-
+
+
-
+
+
-
+
+
-
+
+

bait.throw(name, ...args) diff --git a/docs/api/commander.md b/docs/api/commander.md index 66e77e6..b4180cc 100644 --- a/docs/api/commander.md +++ b/docs/api/commander.md @@ -42,7 +42,8 @@ This sink is for writing errors, as the name would suggest. |deregister(name)|Removes the named command. Note that this will only remove Commander-registered commands.| |register(name, cb)|Adds a new command with the given `name`. When Hilbish has to run a command with a name,| -
+
+ -
+
+

commander.register(name, cb) diff --git a/docs/api/fs.md b/docs/api/fs.md index dec25ee..8addc78 100644 --- a/docs/api/fs.md +++ b/docs/api/fs.md @@ -31,7 +31,8 @@ library offers more functions and will work on any operating system Hilbish does |----|----| |pathSep|The operating system's path separator.| -
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+
-
+
+

fs.stat(path) -> {} diff --git a/docs/api/hilbish/_index.md b/docs/api/hilbish/_index.md index 5e8cff3..ff89f63 100644 --- a/docs/api/hilbish/_index.md +++ b/docs/api/hilbish/_index.md @@ -46,7 +46,8 @@ interfaces and functions which directly relate to shell functionality. |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.which(name) -> string diff --git a/docs/api/hilbish/hilbish.aliases.md b/docs/api/hilbish/hilbish.aliases.md index 652d22f..3e74a3b 100644 --- a/docs/api/hilbish/hilbish.aliases.md +++ b/docs/api/hilbish/hilbish.aliases.md @@ -18,7 +18,8 @@ The alias interface deals with all command aliases in Hilbish. |list() -> table[string, string]|Get a table of all aliases, with string keys as the alias and the value as the command.| |resolve(alias) -> string?|Resolves an alias to its original command. Will thrown an error if the alias doesn't exist.| -
+
+ -
+
+
-
+
+
-
+
+

hilbish.aliases.resolve(alias) -> string? diff --git a/docs/api/hilbish/hilbish.completion.md b/docs/api/hilbish/hilbish.completion.md index c151032..46fde24 100644 --- a/docs/api/hilbish/hilbish.completion.md +++ b/docs/api/hilbish/hilbish.completion.md @@ -18,7 +18,8 @@ The completions interface deals with tab completions. |files(query, ctx, fields) -> entries (table), prefix (string)|Returns file matches based on the provided parameters.| |handler(line, pos)|This function contains the general completion handler for Hilbish. This function handles| -
+
+

hilbish.completion.bins(query, ctx, fields) -> entries (table), prefix (string) @@ -60,7 +61,8 @@ end) ```

-
+
+
-
+
+
-
+
+

hilbish.completion.handler(line, pos) diff --git a/docs/api/hilbish/hilbish.editor.md b/docs/api/hilbish/hilbish.editor.md index 040ca85..5e59ec3 100644 --- a/docs/api/hilbish/hilbish.editor.md +++ b/docs/api/hilbish/hilbish.editor.md @@ -20,7 +20,8 @@ directly interact with the line editor in use. |getChar() -> string|Reads a keystroke from the user. This is in a format of something like Ctrl-L.| |setVimRegister(register, text)|Sets the vim register at `register` to hold the passed text.| -
+
+ -
+
+
-
+
+
-
+
+
-
+
+

hilbish.editor.setVimRegister(register, text) diff --git a/docs/api/hilbish/hilbish.history.md b/docs/api/hilbish/hilbish.history.md index bc1efb0..301ef2b 100644 --- a/docs/api/hilbish/hilbish.history.md +++ b/docs/api/hilbish/hilbish.history.md @@ -21,7 +21,8 @@ method of saving history. |get(index)|Retrieves a command from the history based on the `index`.| |size() -> number|Returns the amount of commands in the history.| -
+
+ -
+
+
-
+
+
-
+
+
-
+
+

hilbish.history.size() -> number diff --git a/docs/api/hilbish/hilbish.jobs.md b/docs/api/hilbish/hilbish.jobs.md index 3a645fa..0ff4db9 100644 --- a/docs/api/hilbish/hilbish.jobs.md +++ b/docs/api/hilbish/hilbish.jobs.md @@ -23,7 +23,8 @@ interactive usage or with the functions defined below for use in external runner |get(id) -> @Job|Get a job object via its ID.| |last() -> @Job|Returns the last added job to the table.| -
+
+ -
+
+
-
+
+
-
+
+
-
+
+

hilbish.jobs.last() -> Job diff --git a/docs/api/hilbish/hilbish.module.md b/docs/api/hilbish/hilbish.module.md index 3363ca7..cfe3920 100644 --- a/docs/api/hilbish/hilbish.module.md +++ b/docs/api/hilbish/hilbish.module.md @@ -53,7 +53,8 @@ If you attempt to require and print the result (`print(require 'plugin')`), it w |----|----| |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) diff --git a/docs/api/hilbish/hilbish.runner.md b/docs/api/hilbish/hilbish.runner.md index c3134ae..56eb030 100644 --- a/docs/api/hilbish/hilbish.runner.md +++ b/docs/api/hilbish/hilbish.runner.md @@ -21,7 +21,8 @@ write command in Fennel. |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.sh(cmd) diff --git a/docs/api/hilbish/hilbish.timers.md b/docs/api/hilbish/hilbish.timers.md index 310c4dd..d100547 100644 --- a/docs/api/hilbish/hilbish.timers.md +++ b/docs/api/hilbish/hilbish.timers.md @@ -38,7 +38,8 @@ print(t.running) // true |INTERVAL|Constant for an interval timer type| |TIMEOUT|Constant for a timeout timer type| -
+
+
-
+
+

hilbish.timers.get(id) -> Timer diff --git a/docs/api/terminal.md b/docs/api/terminal.md index 19eb0eb..a5ecde8 100644 --- a/docs/api/terminal.md +++ b/docs/api/terminal.md @@ -18,7 +18,8 @@ The terminal library is a simple and lower level library for certain terminal in |setRaw()|Puts the terminal into raw mode.| |size()|Gets the dimensions of the terminal. Returns a table with `width` and `height`| -
+
+ -
+
+
-
+
+
-
+
+

terminal.size() diff --git a/nature/commands/doc.lua b/nature/commands/doc.lua index 862c3eb..8981450 100644 --- a/nature/commands/doc.lua +++ b/nature/commands/doc.lua @@ -6,6 +6,22 @@ local Greenhouse = require 'nature.greenhouse' local Page = require 'nature.greenhouse.page' local docfuncs = require 'nature.doc' +local function strip(text, ...) + for _, pat in ipairs {...} do + text = text:gsub(pat, '\b') + end + + return text +end + +local function transformHTMLandMD(text) + return strip(text, '|||', '|%-%-%-%-|%-%-%-%-|') + :gsub('|(.-)|(.-)|', function(entry1, entry2) + return string.format('%s - %s', entry1, entry2) + end) + :gsub('
', '{separator}') +end + commander.register('doc', function(args, sinks) local moddocPath = hilbish.dataDir .. '/docs/' local stat = pcall(fs.stat, '.git/refs/heads/extended-job-api') @@ -117,7 +133,7 @@ Available sections: ]] .. table.concat(modules, ', ') end local backtickOccurence = 0 local function formatDocText(d) - return d:gsub('```(%w+)\n(.-)```', function(lang, text) + return transformHTMLandMD(d):gsub('```(%w+)\n(.-)```', function(lang, text) return docfuncs.renderCodeBlock(text) end) --[[ diff --git a/nature/doc.lua b/nature/doc.lua index 84b3d24..872f18f 100644 --- a/nature/doc.lua +++ b/nature/doc.lua @@ -17,8 +17,8 @@ function M.renderCodeBlock(text) end for i, line in ipairs(lines) do - lines[i] = M.highlight(line:sub(0, longest)) - .. string.rep(' ', longest - line:len()) + lines[i] = ' ' .. M.highlight(line:sub(0, longest)) + .. string.rep(' ', longest - line:len()) .. ' ' end return '\n' .. lunacolors.format('{greyBg}' .. table.concat(lines, '\n')) .. '\n' diff --git a/nature/greenhouse/init.lua b/nature/greenhouse/init.lua index e3cac13..2ea8e00 100644 --- a/nature/greenhouse/init.lua +++ b/nature/greenhouse/init.lua @@ -21,6 +21,7 @@ function Greenhouse:new(sink) self.sink = sink self.pages = {} self.curPage = 1 + self.separator = '─' self.keybinds = { ['Up'] = function(self) self:scroll 'up' end, ['Down'] = function(self) self:scroll 'down' end, @@ -63,7 +64,8 @@ local function sub(str, limit) :gsub('\x1b%[%d+;%d+%w', addOverhead) :gsub('\x1b%[%d+%w', addOverhead) - return s:sub(0, limit + overhead) + return s:sub(0, utf8.offset(str, limit + overhead) or limit + overhead) + --return s:sub(0, limit + overhead) end function Greenhouse:draw() @@ -88,7 +90,8 @@ function Greenhouse:draw() if i == offset + self.region.height - 1 then writer = self.sink.write end - writer(self.sink, sub(lines[i]:gsub('\t', ' '), self.region.width)) + local line = lines[i]:gsub('{separator}', function() return self.separator:rep(self.region.width - 1) end) + writer(self.sink, sub(line:gsub('\t', ' '), self.region.width)) end writer(self.sink, '\27[0m') self:render()