docs(api): document types using LuaCATS types

- Render Lua types in api.txt.

- Added `DictAs(name)` API type which acts the same as `Dict` (no parens)
  when generating the dispatchers, but acts the same as `Dict(name)`
  when generating docs.

- Added `Tuple(...)` API type which is the treated the as `Array` for
  generating the dispatchers, but is used to document richer types.

- Added `Enum(...)` API type to better document enums

- Improve typing of some API functions.

- Improve c_grammar to properly parse API types and replace string pattern
  logic in the parsers.

- Removed all the hardcoded type overrides in gen_eval_files.lua
This commit is contained in:
Lewis Russell
2025-06-16 11:45:44 +01:00
committed by Lewis Russell
parent 3eaa6c5a66
commit 76de3e2d07
21 changed files with 929 additions and 783 deletions

View File

@@ -1,5 +1,6 @@
local cdoc_grammar = require('gen.cdoc_grammar')
local c_grammar = require('gen.c_grammar')
local api_type = require('gen.api_types')
--- @class nvim.cdoc.parser.param
--- @field name string
@@ -140,7 +141,7 @@ local function process_proto(item, state)
cur_obj.params = cur_obj.params or {}
for _, p in ipairs(item.parameters) do
local param = { name = p[2], type = p[1] }
local param = { name = p[2], type = api_type(p[1]) }
local added = false
for _, cp in ipairs(cur_obj.params) do
if cp.name == param.name then
@@ -156,7 +157,7 @@ local function process_proto(item, state)
end
cur_obj.returns = cur_obj.returns or { {} }
cur_obj.returns[1].type = item.return_type
cur_obj.returns[1].type = api_type(item.return_type)
for _, a in ipairs({
'fast',