aboutsummaryrefslogtreecommitdiff
path: root/lua
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-08-08 13:08:44 +0530
committerAkshay Nair <phenax5@gmail.com>2025-08-08 13:08:44 +0530
commit8ec50e55a45af1706d40eff292db4541b6fcc261 (patch)
tree6b4cb54d638765cc0c3178984a6ec18af4a3a7e4 /lua
parentb955a603c27ffb3869901b1899303b936816afcf (diff)
downloadnull-browser-8ec50e55a45af1706d40eff292db4541b6fcc261.tar.gz
null-browser-8ec50e55a45af1706d40eff292db4541b6fcc261.zip
Embed docs as null://docs + web.help api
Diffstat (limited to 'lua')
-rw-r--r--lua/null-browser/api.lua27
1 files changed, 27 insertions, 0 deletions
diff --git a/lua/null-browser/api.lua b/lua/null-browser/api.lua
index 4054895..4da1124 100644
--- a/lua/null-browser/api.lua
+++ b/lua/null-browser/api.lua
@@ -12,6 +12,7 @@ web.view = web.view or {}
web.history = web.history or {}
web.event = web.event or {}
web.decorations = web.decorations or {}
+web.help = web.help or {}
require 'null-browser.utils'
@@ -357,3 +358,29 @@ web.decorations.top = create_decoration_api('top')
web.decorations.bottom = create_decoration_api('bottom')
web.decorations.left = create_decoration_api('left')
web.decorations.right = create_decoration_api('right')
+
+--- Get a list of items for help
+function web.help.get_items()
+ -- TODO: Use proper path from build
+ local file, _ = io.open('./doc/symbols.json', 'r')
+ if file then
+ local contents, _ = file:read('a')
+ return web.json.decode(contents)
+ end
+ return {}
+end
+
+--- Open help docs for a given item
+---
+--- @param item string?
+--- @param opts table?
+--- @param opts.view number?
+function web.help.show(item, opts)
+ opts = opts or {}
+ local url = 'null://docs/api#' .. (item or '')
+ if opts.view ~= nil then
+ web.view.set_url(url, opts.view)
+ else
+ web.view.create(url)
+ end
+end