feat: Add support for ruby (yard, rdoc)
This commit is contained in:
77
lua/neogen/configurations/ruby.lua
Normal file
77
lua/neogen/configurations/ruby.lua
Normal 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
|
||||
11
lua/neogen/templates/rdoc.lua
Normal file
11
lua/neogen/templates/rdoc.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
return {
|
||||
{ nil, "##", { type = { "class", "func" } } },
|
||||
{ nil, "# $1", { type = { "class", "func" } } },
|
||||
{ nil, "", { type = { "class", "func" } } },
|
||||
{ nil, "# $1", { type = { "type" } } },
|
||||
|
||||
{ nil, "#1", { no_results = true, type = { "class", "func" } } },
|
||||
{ nil, "# $1", { no_results = true, type = { "class", "func" } } },
|
||||
{ nil, "", { no_results = true, type = { "class", "func" } } },
|
||||
{ nil, "# $1", { no_results = true, type = { "type" } } },
|
||||
}
|
||||
10
lua/neogen/templates/yard.lua
Normal file
10
lua/neogen/templates/yard.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
local i = require("neogen.types.template").item
|
||||
|
||||
return {
|
||||
{ nil, "# $1", { no_results = true, type = { "class", "func" } } },
|
||||
{ nil, "# $1", { no_results = true, type = { "type" } } },
|
||||
|
||||
{ nil, "# $1" },
|
||||
{ i.Parameter, "# @param %s [$1] $1", {} },
|
||||
{ i.Return, "# @return [$1] $1", {} },
|
||||
}
|
||||
Reference in New Issue
Block a user