Add utilities

After a refactoring of utilities, I added a function to get the first
child node that matches the node name.

Documentation is provided in neogen.utilities.nodes
This commit is contained in:
Daniel Mathiot
2021-08-23 16:00:43 +02:00
parent 6b08b2297c
commit 52128c1bd5
7 changed files with 46 additions and 22 deletions

View File

@@ -11,7 +11,7 @@ return {
match = "parameters",
extract = function(node)
local regular_params = neogen.utility:extract_children("identifier")(node)
local regular_params = neogen.utilities.extractors:extract_children_text("identifier")(node)
return {
parameters = regular_params,
@@ -19,6 +19,15 @@ return {
end,
},
},
["class_definition"] = {
["2"] = {
match = "block",
extract = function(node)
return {}
end,
},
},
},
-- Use default granulator and generator
@@ -29,7 +38,7 @@ return {
template = {
annotation_convention = "google_docstrings", -- required: Which annotation convention to use (default_generator)
append = { position = "after", child_name = "block" }, -- optional: where to append the text (default_generator)
use_default_comment = false, -- If you want to prefix the template with the default comment for the language (default_generator)
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: " } },