diff --git a/docgen/gen_doc.lua b/docgen/gen_doc.lua index 24497593..fe63a5f6 100755 --- a/docgen/gen_doc.lua +++ b/docgen/gen_doc.lua @@ -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 @@ -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 diff --git a/docgen/templates/documentation.md.in b/docgen/templates/documentation.md.in index cc1c7796..70b0dbaf 100644 --- a/docgen/templates/documentation.md.in +++ b/docgen/templates/documentation.md.in @@ -127,6 +127,15 @@ require("crates").setup { ``` +## Command +```vim +:Crates +``` +Run a crates.nvim ``. All ``s are just wrappers around the +corresponding functions. These are the functions available as commands: + + + ## Key mappings Some examples of key mappings. ```lua diff --git a/docgen/wiki/Unstable-documentation.md b/docgen/wiki/Unstable-documentation.md index 668cf710..44b7f607 100644 --- a/docgen/wiki/Unstable-documentation.md +++ b/docgen/wiki/Unstable-documentation.md @@ -388,6 +388,38 @@ require("crates").focus_popup(line: integer|nil) require("crates").hide_popup() ``` +## Command +```vim +:Crates +``` +Run a crates.nvim ``. All ``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