feat: Add kotlin support (#34)
This commit is contained in:
75
lua/neogen/configurations/kotlin.lua
Normal file
75
lua/neogen/configurations/kotlin.lua
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
local _template = require("neogen.template")
|
||||||
|
local i = require("neogen.types.template").item
|
||||||
|
local extractors = require("neogen.utilities.extractors")
|
||||||
|
local nodes_utils = require("neogen.utilities.nodes")
|
||||||
|
|
||||||
|
---@type neogen.Configuration
|
||||||
|
local template = {}
|
||||||
|
|
||||||
|
template.parent = {
|
||||||
|
class = { "class_declaration" },
|
||||||
|
func = { "function_declaration" },
|
||||||
|
}
|
||||||
|
|
||||||
|
template.data = {
|
||||||
|
func = {
|
||||||
|
["function_declaration"] = {
|
||||||
|
["0"] = {
|
||||||
|
extract = function(node)
|
||||||
|
local tree = {
|
||||||
|
{
|
||||||
|
node_type = "parameter",
|
||||||
|
retrieve = "all",
|
||||||
|
subtree = {
|
||||||
|
{
|
||||||
|
node_type = "simple_identifier",
|
||||||
|
as = i.Parameter,
|
||||||
|
retrieve = "first",
|
||||||
|
extract = true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
local nodes = nodes_utils:matching_nodes_from(node, tree)
|
||||||
|
local res = extractors:extract_from_matched(nodes)
|
||||||
|
return res
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
class = {
|
||||||
|
["class_declaration"] = {
|
||||||
|
["0"] = {
|
||||||
|
extract = function(node)
|
||||||
|
local tree = {
|
||||||
|
{
|
||||||
|
node_type = "primary_constructor",
|
||||||
|
retrieve = "first",
|
||||||
|
subtree = {
|
||||||
|
{
|
||||||
|
node_type = "class_parameter",
|
||||||
|
retrieve = "all",
|
||||||
|
subtree = {
|
||||||
|
{
|
||||||
|
node_type = "simple_identifier",
|
||||||
|
retrieve = "first",
|
||||||
|
extract = true,
|
||||||
|
as = i.ClassAttribute,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
local nodes = nodes_utils:matching_nodes_from(node, tree)
|
||||||
|
local res = extractors:extract_from_matched(nodes)
|
||||||
|
return res
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
template.template = _template:add_default_annotation("kdoc")
|
||||||
|
|
||||||
|
return template
|
||||||
@@ -202,6 +202,10 @@ end
|
|||||||
---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section)
|
---@eval return MiniDoc.afterlines_to_code(MiniDoc.current.eval_section)
|
||||||
---@text # Changelog~
|
---@text # Changelog~
|
||||||
---
|
---
|
||||||
|
--- Note: We will only document major and minor versions.
|
||||||
|
---
|
||||||
|
--- ## 2.1.0~
|
||||||
|
--- - Add basic support for `kotlin` (`kdoc`).
|
||||||
--- ## 2.0.0~
|
--- ## 2.0.0~
|
||||||
--- - We made the template API private, only for initial template configuration.
|
--- - We made the template API private, only for initial template configuration.
|
||||||
--- If you want to make a change to a template, please see:
|
--- If you want to make a change to a template, please see:
|
||||||
@@ -211,7 +215,7 @@ end
|
|||||||
--- with multiple annotation conventions.
|
--- with multiple annotation conventions.
|
||||||
---@tag neogen-changelog
|
---@tag neogen-changelog
|
||||||
---@toc_entry Changes in neogen plugin
|
---@toc_entry Changes in neogen plugin
|
||||||
neogen.version = "2.0.0"
|
neogen.version = "2.1.0"
|
||||||
--minidoc_afterlines_end
|
--minidoc_afterlines_end
|
||||||
|
|
||||||
return neogen
|
return neogen
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ return {
|
|||||||
{ nil, " * $1" },
|
{ nil, " * $1" },
|
||||||
{ nil, " *" },
|
{ nil, " *" },
|
||||||
{ i.Parameter, " * @param %s $1" },
|
{ i.Parameter, " * @param %s $1" },
|
||||||
|
{ i.ClassAttribute, "* @property %s $1" },
|
||||||
{ i.Return, " * @return $1" },
|
{ i.Return, " * @return $1" },
|
||||||
{ i.Throw, " * @throws $1" },
|
{ i.Throw, " * @throws $1" },
|
||||||
{ nil, " */" },
|
{ nil, " */" },
|
||||||
|
|||||||
1
lua/neogen/templates/kdoc.lua
Normal file
1
lua/neogen/templates/kdoc.lua
Normal file
@@ -0,0 +1 @@
|
|||||||
|
return require("neogen.templates.javadoc")
|
||||||
Reference in New Issue
Block a user