diff --git a/doc/aerial.txt b/doc/aerial.txt index e51e4b4..890c376 100644 --- a/doc/aerial.txt +++ b/doc/aerial.txt @@ -452,10 +452,11 @@ open({opts}) *aerial.ope Open the aerial window for the current buffer. Parameters: - {opts} `nil|table` - {focus} `boolean` If true, jump to aerial window if it is opened - (default true) - {direction} `"left"|"right"|"float"` Direction to open aerial window + {opts} `nil|aerial.openOpts` + {focus} `nil|boolean` If true, jump to aerial window if it is + opened (default true) + {direction} `nil|"left"|"right"|"float"` Direction to open aerial + window open_in_win({target_win}, {source_win}) *aerial.open_in_win* Open aerial in an existing window @@ -479,10 +480,11 @@ toggle({opts}) *aerial.toggl Open or close the aerial window for the current buffer. Parameters: - {opts} `nil|table` - {focus} `boolean` If true, jump to aerial window if it is opened - (default true) - {direction} `"left"|"right"|"float"` Direction to open aerial window + {opts} `nil|aerial.openOpts` + {focus} `nil|boolean` If true, jump to aerial window if it is + opened (default true) + {direction} `nil|"left"|"right"|"float"` Direction to open aerial + window refetch_symbols({bufnr}) *aerial.refetch_symbols* Refresh the symbols for a buffer @@ -498,7 +500,7 @@ select({opts}) *aerial.selec Jump to a specific symbol. Parameters: - {opts} `nil|table` + {opts} `nil|aerial.selectOpts` {index} `nil|integer` The symbol to jump to. If nil, will jump to the symbol under the cursor (in the aerial buffer) {split} `nil|string` Jump to the symbol in a new split. Can be "v" for diff --git a/doc/api.md b/doc/api.md index e29f2a0..7c7451c 100644 --- a/doc/api.md +++ b/doc/api.md @@ -91,11 +91,11 @@ Close all visible aerial windows except for the one currently focused or for the `open(opts)` \ Open the aerial window for the current buffer. -| Param | Type | Desc | | -| ----- | ------------ | -------------------------- | ------------------------------------------------------------- | -| opts | `nil\|table` | | | -| | focus | `boolean` | If true, jump to aerial window if it is opened (default true) | -| | direction | `"left"\|"right"\|"float"` | Direction to open aerial window | +| Param | Type | Desc | | +| ----- | ---------------------- | ------------------------------- | ------------------------------------------------------------- | +| opts | `nil\|aerial.openOpts` | | | +| | focus | `nil\|boolean` | If true, jump to aerial window if it is opened (default true) | +| | direction | `nil\|"left"\|"right"\|"float"` | Direction to open aerial window | ## open_in_win(target_win, source_win) @@ -129,11 +129,11 @@ Jump to the aerial window for the current buffer, if it is open `toggle(opts)` \ Open or close the aerial window for the current buffer. -| Param | Type | Desc | | -| ----- | ------------ | -------------------------- | ------------------------------------------------------------- | -| opts | `nil\|table` | | | -| | focus | `boolean` | If true, jump to aerial window if it is opened (default true) | -| | direction | `"left"\|"right"\|"float"` | Direction to open aerial window | +| Param | Type | Desc | | +| ----- | ---------------------- | ------------------------------- | ------------------------------------------------------------- | +| opts | `nil\|aerial.openOpts` | | | +| | focus | `nil\|boolean` | If true, jump to aerial window if it is opened (default true) | +| | direction | `nil\|"left"\|"right"\|"float"` | Direction to open aerial window | ## refetch_symbols(bufnr) @@ -155,12 +155,12 @@ call this if you change something in the config (e.g. by setting vim.b.aerial_ba `select(opts)` \ Jump to a specific symbol. -| Param | Type | Desc | | -| ----- | ------------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | -| opts | `nil\|table` | | | -| | index | `nil\|integer` | The symbol to jump to. If nil, will jump to the symbol under the cursor (in the aerial buffer) | -| | split | `nil\|string` | Jump to the symbol in a new split. Can be "v" for vertical or "h" for horizontal. Can also be a raw command to execute (e.g. "belowright split") | -| | jump | `nil\|boolean` | If false and in the aerial window, do not leave the aerial window. (Default true) | +| Param | Type | Desc | | +| ----- | ------------------------ | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | +| opts | `nil\|aerial.selectOpts` | | | +| | index | `nil\|integer` | The symbol to jump to. If nil, will jump to the symbol under the cursor (in the aerial buffer) | +| | split | `nil\|string` | Jump to the symbol in a new split. Can be "v" for vertical or "h" for horizontal. Can also be a raw command to execute (e.g. "belowright split") | +| | jump | `nil\|boolean` | If false and in the aerial window, do not leave the aerial window. (Default true) | ## next(step) diff --git a/lua/aerial/init.lua b/lua/aerial/init.lua index 8508602..39a1026 100644 --- a/lua/aerial/init.lua +++ b/lua/aerial/init.lua @@ -261,10 +261,12 @@ M.close_all = lazy("window", "close_all") ---Close all visible aerial windows except for the one currently focused or for the currently focused window. M.close_all_but_current = lazy("window", "close_all_but_current") +---@class (exact) aerial.openOpts +---@field focus? boolean If true, jump to aerial window if it is opened (default true) +---@field direction? "left"|"right"|"float" Direction to open aerial window + ---Open the aerial window for the current buffer. ----@param opts? table ---- focus boolean If true, jump to aerial window if it is opened (default true) ---- direction "left"|"right"|"float" Direction to open aerial window +---@param opts? aerial.openOpts M.open = function(opts) do_setup() was_closed = false @@ -293,9 +295,7 @@ M.open_all = lazy("window", "open_all") M.focus = lazy("window", "focus") ---Open or close the aerial window for the current buffer. ----@param opts? table ---- focus boolean If true, jump to aerial window if it is opened (default true) ---- direction "left"|"right"|"float" Direction to open aerial window +---@param opts? aerial.openOpts M.toggle = function(opts) do_setup() opts = vim.tbl_extend("keep", opts or {}, { @@ -327,11 +327,13 @@ M.refetch_symbols = function(bufnr) end end +---@class (exact) aerial.selectOpts +---@field index? integer The symbol to jump to. If nil, will jump to the symbol under the cursor (in the aerial buffer) +---@field split? string Jump to the symbol in a new split. Can be "v" for vertical or "h" for horizontal. Can also be a raw command to execute (e.g. "belowright split") +---@field jump? boolean If false and in the aerial window, do not leave the aerial window. (Default true) + ---Jump to a specific symbol. ----@param opts? table ---- index? integer The symbol to jump to. If nil, will jump to the symbol under the cursor (in the aerial buffer) ---- split? string Jump to the symbol in a new split. Can be "v" for vertical or "h" for horizontal. Can also be a raw command to execute (e.g. "belowright split") ---- jump? boolean If false and in the aerial window, do not leave the aerial window. (Default true) +---@param opts? aerial.selectOpts M.select = lazy("navigation", "select", true) ---Jump forwards in the symbol list. diff --git a/scripts/generate.py b/scripts/generate.py index 1b0b73c..98c0679 100755 --- a/scripts/generate.py +++ b/scripts/generate.py @@ -13,11 +13,11 @@ from nvim_doc_tools import ( format_vimdoc_commands, generate_md_toc, indent, - parse_functions, + parse_directory, read_nvim_json, read_section, - render_md_api, - render_vimdoc_api, + render_md_api2, + render_vimdoc_api2, replace_section, ) @@ -61,8 +61,9 @@ def add_md_link_path(path: str, lines: List[str]) -> List[str]: def update_md_api(): - funcs = parse_functions(os.path.join(ROOT, "lua", "aerial", "init.lua")) - lines = ["\n"] + render_md_api(funcs, 2) + ["\n"] + types = parse_directory(os.path.join(ROOT, "lua")) + funcs = types.files["aerial/init.lua"].functions + lines = ["\n"] + render_md_api2(funcs, types, 2) + ["\n"] api_doc = os.path.join(DOC, "api.md") replace_section( api_doc, @@ -138,12 +139,15 @@ def get_notes_vimdoc() -> "VimdocSection": def generate_vimdoc(): doc = Vimdoc("aerial.txt", "aerial") - funcs = parse_functions(os.path.join(ROOT, "lua", "aerial", "init.lua")) + types = parse_directory(os.path.join(ROOT, "lua")) + funcs = types.files["aerial/init.lua"].functions doc.sections.extend( [ get_options_vimdoc(), get_commands_vimdoc(), - VimdocSection("API", "aerial-api", render_vimdoc_api("aerial", funcs)), + VimdocSection( + "API", "aerial-api", render_vimdoc_api2("aerial", funcs, types) + ), get_notes_vimdoc(), ] )