feat(c) Add @typedef for doxygen (#80)

This commit is contained in:
danymat
2022-03-11 10:37:18 +01:00
parent f2aeb078f0
commit 1da0dd9e56
3 changed files with 21 additions and 5 deletions

View File

@@ -208,7 +208,7 @@ There is a list of supported languages and fields, with their annotation style
| Languages | Annotation Conventions | Supported annotation types | | Languages | Annotation Conventions | Supported annotation types |
| --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- | | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
| sh | [Google Style Guide](https://google.github.io/styleguide/shellguide.html) (`"google_bash"`) | `func`, `file` | | sh | [Google Style Guide](https://google.github.io/styleguide/shellguide.html) (`"google_bash"`) | `func`, `file` |
| c | [Doxygen](https://www.doxygen.nl/manual/commands.html) (`"doxygen"`) | `func`, `file` | | c | [Doxygen](https://www.doxygen.nl/manual/commands.html) (`"doxygen"`) | `func`, `file`, `type` |
| csharp | [Xmldoc](https://docs.microsoft.com/fr-fr/dotnet/csharp/language-reference/xmldoc/) (`"xmldoc"`) <br> [Doxygen](https://www.doxygen.nl/manual/commands.html) (`"doxygen"`) | `func`, `file`, `class` | | csharp | [Xmldoc](https://docs.microsoft.com/fr-fr/dotnet/csharp/language-reference/xmldoc/) (`"xmldoc"`) <br> [Doxygen](https://www.doxygen.nl/manual/commands.html) (`"doxygen"`) | `func`, `file`, `class` |
| cpp | [Doxygen](https://www.doxygen.nl/manual/commands.html) (`"doxygen"`) | `func`, `file`, `class` | | cpp | [Doxygen](https://www.doxygen.nl/manual/commands.html) (`"doxygen"`) | `func`, `file`, `class` |
| go | [GoDoc](https://go.dev/blog/godoc) (`"godoc"`) | `func`, `type` | | go | [GoDoc](https://go.dev/blog/godoc) (`"godoc"`) | `func`, `type` |

View File

@@ -122,6 +122,7 @@ local c_config = {
"template_declaration", "template_declaration",
}, },
file = { "translation_unit" }, file = { "translation_unit" },
type = { "type_definition" },
}, },
data = { data = {
@@ -141,6 +142,20 @@ local c_config = {
}, },
}, },
}, },
type = {
["type_definition"] = {
["1"] = {
extract = function(node)
local tree = {
{ retrieve = "first", node_type = "type_identifier", extract = true, as = i.Type },
}
local nodes = nodes_utils:matching_nodes_from(node, tree)
local res = extractors:extract_from_matched(nodes)
return res
end,
},
},
},
}, },
locator = function(node_info, nodes_to_match) locator = function(node_info, nodes_to_match)

View File

@@ -6,12 +6,13 @@ return {
{ nil, " */", { no_results = true, type = { "func", "file", "class" } } }, { nil, " */", { no_results = true, type = { "func", "file", "class" } } },
{ nil, "", { no_results = true, type = { "file" } } }, { nil, "", { no_results = true, type = { "file" } } },
{ nil, "/**", { type = { "func", "class" } } }, { nil, "/**", { type = { "func", "class", "type" } } },
{ i.ClassName, " * @class %s", { type = { "class" } } }, { i.ClassName, " * @class %s", { type = { "class" } } },
{ nil, " * @brief $1", { type = { "func", "class" } } }, { i.Type, " * @typedef $1", { type = { "type" } } },
{ nil, " *", { type = { "func", "class" } } }, { nil, " * @brief $1", { type = { "func", "class", "type" } } },
{ nil, " *", { type = { "func", "class", "type" } } },
{ i.Tparam, " * @tparam %s $1" }, { i.Tparam, " * @tparam %s $1" },
{ i.Parameter, " * @param %s $1" }, { i.Parameter, " * @param %s $1" },
{ i.Return, " * @return $1" }, { i.Return, " * @return $1" },
{ nil, " */", { type = { "func", "class" } } }, { nil, " */", { type = { "func", "class", "type" } } },
} }