Skip to content

Commit

Permalink
docs(wiki): add command section
Browse files Browse the repository at this point in the history
  • Loading branch information
saecki committed Jan 13, 2024
1 parent ab6634b commit fca3aa8
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
27 changes: 27 additions & 0 deletions docgen/gen_doc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,31 @@ local function gen_markdown_functions(lines)
file:close()
end

local function gen_markdown_subcommands(lines)
local file = io.open("teal/crates/command.tl", "r")
local line_iter = file:lines("*l")
for l in line_iter do
if l:match("^local sub_commands:") then
break
end
end

for l in line_iter do
if l == "}" then
break
end
if l ~= "" then
local pat = "^%s*{%s*\"([^\"]+)\"%s*,%s*[^%s]+%s*},$"
local name = l:match(pat)
if name then
local doc_ref = string.format(" - `%s()`", name)
table.insert(lines, doc_ref)
end
end
end
file:close()
end

local function format_vimdoc_params(params)
local text = {}
for p, t in params:gmatch("[,]?([^:]+):%s*([^,]+)[,]?") do
Expand Down Expand Up @@ -337,6 +362,8 @@ local function gen_markdown(inpath, outpath)
gen_def_config(lines, 1, {}, config.schema)
elseif ph == "FUNCTIONS" then
gen_markdown_functions(lines)
elseif ph == "SUBCOMMANDS" then
gen_markdown_subcommands(lines)
else
gen_from_shared_file(lines, indent, ph)
end
Expand Down
9 changes: 9 additions & 0 deletions docgen/templates/documentation.md.in
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,15 @@ require("crates").setup {
<SHARED:FUNCTIONS>
```

## Command
```vim
:Crates <subcmd>
```
Run a crates.nvim `<subcmd>`. All `<subcmd>`s are just wrappers around the
corresponding functions. These are the functions available as commands:

<SHARED:SUBCOMMANDS>

## Key mappings
Some examples of key mappings.
```lua
Expand Down
32 changes: 32 additions & 0 deletions docgen/wiki/Unstable-documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,38 @@ require("crates").focus_popup(line: integer|nil)
require("crates").hide_popup()
```

## Command
```vim
:Crates <subcmd>
```
Run a crates.nvim `<subcmd>`. All `<subcmd>`s are just wrappers around the
corresponding functions. These are the functions available as commands:
- `hide()`
- `show()`
- `toggle()`
- `update()`
- `reload()`
- `upgrade_crate()`
- `upgrade_crates()`
- `upgrade_all_crates()`
- `update_crate()`
- `update_crates()`
- `update_all_crates()`
- `expand_plain_crate_to_inline_table()`
- `extract_crate_into_table()`
- `open_homepage()`
- `open_repository()`
- `open_documentation()`
- `open_cratesio()`
- `popup_available()`
- `show_popup()`
- `show_crate_popup()`
- `show_versions_popup()`
- `show_features_popup()`
- `show_dependencies_popup()`
- `focus_popup()`
- `hide_popup()`

## Key mappings
Some examples of key mappings.
```lua
Expand Down

0 comments on commit fca3aa8

Please sign in to comment.