Skip to content

Commit

Permalink
docs(vimdoc): add command section
Browse files Browse the repository at this point in the history
  • Loading branch information
saecki committed Jan 13, 2024
1 parent a8ab14c commit ab6634b
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ For example
```
<SHARED:DEFAULT_CONFIGURATION>
```
would be replaced by the generated default configuration, but
would be replaced by the generated default configuration, but
```
<SHARED:keymaps.lua>
```
Expand Down
35 changes: 35 additions & 0 deletions doc/crates.txt
Original file line number Diff line number Diff line change
Expand Up @@ -453,6 +453,41 @@ hide_popup() *crates.hide_popup()*
Hide the popup.


==============================================================================
COMMAND *crates-command*

:Crates {subcmd}

Run a crates.nvim {subcmd}. All {subcmd}s are just wrappers around the
corresponding |crates-functions|. These are the functions available as
commands:

- |crates.hide()|
- |crates.show()|
- |crates.toggle()|
- |crates.update()|
- |crates.reload()|
- |crates.upgrade_crate()|
- |crates.upgrade_crates()|
- |crates.upgrade_all_crates()|
- |crates.update_crate()|
- |crates.update_crates()|
- |crates.update_all_crates()|
- |crates.expand_plain_crate_to_inline_table()|
- |crates.extract_crate_into_table()|
- |crates.open_homepage()|
- |crates.open_repository()|
- |crates.open_documentation()|
- |crates.open_cratesio()|
- |crates.popup_available()|
- |crates.show_popup()|
- |crates.show_crate_popup()|
- |crates.show_versions_popup()|
- |crates.show_features_popup()|
- |crates.show_dependencies_popup()|
- |crates.focus_popup()|
- |crates.hide_popup()|

==============================================================================
CONFIGURATION *crates-config*

Expand Down
27 changes: 27 additions & 0 deletions docgen/gen_doc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,31 @@ local function gen_vimdoc_functions(lines)
file:close()
end

local function gen_vimdoc_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(" - |crates.%s()|", name)
table.insert(lines, doc_ref)
end
end
end
file:close()
end

local function gen_vimdoc_highlights(lines)
for _, value in ipairs(highlight.highlights) do
local name = value[1]
Expand Down Expand Up @@ -279,6 +304,8 @@ local function gen_vim_doc()
gen_def_config(lines, 2, {}, config.schema)
elseif ph == "FUNCTIONS" then
gen_vimdoc_functions(lines)
elseif ph == "SUBCOMMANDS" then
gen_vimdoc_subcommands(lines)
elseif ph == "CONFIGURATION" then
gen_vimdoc_config(lines, {}, config.schema)
elseif ph == "HIGHLIGHTS" then
Expand Down
11 changes: 11 additions & 0 deletions docgen/templates/crates.txt.in
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ They can be accessed like this.
<

<SHARED:FUNCTIONS>
==============================================================================
COMMAND *crates-command*

:Crates {subcmd}

Run a crates.nvim {subcmd}. All {subcmd}s are just wrappers around the
corresponding |crates-functions|. These are the functions available as
commands:

<SHARED:SUBCOMMANDS>

==============================================================================
CONFIGURATION *crates-config*

Expand Down
4 changes: 2 additions & 2 deletions lua/crates/command.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ local sub_commands = {
{ "update_crates", actions.update_crates },
{ "update_all_crates", actions.update_all_crates },

{ "expand_to_inline_table", actions.expand_plain_crate_to_inline_table },
{ "extract_into_table", actions.extract_crate_into_table },
{ "expand_plain_crate_to_inline_table", actions.expand_plain_crate_to_inline_table },
{ "extract_crate_into_table", actions.extract_crate_into_table },

{ "open_homepage", actions.open_homepage },
{ "open_repository", actions.open_repository },
Expand Down
4 changes: 2 additions & 2 deletions teal/crates/command.tl
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ local sub_commands: {{string,function}} = {
{ "update_crates", actions.update_crates },
{ "update_all_crates", actions.update_all_crates },

{ "expand_to_inline_table", actions.expand_plain_crate_to_inline_table },
{ "extract_into_table", actions.extract_crate_into_table },
{ "expand_plain_crate_to_inline_table", actions.expand_plain_crate_to_inline_table },
{ "extract_crate_into_table", actions.extract_crate_into_table },

{ "open_homepage", actions.open_homepage },
{ "open_repository", actions.open_repository },
Expand Down

0 comments on commit ab6634b

Please sign in to comment.