C# improvements (#86)

* fix: Fixing csharp docs for interfaces

* feat(csharp): adding type params support
This commit is contained in:
Zoe Roux
2022-04-01 17:37:03 +02:00
committed by GitHub
parent c539cccce4
commit f249a70ee5
2 changed files with 45 additions and 17 deletions

View File

@@ -12,7 +12,7 @@ return {
"delegate_declaration", "delegate_declaration",
"conversion_operator_declaration", "conversion_operator_declaration",
}, },
class = { "class_declaration" }, class = { "class_declaration", "interface_declaration" },
type = { "field_declaration", "property_declaration", "event_field_declaration", "indexer_declaration" }, type = { "field_declaration", "property_declaration", "event_field_declaration", "indexer_declaration" },
}, },
data = { data = {
@@ -36,13 +36,49 @@ return {
}, },
{ {
retrieve = "first", retrieve = "first",
node_type = "block", node_type = "type_parameter_list",
subtree = { subtree = {
{ {
retrieve = "first", retrieve = "all",
recursive = true, node_type = "type_parameter",
node_type = "return_statement", subtree = {
extract = true, { position = 1, extract = true, as = i.Tparam },
},
},
},
},
{
position = 1,
extract = true,
as = i.Return
},
}
local nodes = nodes_utils:matching_nodes_from(node, tree)
local res = extractors:extract_from_matched(nodes)
if res.return_statement[1] == "void" then
res.return_statement = nil
end
res.identifier = res["_"]
return res
end,
},
},
},
class = {
["class_declaration|interface_declaration"] = {
["0"] = {
extract = function(node)
local tree = {
{
retrieve = "first",
node_type = "type_parameter_list",
subtree = {
{
retrieve = "all",
node_type = "type_parameter",
subtree = {
{ position = 1, extract = true, as = i.Tparam },
},
}, },
}, },
}, },
@@ -55,15 +91,6 @@ return {
}, },
}, },
}, },
class = {
["class_declaration"] = {
["0"] = {
extract = function()
return {}
end,
},
},
},
type = { type = {
["field_declaration|property_declaration|event_field_declaration"] = { ["field_declaration|property_declaration|event_field_declaration"] = {
["0"] = { ["0"] = {

View File

@@ -7,7 +7,8 @@ return {
{ nil, "/// <summary>", {} }, { nil, "/// <summary>", {} },
{ nil, "/// $1", {} }, { nil, "/// $1", {} },
{ i.Parameter, '/// <param name="%s">$1</param>', { type = { "func", "type" } } },
{ i.Return, "/// <returns>$1</returns>", { type = { "func", "type" } } },
{ nil, "/// </summary>", {} }, { nil, "/// </summary>", {} },
{ i.Parameter, '/// <param name="%s">$1</param>', { type = { "func", "type" } } },
{ i.Tparam, '/// <typeparam name="%s">$1</typeparam>', { type = { "func", "class" } } },
{ i.Return, "/// <returns>$1</returns>", { type = { "func", "type" } } },
} }