feat(python): Add support for throw statements

Closes #106

Support currently reST annotations
This commit is contained in:
danymat
2022-10-17 12:33:34 +02:00
parent 3ea6a2a638
commit 8624a73c86
3 changed files with 19 additions and 2 deletions

View File

@@ -71,6 +71,19 @@ return {
recursive = true, recursive = true,
extract = true, extract = true,
}, },
{
retrieve = "all",
node_type = "raise_statement",
recursive = true,
subtree = {
{
retrieve = "first",
node_type = "identifier",
extract = true,
as = i.Throw,
},
},
},
}, },
}, },
{ {
@@ -133,6 +146,7 @@ return {
or nil or nil
results[i.ArbitraryArgs] = res[i.ArbitraryArgs] results[i.ArbitraryArgs] = res[i.ArbitraryArgs]
results[i.Kwargs] = res[i.Kwargs] results[i.Kwargs] = res[i.Kwargs]
results[i.Throw] = res[i.Throw]
return results return results
end, end,
}, },

View File

@@ -241,6 +241,9 @@ end
--- ---
--- Note: We will only document `major` and `minor` versions, not `patch` ones. (only X and Y in X.Y.z) --- Note: We will only document `major` and `minor` versions, not `patch` ones. (only X and Y in X.Y.z)
--- ---
--- ## 2.10.0~
--- - Add support for Throw statements in python
--- Note: only active for reST template as of right now (please open an issue request for more templates)
--- ## 2.9.0~ --- ## 2.9.0~
--- - Add support for `vsnip` snippet engine ! (see |neogen-snippet-integration|) --- - Add support for `vsnip` snippet engine ! (see |neogen-snippet-integration|)
--- ## 2.8.0~ --- ## 2.8.0~
@@ -282,7 +285,7 @@ end
--- with multiple annotation conventions. --- with multiple annotation conventions.
---@tag neogen-changelog ---@tag neogen-changelog
---@toc_entry Changes in neogen plugin ---@toc_entry Changes in neogen plugin
neogen.version = "2.9.2" neogen.version = "2.10.0"
--minidoc_afterlines_end --minidoc_afterlines_end
return neogen return neogen

View File

@@ -1,6 +1,5 @@
local i = require("neogen.types.template").item local i = require("neogen.types.template").item
return { return {
{ nil, '""" $1 """', { no_results = true, type = { "class", "func" } } }, { nil, '""" $1 """', { no_results = true, type = { "class", "func" } } },
{ nil, '"""$1', { no_results = true, type = { "file" } } }, { nil, '"""$1', { no_results = true, type = { "file" } } },
@@ -27,6 +26,7 @@ return {
}, },
}, },
{ i.ClassAttribute, ":param %s: $1" }, { i.ClassAttribute, ":param %s: $1" },
{ i.Throw, ":raises %s: $1", { type = { "func" } } },
{ i.HasReturn, ":return: $1", { type = { "func" } } }, { i.HasReturn, ":return: $1", { type = { "func" } } },
{ i.HasReturn, ":rtype: $1", { type = { "func" } } }, { i.HasReturn, ":rtype: $1", { type = { "func" } } },
{ nil, '"""' }, { nil, '"""' },