docs: docgen

This commit is contained in:
Folke Lemaitre 2024-11-06 11:27:52 +01:00
parent 47e956f7c4
commit 983621b0fe
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
28 changed files with 43 additions and 122 deletions

View file

@ -10,11 +10,6 @@ Table of Contents *snacks-bufdelete-table-of-contents*
==============================================================================
1. Module *snacks-bufdelete-module*
>lua
---@class snacks.bufdelete
Snacks.bufdelete = {}
<
SNACKS.BUFDELETE() *snacks-bufdelete-module-snacks.bufdelete()*

View file

@ -12,11 +12,6 @@ Table of Contents *snacks-debug-table-of-contents*
==============================================================================
1. Module *snacks-debug-module*
>lua
---@class snacks.debug
Snacks.debug = {}
<
SNACKS.DEBUG() *snacks-debug-module-snacks.debug()*

View file

@ -30,11 +30,6 @@ BLAME_LINE *snacks-git-styles-blame_line*
==============================================================================
2. Module *snacks-git-module*
>lua
---@class snacks.git
Snacks.git = {}
<
SNACKS.GIT.BLAME_LINE() *snacks-git-module-snacks.git.blame_line()*

View file

@ -43,11 +43,6 @@ Table of Contents *snacks-gitbrowse-table-of-contents*
==============================================================================
2. Module *snacks-gitbrowse-module*
>lua
---@class snacks.gitbrowse
Snacks.gitbrowse = {}
<
SNACKS.GITBROWSE() *snacks-gitbrowse-module-snacks.gitbrowse()*

View file

@ -77,11 +77,6 @@ LAZYGIT *snacks-lazygit-styles-lazygit*
==============================================================================
4. Module *snacks-lazygit-module*
>lua
---@class snacks.lazygit
Snacks.lazygit = {}
<
SNACKS.LAZYGIT() *snacks-lazygit-module-snacks.lazygit()*

View file

@ -22,11 +22,6 @@ Table of Contents *snacks-notify-table-of-contents*
==============================================================================
2. Module *snacks-notify-module*
>lua
---@class snacks.notify
Snacks.notify = {}
<
SNACKS.NOTIFY() *snacks-notify-module-snacks.notify()*

View file

@ -12,11 +12,6 @@ Table of Contents *snacks-rename-table-of-contents*
==============================================================================
1. Module *snacks-rename-module*
>lua
---@class snacks.rename
Snacks.rename = {}
<
SNACKS.RENAME() *snacks-rename-module-snacks.rename()*

View file

@ -13,7 +13,6 @@ Table of Contents *snacks-toggle-table-of-contents*
- Snacks.toggle.new() |snacks-toggle-module-snacks.toggle.new()|
- Snacks.toggle.option() |snacks-toggle-module-snacks.toggle.option()|
- Snacks.toggle.treesitter()|snacks-toggle-module-snacks.toggle.treesitter()|
- toggle:_wk() |snacks-toggle-module-toggle:_wk()|
- toggle:get() |snacks-toggle-module-toggle:get()|
- toggle:map() |snacks-toggle-module-toggle:map()|
- toggle:set() |snacks-toggle-module-toggle:set()|
@ -121,13 +120,6 @@ SNACKS.TOGGLE.TREESITTER() *snacks-toggle-module-snacks.toggle.treesitter()*
<
TOGGLE:_WK() *snacks-toggle-module-toggle:_wk()*
>lua
toggle:_wk(keys, mode)
<
TOGGLE:GET() *snacks-toggle-module-toggle:get()*
>lua

View file

@ -5,8 +5,8 @@ Table of Contents *snacks-win-table-of-contents*
1. Config |snacks-win-config|
2. Styles |snacks-win-styles|
- minimal |snacks-win-styles-minimal|
- float |snacks-win-styles-float|
- minimal |snacks-win-styles-minimal|
- split |snacks-win-styles-split|
3. Types |snacks-win-types|
4. Module |snacks-win-module|
@ -64,6 +64,19 @@ Table of Contents *snacks-win-table-of-contents*
2. Styles *snacks-win-styles*
FLOAT *snacks-win-styles-float*
>lua
{
position = "float",
backdrop = 60,
height = 0.9,
width = 0.9,
zindex = 50,
}
<
MINIMAL *snacks-win-styles-minimal*
>lua
@ -89,19 +102,6 @@ MINIMAL *snacks-win-styles-minimal*
<
FLOAT *snacks-win-styles-float*
>lua
{
position = "float",
backdrop = 60,
height = 0.9,
width = 0.9,
zindex = 50,
}
<
SPLIT *snacks-win-styles-split*
>lua

View file

@ -23,11 +23,6 @@ Table of Contents *snacks-words-table-of-contents*
==============================================================================
2. Module *snacks-words-module*
>lua
---@class snacks.words
Snacks.words = {}
<
SNACKS.WORDS.IS_ENABLED() *snacks-words-module-snacks.words.is_enabled()*

View file

@ -4,11 +4,6 @@
## 📦 Module
```lua
---@class snacks.bufdelete
Snacks.bufdelete = {}
```
### `Snacks.bufdelete()`
```lua

View file

@ -4,11 +4,6 @@
## 📦 Module
```lua
---@class snacks.debug
Snacks.debug = {}
```
### `Snacks.debug()`
```lua

View file

@ -19,11 +19,6 @@
## 📦 Module
```lua
---@class snacks.git
Snacks.git = {}
```
### `Snacks.git.blame_line()`
Show git log for the current line.

View file

@ -33,11 +33,6 @@
## 📦 Module
```lua
---@class snacks.gitbrowse
Snacks.gitbrowse = {}
```
### `Snacks.gitbrowse()`
```lua

View file

@ -58,11 +58,6 @@
## 📦 Module
```lua
---@class snacks.lazygit
Snacks.lazygit = {}
```
### `Snacks.lazygit()`
```lua

View file

@ -10,11 +10,6 @@
## 📦 Module
```lua
---@class snacks.notify
Snacks.notify = {}
```
### `Snacks.notify()`
```lua

View file

@ -4,11 +4,6 @@
## 📦 Module
```lua
---@class snacks.rename
Snacks.rename = {}
```
### `Snacks.rename()`
```lua

View file

@ -91,12 +91,6 @@ Snacks.toggle.option(option, opts)
Snacks.toggle.treesitter(opts)
```
### `toggle:_wk()`
```lua
toggle:_wk(keys, mode)
```
### `toggle:get()`
```lua

View file

@ -14,11 +14,6 @@
## 📦 Module
```lua
---@class snacks.words
Snacks.words = {}
```
### `Snacks.words.is_enabled()`
```lua

View file

@ -1,4 +1,5 @@
---@class snacks.bufdelete
---@hide
---@overload fun(buf?: number)
local M = setmetatable({}, {
__call = function(t, ...)

View file

@ -1,4 +1,5 @@
---@class snacks.debug
---@hide
---@overload fun(...)
local M = setmetatable({}, {
__call = function(t, ...)

View file

@ -8,12 +8,12 @@ function M.extract(lines)
local mod ---@type string
local comments = {} ---@type string[]
local types = {} ---@type string[]
local styles = {} ---@type table<string, string>
local styles = {} ---@type {name:string, opts:string}[]
local style_pattern = 'Snacks%.config%.style%("([^"]+)"%s*,%s*({.-}%s*)%)'
for style_name, style in code:gmatch(style_pattern) do
styles[style_name] = style
table.insert(styles, { name = style_name, opts = style })
end
---@type {name: string, args: string, comment?: string, types?: string, type: "method"|"function"}[]
@ -30,12 +30,14 @@ function M.extract(lines)
else
local t, name, args = line:match("^function M([:%.])([%w_%.]+)%((.-)%)")
if name and args then
table.insert(methods, {
name = name,
args = args,
type = t,
comment = comment,
})
if not name:find("^_") then
table.insert(methods, {
name = name,
args = args,
type = t,
comment = comment,
})
end
elseif #comments > 0 and line == "" then
table.insert(types, table.concat(comments, "\n"))
end
@ -112,11 +114,14 @@ function M.render(name, info)
add(M.md(info.config))
end
if not vim.tbl_isempty(info.styles) then
if #info.styles > 0 then
table.sort(info.styles, function(a, b)
return a.name < b.name
end)
add("## 🎨 Styles\n")
for style, value in pairs(info.styles) do
add(("### `%s`\n"):format(style))
add(M.md(value))
for _, style in pairs(info.styles) do
add(("### `%s`\n"):format(style.name))
add(M.md(style.opts))
end
end
@ -148,8 +153,10 @@ function M.render(name, info)
end
return true
end, mod_lines)
table.insert(mod_lines, prefix .. " = {}")
add(M.md(table.concat(mod_lines, "\n")))
if not info.mod:find("@hide") then
table.insert(mod_lines, prefix .. " = {}")
add(M.md(table.concat(mod_lines, "\n")))
end
end
table.sort(info.methods, function(a, b)

View file

@ -1,4 +1,5 @@
---@class snacks.git
---@hide
local M = {}
Snacks.config.style("blame_line", {

View file

@ -1,4 +1,5 @@
---@class snacks.gitbrowse
---@hide
---@overload fun(opts?: snacks.gitbrowse.Config)
local M = setmetatable({}, {
__call = function(t, ...)

View file

@ -1,3 +1,4 @@
---@hide
---@class snacks.lazygit
---@overload fun(opts?: snacks.lazygit.Config): snacks.win
local M = setmetatable({}, {

View file

@ -1,3 +1,4 @@
---@hide
---@class snacks.notify
---@overload fun(msg: string|string[], opts?: snacks.notify.Opts)
local M = setmetatable({}, {

View file

@ -1,3 +1,4 @@
---@hide
---@class snacks.rename
---@overload fun()
local M = setmetatable({}, {

View file

@ -1,3 +1,4 @@
---@hide
---@class snacks.words
local M = {}