Skip to content

Commit

Permalink
improve docs script
Browse files Browse the repository at this point in the history
  • Loading branch information
pablopunk committed Jan 25, 2024
1 parent 8ff4765 commit d6b1222
Show file tree
Hide file tree
Showing 3 changed files with 125 additions and 23 deletions.
111 changes: 97 additions & 14 deletions doc/unclutter.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,85 @@ unclutter.setup({opts}) *unclutter.setup()*


================================================================================
unclutter.plugin *unclutter.plugin*
unclutter.autocmds *unclutter.autocmds*



plugin.buf_just_left() *plugin.buf_just_left()*
autocmds.remove_augroup() *autocmds.remove_augroup()*
Remove the created augroup.



plugin.enable({opts}) *plugin.enable()*
Initialize the plugin
autocmds.on_buf_leave({callback}) *autocmds.on_buf_leave()*
Create an autocmd for the BufLeave event.


Parameters: ~
{opts} (unclutter.config)
{callback} (function) The callback function to be executed.


plugin.disable() *plugin.disable()*
Disable the plugin
autocmds.on_buf_delete({callback}) *autocmds.on_buf_delete()*
Create an autocmd for the BufDelete event.


Parameters: ~
{callback} (function) The callback function to be executed.

plugin.setup_autocmds() *plugin.setup_autocmds()*
Setup the autocmds

autocmds.on_buf_enter({callback}) *autocmds.on_buf_enter()*
Create an autocmd for the BufEnter event.


plugin.buffer_should_be_hidden_on_leave({buf}) *plugin.buffer_should_be_hidden_on_leave()*
Check if buffer should be hidden
Parameters: ~
{callback} (function) The callback function to be executed.


autocmds.on_buf_write_post({callback}) *autocmds.on_buf_write_post()*
Create an autocmd for the BufWritePost event.


Parameters: ~
{buf} (number)
{callback} (function) The callback function to be executed.

Return: ~
boolean

autocmds.on_vim_enter({callback}) *autocmds.on_vim_enter()*
Create an autocmd for the VimEnter event.


Parameters: ~
{callback} (function) The callback function to be executed.


autocmds.on_insert_enter({callback}) *autocmds.on_insert_enter()*
Create an autocmd for the InsertEnter event.


Parameters: ~
{callback} (function) The callback function to be executed.


autocmds.on_buf_modified_set({callback}) *autocmds.on_buf_modified_set()*
Create an autocmd for the BufModifiedSet event.


Parameters: ~
{callback} (function) The callback function to be executed.


autocmds.on_win_enter({callback}) *autocmds.on_win_enter()*
Create an autocmd for the WinEnter event.


Parameters: ~
{callback} (function) The callback function to be executed.


autocmds.on_win_new({callback}) *autocmds.on_win_new()*
Create an autocmd for the WinNew event.


Parameters: ~
{callback} (function) The callback function to be executed.



Expand Down Expand Up @@ -212,6 +256,45 @@ config.set({opts}) *config.set()*



================================================================================
unclutter.plugin *unclutter.plugin*



plugin.buf_just_left() *plugin.buf_just_left()*



plugin.enable({opts}) *plugin.enable()*
Initialize the plugin


Parameters: ~
{opts} (unclutter.config)


plugin.disable() *plugin.disable()*
Disable the plugin



plugin.setup_autocmds() *plugin.setup_autocmds()*
Setup the autocmds



plugin.buffer_should_be_hidden_on_leave({buf}) *plugin.buffer_should_be_hidden_on_leave()*
Check if buffer should be hidden


Parameters: ~
{buf} (number)

Return: ~
boolean



================================================================================
unclutter.tabline *unclutter.tabline*

Expand Down
20 changes: 19 additions & 1 deletion lua/unclutter/autocmds.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ local autocmds = {}
local augroup_name = "Unclutter"
local augroup = vim.api.nvim_create_augroup(augroup_name, {})

-- Remove created augroup
---Remove the created augroup.
autocmds.remove_augroup = function()
pcall(vim.api.nvim_del_augroup_by_name, augroup_name)
end

---Create an autocmd for the BufLeave event.
---@param callback function: The callback function to be executed.
autocmds.on_buf_leave = function(callback)
vim.api.nvim_create_autocmd("BufLeave", {
group = augroup,
Expand All @@ -16,6 +18,8 @@ autocmds.on_buf_leave = function(callback)
})
end

---Create an autocmd for the BufDelete event.
---@param callback function: The callback function to be executed.
autocmds.on_buf_delete = function(callback)
vim.api.nvim_create_autocmd("BufDelete", {
group = augroup,
Expand All @@ -24,6 +28,8 @@ autocmds.on_buf_delete = function(callback)
})
end

---Create an autocmd for the BufEnter event.
---@param callback function: The callback function to be executed.
autocmds.on_buf_enter = function(callback)
vim.api.nvim_create_autocmd("BufEnter", {
group = augroup,
Expand All @@ -32,6 +38,8 @@ autocmds.on_buf_enter = function(callback)
})
end

---Create an autocmd for the BufWritePost event.
---@param callback function: The callback function to be executed.
autocmds.on_buf_write_post = function(callback)
vim.api.nvim_create_autocmd("BufWritePost", {
group = augroup,
Expand All @@ -40,6 +48,8 @@ autocmds.on_buf_write_post = function(callback)
})
end

---Create an autocmd for the VimEnter event.
---@param callback function: The callback function to be executed.
autocmds.on_vim_enter = function(callback)
vim.api.nvim_create_autocmd("VimEnter", {
group = augroup,
Expand All @@ -48,6 +58,8 @@ autocmds.on_vim_enter = function(callback)
})
end

---Create an autocmd for the InsertEnter event.
---@param callback function: The callback function to be executed.
autocmds.on_insert_enter = function(callback)
vim.api.nvim_create_autocmd("InsertEnter", {
group = augroup,
Expand All @@ -56,6 +68,8 @@ autocmds.on_insert_enter = function(callback)
})
end

---Create an autocmd for the BufModifiedSet event.
---@param callback function: The callback function to be executed.
autocmds.on_buf_modified_set = function(callback)
vim.api.nvim_create_autocmd("BufModifiedSet", {
group = augroup,
Expand All @@ -64,6 +78,8 @@ autocmds.on_buf_modified_set = function(callback)
})
end

---Create an autocmd for the WinEnter event.
---@param callback function: The callback function to be executed.
autocmds.on_win_enter = function(callback)
vim.api.nvim_create_autocmd("WinEnter", {
group = augroup,
Expand All @@ -72,6 +88,8 @@ autocmds.on_win_enter = function(callback)
})
end

---Create an autocmd for the WinNew event.
---@param callback function: The callback function to be executed.
autocmds.on_win_new = function(callback)
vim.api.nvim_create_autocmd("WinNew", {
group = augroup,
Expand Down
17 changes: 9 additions & 8 deletions scripts/docs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,18 @@ local docgen = require "docgen"
local docs = {}

docs.test = function()
-- Filepaths that should generate docs
local input_files = {
"./lua/unclutter/init.lua",
"./lua/unclutter/plugin.lua",
"./lua/unclutter/buffer.lua",
"./lua/unclutter/config.lua",
"./lua/unclutter/tabline.lua",
"./lua/unclutter/telescope.lua",
"./lua/unclutter/init.lua", -- force this to be first
}

-- Output file
local files = vim.fn.glob("./lua/unclutter/*.lua", true, 1)

for _, file in ipairs(files) do
if not file:match "_spec" and not vim.tbl_contains(input_files, file) then
table.insert(input_files, file)
end
end

local output_file = "./doc/unclutter.txt"
local output_file_handle = io.open(output_file, "w")
assert(output_file_handle, "Could not open " .. output_file)
Expand Down

0 comments on commit d6b1222

Please sign in to comment.