From 9e06f1424fe2d8a4135639dd9f74fb24680ada53 Mon Sep 17 00:00:00 2001 From: James Trew Date: Thu, 1 Aug 2024 21:17:59 -0400 Subject: [PATCH] docs: adapt gendoc config --- doc/telescope-file-browser.txt | 104 +++++++++--------- .../_extensions/file_browser/actions.lua | 1 - scripts/gendocs.lua | 37 ++++--- 3 files changed, 74 insertions(+), 68 deletions(-) diff --git a/doc/telescope-file-browser.txt b/doc/telescope-file-browser.txt index 541f89f..fbb9678 100644 --- a/doc/telescope-file-browser.txt +++ b/doc/telescope-file-browser.txt @@ -1,5 +1,5 @@ ============================================================================== -_EXTENSIONS_FILE_BROWSER *telescope-file-browser._extensions_file_browser* +TELESCOPE-FILE-BROWSER.NVIM *telescope-file-browser* `telescope-file-browser.nvim` is an extension for telescope.nvim. It helps you efficiently create, delete, rename, or move files powered by navigation from @@ -64,7 +64,7 @@ Extends |telescope-file-browser.PickerOpts| implementation details By default, ============================================================================== -_EXTENSIONS_FILE_BROWSER_PICKER*telescope-file-browser._extensions_file_browser_picker* +PICKER *telescope-file-browser.picker* You can use the file browser as follows >lua vim.keymap.set( @@ -189,8 +189,8 @@ Extends |telescope.picker.opts| the file browser - *telescope-file-browser._extensions_file_browser_picker.file_browser()* -_extensions_file_browser_picker.file_browser({opts}) + *telescope-file-browser.picker.file_browser()* +fb_picker.file_browser({opts}) Create a new file browser picker. Parameters: ~ @@ -198,7 +198,7 @@ _extensions_file_browser_picker.file_browser({opts}) picker. See |telescope-file-browser.PickerOpts| ============================================================================== -_EXTENSIONS_FILE_BROWSER_ACTIONS*telescope-file-browser._extensions_file_browser_actions* +ACTIONS *telescope-file-browser.actions* The file browser actions are functions enable file system operations from within the file browser picker. In particular, the actions include creation, @@ -223,8 +223,8 @@ You can remap actions as follows: >lua } < - *telescope-file-browser._extensions_file_browser_actions.create()* -_extensions_file_browser_actions.create({prompt_bufnr}) + *telescope-file-browser.actions.create()* +fb_actions.create({prompt_bufnr}) Creates a new file or dir in the current directory of the |telescope-file-browser.picker.file_browser|. • Finder: @@ -239,8 +239,8 @@ _extensions_file_browser_actions.create({prompt_bufnr}) Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr -*telescope-file-browser._extensions_file_browser_actions.create_from_prompt()* -_extensions_file_browser_actions.create_from_prompt({prompt_bufnr}) + *telescope-file-browser.actions.create_from_prompt()* +fb_actions.create_from_prompt({prompt_bufnr}) Creates a new file or dir via prompt in the current directory of the |telescope-file-browser.picker.file_browser|. • Notes: @@ -252,8 +252,8 @@ _extensions_file_browser_actions.create_from_prompt({prompt_bufnr}) Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.rename()* -_extensions_file_browser_actions.rename({prompt_bufnr}) + *telescope-file-browser.actions.rename()* +fb_actions.rename({prompt_bufnr}) Rename files or folders for |telescope-file-browser.picker.file_browser|. Notes: @@ -265,8 +265,7 @@ _extensions_file_browser_actions.rename({prompt_bufnr}) Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.move()* -_extensions_file_browser_actions.move({prompt_bufnr}) +fb_actions.move({prompt_bufnr}) *telescope-file-browser.actions.move()* Move multi-selected files or folders to current directory in |telescope-file-browser.picker.file_browser|. • Notes: @@ -278,8 +277,7 @@ _extensions_file_browser_actions.move({prompt_bufnr}) Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.copy()* -_extensions_file_browser_actions.copy({prompt_bufnr}) +fb_actions.copy({prompt_bufnr}) *telescope-file-browser.actions.copy()* Copy file or folders recursively to current directory in |telescope-file-browser.picker.file_browser|. • Finder: @@ -291,8 +289,8 @@ _extensions_file_browser_actions.copy({prompt_bufnr}) Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.remove()* -_extensions_file_browser_actions.remove({prompt_bufnr}) + *telescope-file-browser.actions.remove()* +fb_actions.remove({prompt_bufnr}) Remove file or folders recursively for |telescope-file-browser.picker.file_browser|. @@ -301,23 +299,22 @@ _extensions_file_browser_actions.remove({prompt_bufnr}) Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.toggle_hidden()* -_extensions_file_browser_actions.toggle_hidden({prompt_bufnr}) + *telescope-file-browser.actions.toggle_hidden()* +fb_actions.toggle_hidden({prompt_bufnr}) Toggle hidden files or folders for |telescope-file-browser.picker.file_browser|. Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr -*telescope-file-browser._extensions_file_browser_actions.toggle_respect_gitignore()* -_extensions_file_browser_actions.toggle_respect_gitignore({prompt_bufnr}) + *telescope-file-browser.actions.toggle_respect_gitignore()* +fb_actions.toggle_respect_gitignore({prompt_bufnr}) Toggle respect_gitignore for |telescope-file-browser.picker.file_browser|. Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.open()* -_extensions_file_browser_actions.open() +fb_actions.open() *telescope-file-browser.actions.open()* Opens the file or folder with the default application. • Notes: • map fb_actions.open + fb_actions.close if you want to close the picker @@ -328,8 +325,8 @@ _extensions_file_browser_actions.open() • Windows: defaults to default applications through `start` @pram prompt_bufnr number: The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.goto_parent_dir()* -_extensions_file_browser_actions.goto_parent_dir({prompt_bufnr}, {bypass}) + *telescope-file-browser.actions.goto_parent_dir()* +fb_actions.goto_parent_dir({prompt_bufnr}, {bypass}) Goto parent directory in |telescope-file-browser.picker.file_browser|. Parameters: ~ @@ -337,39 +334,39 @@ _extensions_file_browser_actions.goto_parent_dir({prompt_bufnr}, {bypass}) • {bypass} (`boolean`) Allow passing beyond the globally set current working directory - *telescope-file-browser._extensions_file_browser_actions.goto_cwd()* -_extensions_file_browser_actions.goto_cwd({prompt_bufnr}) + *telescope-file-browser.actions.goto_cwd()* +fb_actions.goto_cwd({prompt_bufnr}) Goto working directory of nvim in |telescope-file-browser.picker.file_browser|. Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.change_cwd()* -_extensions_file_browser_actions.change_cwd({prompt_bufnr}) + *telescope-file-browser.actions.change_cwd()* +fb_actions.change_cwd({prompt_bufnr}) Change working directory of nvim to the selected file/folder in |telescope-file-browser.picker.file_browser|. Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.goto_home_dir()* -_extensions_file_browser_actions.goto_home_dir({prompt_bufnr}) + *telescope-file-browser.actions.goto_home_dir()* +fb_actions.goto_home_dir({prompt_bufnr}) Goto home directory in |telescope-file-browser.picker.file_browser|. Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.toggle_browser()* -_extensions_file_browser_actions.toggle_browser({prompt_bufnr}) + *telescope-file-browser.actions.toggle_browser()* +fb_actions.toggle_browser({prompt_bufnr}) Toggle between file and folder browser for |telescope-file-browser.picker.file_browser|. Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.toggle_all()* -_extensions_file_browser_actions.toggle_all({prompt_bufnr}) + *telescope-file-browser.actions.toggle_all()* +fb_actions.toggle_all({prompt_bufnr}) Toggles all selections akin to |telescope.actions.toggle_all| but ignores parent & current directory • Note: if the parent or current directory were selected, they will be @@ -378,8 +375,8 @@ _extensions_file_browser_actions.toggle_all({prompt_bufnr}) Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.select_all()* -_extensions_file_browser_actions.select_all({prompt_bufnr}) + *telescope-file-browser.actions.select_all()* +fb_actions.select_all({prompt_bufnr}) Multi select all entries akin to |telescope.actions.select_all| but ignores parent & current directory • Note: @@ -390,16 +387,16 @@ _extensions_file_browser_actions.select_all({prompt_bufnr}) Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.sort_by_size()* -_extensions_file_browser_actions.sort_by_size({prompt_bufnr}) + *telescope-file-browser.actions.sort_by_size()* +fb_actions.sort_by_size({prompt_bufnr}) Toggle sorting by size of the entry. Note: initially sorts descendingly in size. Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.sort_by_date()* -_extensions_file_browser_actions.sort_by_date({prompt_bufnr}) + *telescope-file-browser.actions.sort_by_date()* +fb_actions.sort_by_date({prompt_bufnr}) Toggle sorting by last change to the entry. Note: initially sorts desendingly from most to least recently changed entry. @@ -407,8 +404,8 @@ _extensions_file_browser_actions.sort_by_date({prompt_bufnr}) Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.backspace()* -_extensions_file_browser_actions.backspace({prompt_bufnr}, {bypass}) + *telescope-file-browser.actions.backspace()* +fb_actions.backspace({prompt_bufnr}, {bypass}) If the prompt is empty, goes up to parent dir. Otherwise, acts as normal. Parameters: ~ @@ -416,15 +413,15 @@ _extensions_file_browser_actions.backspace({prompt_bufnr}, {bypass}) • {bypass} (`boolean`) Allow passing beyond the globally set current working directory - *telescope-file-browser._extensions_file_browser_actions.path_separator()* -_extensions_file_browser_actions.path_separator({prompt_bufnr}) + *telescope-file-browser.actions.path_separator()* +fb_actions.path_separator({prompt_bufnr}) When a path separator is entered, navigate to the directory in the prompt. Parameters: ~ • {prompt_bufnr} (`number`) The prompt bufnr - *telescope-file-browser._extensions_file_browser_actions.open_dir()* -_extensions_file_browser_actions.open_dir({prompt_bufnr}, {_}, {dir}) + *telescope-file-browser.actions.open_dir()* +fb_actions.open_dir({prompt_bufnr}, {_}, {dir}) Open directory and refresh picker Parameters: ~ @@ -432,7 +429,7 @@ _extensions_file_browser_actions.open_dir({prompt_bufnr}, {_}, {dir}) • {dir} (`string?`) priority dir path ============================================================================== -_EXTENSIONS_FILE_BROWSER_FINDERS*telescope-file-browser._extensions_file_browser_finders* +FINDERS *telescope-file-browser.finders* The file browser finders power the picker with both a file and folder browser. @@ -444,8 +441,8 @@ Extends |telescope-file-browser.PickerOpts| finder (advanced) - *telescope-file-browser._extensions_file_browser_finders.browse_files()* -_extensions_file_browser_finders.browse_files({opts}) + *telescope-file-browser.finders.browse_files()* +fb_finders.browse_files({opts}) Returns a finder that is populated with files and folders in `path` . • Notes: • Uses `fd` if available for more async-ish browsing and speed-ups @@ -454,8 +451,8 @@ _extensions_file_browser_finders.browse_files({opts}) • {opts} (`telescope-file-browser.FinderOpts?`) options to pass to the finder. See |telescope-file-browser.FinderOpts| - *telescope-file-browser._extensions_file_browser_finders.browse_folders()* -_extensions_file_browser_finders.browse_folders({opts}) + *telescope-file-browser.finders.browse_folders()* +fb_finders.browse_folders({opts}) Returns a finder that is populated with (sub-)folders of `cwd` . • Notes: • Uses `fd` if available for more async-ish browsing and speed-ups @@ -464,8 +461,7 @@ _extensions_file_browser_finders.browse_folders({opts}) • {opts} (`telescope-file-browser.FinderOpts?`) options to pass to the finder. See |telescope-file-browser.FinderOpts| - *telescope-file-browser._extensions_file_browser_finders.finder()* -_extensions_file_browser_finders.finder({opts}) +fb_finders.finder({opts}) *telescope-file-browser.finders.finder()* Returns a finder that combines |fb_finders.browse_files| and |fb_finders.browse_folders| into a unified finder. diff --git a/lua/telescope/_extensions/file_browser/actions.lua b/lua/telescope/_extensions/file_browser/actions.lua index c87247d..3147fe0 100755 --- a/lua/telescope/_extensions/file_browser/actions.lua +++ b/lua/telescope/_extensions/file_browser/actions.lua @@ -39,7 +39,6 @@ local popup = require "plenary.popup" local scan = require "plenary.scandir" local async = require "plenary.async" ----@package local fb_actions = setmetatable({}, { __index = function(_, k) error("Key does not exist for 'fb_actions': " .. tostring(k)) diff --git a/scripts/gendocs.lua b/scripts/gendocs.lua index ae76158..59762c0 100644 --- a/scripts/gendocs.lua +++ b/scripts/gendocs.lua @@ -5,18 +5,29 @@ load(vim.fn.system "curl -s https://raw.githubusercontent.com/jamestrew/docgen.n require("docgen").run { name = "telescope-file-browser", files = { - "./lua/telescope/_extensions/file_browser.lua", - "./lua/telescope/_extensions/file_browser/picker.lua", - "./lua/telescope/_extensions/file_browser/actions.lua", - "./lua/telescope/_extensions/file_browser/finders.lua", + { + "./lua/telescope/_extensions/file_browser.lua", + title = "TELESCOPE-FILE-BROWSER.NVIM", + tag = "telescope-file-browser", + fn_prefix = "file_browser", + }, + { + "./lua/telescope/_extensions/file_browser/picker.lua", + title = "PICKER", + tag = "telescope-file-browser.picker", + fn_prefix = "fb_picker", + }, + { + "./lua/telescope/_extensions/file_browser/actions.lua", + title = "ACTIONS", + tag = "telescope-file-browser.actions", + fn_prefix = "fb_actions", + }, + { + "./lua/telescope/_extensions/file_browser/finders.lua", + title = "FINDERS", + tag = "telescope-file-browser.finders", + fn_prefix = "fb_finders", + }, }, - section_fmt = function(filename) - local section_names = { - ["./lua/telescope/_extensions/file_browser.lua"] = "TELESCOPE-FILE-BROWSER", - ["./lua/telescope/_extensions/file_browser/picker.lua"] = "PICKER", - ["./lua/telescope/_extensions/file_browser/actions.lua"] = "ACTIONS", - ["./lua/telescope/_extensions/file_browser/finders.lua"] = "FINDERS", - } - return section_names[filename] - end, }