Improve Godoc support (#75)
* Improve Godoc support Godoc recommends, as per https://go.dev/blog/godoc , that documentation comments start with the name of the thing being documented. This adds that, as well as better support for structs and interfaces. * ref(go) Use `as` keyword in configuration trees * chore: Bump neogen version Co-authored-by: danymat <d.danymat@gmail.com>
This commit is contained in:
@@ -1,17 +1,46 @@
|
|||||||
local template = require("neogen.template")
|
local template = require("neogen.template")
|
||||||
|
local extractors = require("neogen.utilities.extractors")
|
||||||
|
local nodes_utils = require("neogen.utilities.nodes")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
parent = {
|
parent = {
|
||||||
func = { "function_declaration" },
|
func = { "function_declaration", "method_declaration" },
|
||||||
type = { "package_clause", "const_declaration", "var_declaration" },
|
type = { "package_clause", "const_declaration", "var_declaration", "type_declaration" },
|
||||||
},
|
},
|
||||||
|
|
||||||
data = {
|
data = {
|
||||||
func = {
|
func = {
|
||||||
["function_declaration"] = {
|
["function_declaration"] = {
|
||||||
["0"] = {
|
["0"] = {
|
||||||
extract = function()
|
extract = function(node)
|
||||||
return {}
|
local tree = {
|
||||||
|
{
|
||||||
|
retrieve = "first",
|
||||||
|
node_type = "identifier",
|
||||||
|
extract = "true",
|
||||||
|
as = "func_name",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
local nodes = nodes_utils:matching_nodes_from(node, tree)
|
||||||
|
local res = extractors:extract_from_matched(nodes)
|
||||||
|
return res
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
["method_declaration"] = {
|
||||||
|
["0"] = {
|
||||||
|
extract = function(node)
|
||||||
|
local tree = {
|
||||||
|
{
|
||||||
|
retrieve = "first",
|
||||||
|
node_type = "field_identifier",
|
||||||
|
extract = "true",
|
||||||
|
as = "func_name",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
local nodes = nodes_utils:matching_nodes_from(node, tree)
|
||||||
|
local res = extractors:extract_from_matched(nodes)
|
||||||
|
return res
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -24,6 +53,29 @@ return {
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
["type_declaration"] = {
|
||||||
|
["0"] = {
|
||||||
|
extract = function(node)
|
||||||
|
local tree = {
|
||||||
|
{
|
||||||
|
retrieve = "all",
|
||||||
|
node_type = "type_spec",
|
||||||
|
subtree = {
|
||||||
|
{
|
||||||
|
retrieve = "first",
|
||||||
|
node_type = "type_identifier",
|
||||||
|
extract = true,
|
||||||
|
as = "type_name",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
local nodes = nodes_utils:matching_nodes_from(node, tree)
|
||||||
|
local res = extractors:extract_from_matched(nodes)
|
||||||
|
return res
|
||||||
|
end,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -216,6 +216,8 @@ end
|
|||||||
---
|
---
|
||||||
--- Note: We will only document `major` and `minor` versions, not `patch` ones.
|
--- Note: We will only document `major` and `minor` versions, not `patch` ones.
|
||||||
---
|
---
|
||||||
|
--- ## 2.4.0~
|
||||||
|
--- - Improve godoc template (#75)
|
||||||
--- ## 2.3.0~
|
--- ## 2.3.0~
|
||||||
--- - Added bundled support with snippet engines !
|
--- - Added bundled support with snippet engines !
|
||||||
--- Check out |snippet-integration| for basic setup
|
--- Check out |snippet-integration| for basic setup
|
||||||
@@ -234,7 +236,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.3.0"
|
neogen.version = "2.4.0"
|
||||||
--minidoc_afterlines_end
|
--minidoc_afterlines_end
|
||||||
|
|
||||||
return neogen
|
return neogen
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
return {
|
return {
|
||||||
{ nil, " $1", { no_results = true } },
|
{ nil, " $1", { no_results = true } },
|
||||||
|
{ "func_name", " %s $1", { type = { "func" }}},
|
||||||
|
{ "type_name", " %s $1", { type = { "type" }}},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user