(lua) Add ldoc annotation convention

This commit is contained in:
Daniel Mathiot
2021-08-29 18:43:11 +02:00
parent a07df9e3a4
commit 518515be3e
2 changed files with 9 additions and 4 deletions

View File

@@ -6,7 +6,7 @@ local c_params = {
retrieve = "all", retrieve = "all",
node_type = "parameter_declaration", node_type = "parameter_declaration",
subtree = { subtree = {
{ retrieve = "first_recursive", node_type = "identifier", extract = true} { retrieve = "first_recursive", node_type = "identifier", extract = true },
}, },
}, },
}, },
@@ -23,7 +23,7 @@ local c_function_extractor = function(node)
{ {
retrieve = "first_recursive", retrieve = "first_recursive",
node_type = "function_declarator", node_type = "function_declarator",
extract = true extract = true,
}, },
{ {
retrieve = "first", retrieve = "first",
@@ -32,13 +32,12 @@ local c_function_extractor = function(node)
{ retrieve = "first", node_type = "return_statement", extract = true }, { retrieve = "first", node_type = "return_statement", extract = true },
}, },
}, },
c_params c_params,
} }
local nodes = neogen.utilities.nodes:matching_nodes_from(node, tree) local nodes = neogen.utilities.nodes:matching_nodes_from(node, tree)
local res = neogen.utilities.extractors:extract_from_matched(nodes) local res = neogen.utilities.extractors:extract_from_matched(nodes)
if nodes.function_declarator then if nodes.function_declarator then
local subnodes = neogen.utilities.nodes:matching_nodes_from(nodes.function_declarator[1], tree) local subnodes = neogen.utilities.nodes:matching_nodes_from(nodes.function_declarator[1], tree)
local subres = neogen.utilities.extractors:extract_from_matched(subnodes) local subres = neogen.utilities.extractors:extract_from_matched(subnodes)

View File

@@ -124,5 +124,11 @@ return {
{ "class_name", "- @class $1|any" }, { "class_name", "- @class $1|any" },
{ "type", "- @type %s $1" }, { "type", "- @type %s $1" },
}, },
ldoc = {
{ nil, "- $1", { no_results = true, type = { "func" } } },
{ nil, "- $1", { type = { "func" } } },
{ "parameters", " @tparam $1|any %s " },
{ "return_statement", " @treturn $1|any" },
},
}, },
} }