Skip to content

Commit

Permalink
docs: handle nio.create wrapped functions
Browse files Browse the repository at this point in the history
  • Loading branch information
rcarriga committed Apr 15, 2023
1 parent ec43e87 commit c66ef2c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
13 changes: 8 additions & 5 deletions doc/neotest.txt
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,7 @@ Debug the current file with nvim-dap
lua require("neotest").run.run({vim.fn.expand("%"), strategy = "dap"})
<
Parameters~
{args} `(string|neotest.run.RunArgs?)` Position ID to run or args. If args
then args[1] should be the position ID.
{args} `(string|neotest.run.RunArgs?)` Position ID to run or args.

*neotest.run.run_last()*
`run_last`({args})
Expand Down Expand Up @@ -521,7 +520,9 @@ Return~

Get last test position ID and args
Return~
`(string|nil,neotest.run.RunArgs|nil)` Position id and last args table
`(string|nil)` position_id
Return~
`(neotest.run.RunArgs|nil)` args


==============================================================================
Expand Down Expand Up @@ -811,7 +812,7 @@ Return~

*neotest.client.GetPositionArgs*
Fields~
{adapter} `(string)` Adapter ID
{adapter?} `(string)` Adapter ID

*neotest.Client:get_position()*
`Client:get_position`({position_id}, {args})
Expand Down Expand Up @@ -851,7 +852,9 @@ Return~
Parameters~
{file_path} `(string)`
Return~
`(string,neotest.Adapter)`
`(string?)`
Return~
`(neotest.Adapter?)`


==============================================================================
Expand Down
17 changes: 17 additions & 0 deletions doc/nio.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,22 @@ argument must be the callback.
Return~
`(function)` Returns an async function

*nio.create()*
`create`({func}, {argc})

Takes an async function and returns a function that can run in both async
and non async contexts. When running in an async context, the function can
return values, but when run in a non-async context, a Task object is
returned and an extra callback argument can be supplied to receive the
result, with the same signature as the callback for `nio.run`.

This is useful for APIs where users don't want to create async
contexts but which are still used in async contexts internally.
Parameters~
{func} `(async fun(...))`
{argc?} `(integer)` The number of arguments of func. Must be included if there
are arguments.

*nio.gather()*
`gather`({functions})

Expand Down Expand Up @@ -193,6 +209,7 @@ Fields~
by the client
{notify} `(nio.lsp.NotifyClient)` Interface to all notifications that can be
sent by the client
{server_capabilities} `(nio.lsp.types.ServerCapabilities)`

*nio.lsp.client()*
`client`({client_id})
Expand Down
5 changes: 5 additions & 0 deletions scripts/gendocs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ H.pattern_sets = {
'^function%s+(%S-)(%b())', -- Regular definition
'^local%s+function%s+(%S-)(%b())', -- Local definition
'^(%S+)%s*=%s*function(%b())', -- Regular assignment
'^(%S+)%s*=%s*nio.create%(function(%b())', -- Regular assignment
'^local%s+(%S+)%s*=%s*function(%b())', -- Local assignment
},
-- Determine if line is a general assignment
Expand Down Expand Up @@ -678,6 +679,10 @@ end
local function create_config(module, header)
return {
hooks = vim.tbl_extend("force", minidoc.default_hooks, {
block_pre = function(b)
-- Infer metadata based on afterlines
if b:has_lines() and #b.info.afterlines > 0 then H.infer_header(b) end
end,
section_post = function(section)
for i, line in ipairs(section) do
if type(line) == "string" then
Expand Down

0 comments on commit c66ef2c

Please sign in to comment.