feat: Add support for ruby (yard, rdoc)

This commit is contained in:
danymat
2022-02-08 14:12:22 +01:00
parent 7a2e69b660
commit e9b2812ed1
4 changed files with 99 additions and 0 deletions

View File

@@ -0,0 +1,77 @@
local _template = require("neogen.utilities.template")
local i = require("neogen.types.template").item
local nodes_utils = require("neogen.utilities.nodes")
local extractors = require("neogen.utilities.extractors")
local template = {}
template.parent = {
func = { "method" },
class = { "class" },
type = { "call" },
}
local identifier = {
retrieve = "first",
node_type = "identifier",
as = i.Parameter,
extract = true,
}
template.data = {
func = {
["method"] = {
["0"] = {
extract = function(node)
local tree = {
{
retrieve = "first",
node_type = "method_parameters",
subtree = {
{
retrieve = "all",
node_type = "optional_parameter",
subtree = {
identifier,
},
},
identifier,
},
},
{
retrieve = "all",
node_type = "return",
as = i.Return,
extract = true,
},
}
local nodes = nodes_utils:matching_nodes_from(node, tree)
local res = extractors:extract_from_matched(nodes)
return res
end,
},
},
},
class = {
["class"] = {
["0"] = {
extract = function()
return {}
end,
},
},
},
type = {
["call"] = {
["0"] = {
extract = function()
return {}
end,
},
},
},
}
template.template = _template:add_default_annotation("yard"):add_annotation("rdoc")
return template