feat: Add support for bash (google shellguide)

This commit is contained in:
danymat
2022-02-08 15:12:08 +01:00
parent 970bebc2ec
commit e38e663dc1
3 changed files with 81 additions and 0 deletions

View File

@@ -187,6 +187,7 @@ There is a list of supported languages and fields, with their annotation style
| Languages | Annotation Conventions | Supported annotation types |
| ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- |
| 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` |
| 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` |

View File

@@ -0,0 +1,62 @@
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")
---@type neogen.Configuration
local template = {}
template.parent = {
func = { "function_definition" },
file = { "program" },
}
template.data = {
func = {
["function_definition"] = {
["0"] = {
extract = function(node)
local tree = {
{
node_type = "compound_statement",
retrieve = "first",
subtree = {
{
node_type = "simple_expansion",
retrieve = "all",
recursive = true,
as = i.Parameter,
extract = true,
},
{
node_type = "expansion",
recursive = true,
retrieve = "all",
subtree = {
{ node_type = "variable_name", retrieve = "all", extract = true },
},
},
},
},
}
local nodes = nodes_utils:matching_nodes_from(node, tree)
local res = extractors:extract_from_matched(nodes)
return res
end,
},
},
},
file = {
["program"] = {
["0"] = {
extract = function()
return {}
end,
},
},
},
}
template.template = _template:add_default_annotation("google_bash")
return template

View File

@@ -0,0 +1,18 @@
local i = require("neogen.types.template").item
return {
{ nil, "#######################################", { no_results = true, type = { "func" } } },
{ nil, "# $1", { no_results = true, type = { "func" } } },
{ nil, "#######################################", { no_results = true, type = { "func" } } },
{ nil, "#!/bin/bash$1", { no_results = true, type = { "file" } } },
{ nil, "#", { no_results = true, type = { "file" } } },
{ nil, "# $1", { no_results = true, type = { "file" } } },
{ nil, "", { no_results = true, type = { "file" } } },
{ nil, "#######################################" },
{ nil, "# $1" },
{ "variable_name", "# %s", { before_first_item = { "# Globals:" } } },
{ i.Parameter, "# $1", { before_first_item = { "# Arguments:" } } },
{ nil, "#######################################" },
}