Add support for numpydoc

This commit is contained in:
Daniel Mathiot
2021-08-23 19:11:44 +02:00
parent 88c4d40078
commit ee1e1a491c
3 changed files with 17 additions and 5 deletions

View File

@@ -113,10 +113,19 @@ 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, '"""' },
{ "parameters", "\t%s: ", { before_first_item = "Args: " } },
{ "attributes", "\t%s: ", { before_first_item = "Attributes: " } },
{ "return_statement", "", { before_first_item = "Returns: " } },
{ "parameters", "\t%s: ", { before_first_item = { "", "Args:" } } },
{ "attributes", "\t%s: ", { before_first_item = { "", "Attributes: " } } },
{ "return_statement", "", { before_first_item = { "", "Returns: " } } },
{ nil, "" },
{ nil, '"""' },
},
numpydoc = {
{ nil, '"""' },
{ "parameters", "%s: ", { before_first_item = { "", "Parameters", "----------" } } },
{ "attributes", "%s: ", { before_first_item = { "", "Attributes", "----------" } } },
{ "return_statement", "", { before_first_item = { "", "Returns", "-------" } } },
{ nil, "" },
{ nil, '"""' }
}
},
}

View File

@@ -57,7 +57,9 @@ neogen.default_generator = function(parent, data, template)
-- Will append the item before all their nodes
if opts.before_first_item and data[type] then
table.insert(result, prefix .. opts.before_first_item)
for _, value in pairs(opts.before_first_item) do
table.insert(result, prefix .. value)
end
end
if not type then