feat(ts,js) Add support for file annotations (#31)

This commit is contained in:
danymat
2022-01-09 14:15:01 +01:00
parent 24a0498477
commit d8f0d24cc6
3 changed files with 38 additions and 9 deletions

View File

@@ -19,6 +19,7 @@ return {
parent = {
func = { "function_declaration", "expression_statement", "variable_declaration", "lexical_declaration" },
class = { "function_declaration", "expression_statement", "variable_declaration", "class_declaration" },
file = { "program" },
},
data = {
@@ -79,6 +80,15 @@ return {
},
},
},
file = {
["program"] = {
["0"] = {
extract = function()
return {}
end,
},
},
},
},
template = {
@@ -86,7 +96,12 @@ return {
use_default_comment = false,
jsdoc = {
{ nil, "/* $1 */", { no_results = true } },
{ nil, "/* $1 */", { no_results = true, type = { "func", "class" } } },
{ nil, "/**", { no_results = true, type = { "file" } } },
{ nil, " * @module $1", { no_results = true, type = { "file" } } },
{ nil, " */", { no_results = true, type = { "file" } } },
{ nil, "/**" },
{ "class_tag", " * @classdesc $1", { before_first_item = { " * ", " * @class" }, type = { "class" } } },
{ "parameters", " * @param {any} %s $1" },

View File

@@ -33,6 +33,7 @@ return {
func = { "function_declaration", "expression_statement", "variable_declaration", "lexical_declaration" },
class = { "function_declaration", "expression_statement", "variable_declaration", "class_declaration" },
type = { "variable_declaration" },
file = { "program" },
},
data = {
@@ -114,14 +115,27 @@ return {
},
},
},
file = {
["program"] = {
["0"] = {
extract = function()
return {}
end,
},
},
},
},
template = {
annotation_convention = "jsdoc",
use_default_comment = false,
jsdoc = {
{ nil, "/* $1 */", { no_results = true } },
{ nil, "/* $1 */", { no_results = true, type = { "class", "func" } } },
{ nil, "/**", { no_results = true, type = { "file" } } },
{ nil, " * @module $1", { no_results = true, type = { "file" } } },
{ nil, " */", { no_results = true, type = { "file" } } },
{ nil, "/**" },
{ "class_tag", " * @classdesc $1", { before_first_item = { " * ", " * @class" }, type = { "class" } } },
{ "parameters", " * @param {any} %s $1" },