Add default comments when no results (python, lua)
This commit is contained in:
@@ -67,7 +67,7 @@ neogen.setup = function(opts)
|
||||
languages = {
|
||||
lua = require("neogen.configurations.lua"),
|
||||
python = require("neogen.configurations.python"),
|
||||
javascript = require("neogen.configurations.javascript")
|
||||
javascript = require("neogen.configurations.javascript"),
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
local function_tree = {
|
||||
{ retrieve = "first", node_type = "formal_parameters", subtree = {
|
||||
{ retrieve = "all", node_type = "identifier", extract = true }
|
||||
} },
|
||||
{ retrieve = "first", node_type = "statement_block", subtree = {
|
||||
{ retrieve = "first", node_type = "return_statement", extract = true }
|
||||
} }
|
||||
{
|
||||
retrieve = "first",
|
||||
node_type = "formal_parameters",
|
||||
subtree = {
|
||||
{ retrieve = "all", node_type = "identifier", extract = true },
|
||||
},
|
||||
},
|
||||
{
|
||||
retrieve = "first",
|
||||
node_type = "statement_block",
|
||||
subtree = {
|
||||
{ retrieve = "first", node_type = "return_statement", extract = true },
|
||||
},
|
||||
},
|
||||
}
|
||||
return {
|
||||
parent = { "function_declaration", "expression_statement", "variable_declaration" },
|
||||
@@ -22,8 +30,8 @@ return {
|
||||
results.parameters = res.identifier
|
||||
results.return_statement = res.return_statement
|
||||
return results
|
||||
end
|
||||
}
|
||||
end,
|
||||
},
|
||||
},
|
||||
["expression_statement|variable_declaration"] = {
|
||||
["1"] = {
|
||||
@@ -36,8 +44,8 @@ return {
|
||||
results.parameters = res.identifier
|
||||
results.return_statement = res.return_statement
|
||||
return results
|
||||
end
|
||||
}
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -50,7 +58,7 @@ return {
|
||||
{ nil, "/**" },
|
||||
{ "parameters", " * @param {any} %s " },
|
||||
{ "return_statement", " * @returns {any} " },
|
||||
{ nil, " */" }
|
||||
}
|
||||
}
|
||||
{ nil, " */" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -67,6 +67,7 @@ return {
|
||||
annotation_convention = "emmylua",
|
||||
emmylua = {
|
||||
{ nil, "- " },
|
||||
{ nil, "- ", { no_results = true } },
|
||||
{ "parameters", "- @param %s any" },
|
||||
{ "vararg", "- @vararg any" },
|
||||
{ "return_statement", "- @return any" },
|
||||
|
||||
@@ -106,6 +106,7 @@ return {
|
||||
use_default_comment = false, -- If you want to prefix the template with the default comment for the language, e.g for python: # (default_generator)
|
||||
google_docstrings = {
|
||||
{ nil, '"""' },
|
||||
{ nil, '""" """', { no_results = true } },
|
||||
{ "parameters", "\t%s: ", { before_first_item = { "", "Args:" } } },
|
||||
{ "attributes", "\t%s: ", { before_first_item = { "", "Attributes: " } } },
|
||||
{ "return_statement", "", { before_first_item = { "", "Returns: " } } },
|
||||
@@ -114,6 +115,7 @@ return {
|
||||
},
|
||||
numpydoc = {
|
||||
{ nil, '"""' },
|
||||
{ nil, '""" """', { no_results = true } },
|
||||
{ "parameters", "%s: ", { before_first_item = { "", "Parameters", "----------" } } },
|
||||
{ "attributes", "%s: ", { before_first_item = { "", "Attributes", "----------" } } },
|
||||
{ "return_statement", "", { before_first_item = { "", "Returns", "-------" } } },
|
||||
|
||||
Reference in New Issue
Block a user