Add support for empty jsdoc comment
This commit is contained in:
@@ -35,7 +35,7 @@ neogen.auto_generate = function(custom_template)
|
|||||||
-- Use the language granulator to get the required content inside the node found with the locator
|
-- Use the language granulator to get the required content inside the node found with the locator
|
||||||
local data = language.granulator(located_parent_node, language.data)
|
local data = language.granulator(located_parent_node, language.data)
|
||||||
|
|
||||||
if data and not vim.tbl_isempty(data) then
|
if data then
|
||||||
-- Will try to generate the documentation from a template and the data found from the granulator
|
-- Will try to generate the documentation from a template and the data found from the granulator
|
||||||
local to_place, start_column, content = language.generator(
|
local to_place, start_column, content = language.generator(
|
||||||
located_parent_node,
|
located_parent_node,
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ return {
|
|||||||
use_default_comment = false,
|
use_default_comment = false,
|
||||||
|
|
||||||
jsdoc = {
|
jsdoc = {
|
||||||
|
{ nil, "/* */", { no_results = true } },
|
||||||
{ nil, "/**" },
|
{ nil, "/**" },
|
||||||
{ "parameters", " * @param {any} %s " },
|
{ "parameters", " * @param {any} %s " },
|
||||||
{ "return_statement", " * @returns {any} " },
|
{ "return_statement", " * @returns {any} " },
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ neogen.default_generator = function(parent, data, template)
|
|||||||
|
|
||||||
-- Checks for custom options
|
-- Checks for custom options
|
||||||
-- Supported options:
|
-- Supported options:
|
||||||
-- - before_first_item = value
|
-- - before_first_item = string[]
|
||||||
|
-- - no_params = bool
|
||||||
local opts = values[3] or {}
|
local opts = values[3] or {}
|
||||||
|
|
||||||
-- Will append the item before all their nodes
|
-- Will append the item before all their nodes
|
||||||
@@ -62,15 +63,19 @@ neogen.default_generator = function(parent, data, template)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not type then
|
if opts.no_results == true and vim.tbl_isempty(data) then
|
||||||
table.insert(result, prefix .. values[2]:format(""))
|
table.insert(result, prefix .. values[2])
|
||||||
else
|
else
|
||||||
if data[type] then
|
if not type and opts.no_results ~= true and not vim.tbl_isempty(data) then
|
||||||
if #vim.tbl_values(data[type]) == 1 then
|
table.insert(result, prefix .. values[2]:format(""))
|
||||||
table.insert(result, prefix .. values[2]:format(data[type][1]))
|
else
|
||||||
else
|
if data[type] then
|
||||||
for _, value in ipairs(data[type]) do
|
if #vim.tbl_values(data[type]) == 1 then
|
||||||
table.insert(result, prefix .. values[2]:format(value))
|
table.insert(result, prefix .. values[2]:format(data[type][1]))
|
||||||
|
else
|
||||||
|
for _, value in ipairs(data[type]) do
|
||||||
|
table.insert(result, prefix .. values[2]:format(value))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user