diff --git a/doc/neogen.txt b/doc/neogen.txt index 628a698..8d2e095 100644 --- a/doc/neogen.txt +++ b/doc/neogen.txt @@ -189,6 +189,8 @@ Here is the current Neogen version: Note: We will only document `major` and `minor` versions, not `patch` ones. (only X and Y in X.Y.z) +## 2.14.0~ + - Google docstrings now include "Raises:", whenever possible ## 2.13.0~ - Improve google docstrings template (#124) - Fix minor python retriever issues (#124) diff --git a/lua/neogen/configurations/python.lua b/lua/neogen/configurations/python.lua index 97e6860..cf98ed9 100644 --- a/lua/neogen/configurations/python.lua +++ b/lua/neogen/configurations/python.lua @@ -151,21 +151,24 @@ return { end local results = helpers.copy({ - [i.HasParameter] = function(t) - return (t[i.Parameter] or t[i.Tparam]) and { true } - end, - [i.HasReturn] = function(t) - return (t[i.ReturnTypeHint] or t[i.Return]) and { true } - end, - [i.Type] = true, - [i.Parameter] = true, - [i.Return] = true, - [i.ReturnTypeHint] = true, - [i.ArbitraryArgs] = true, - [i.Kwargs] = true, - [i.Throw] = true, - [i.Tparam] = true, - }, res) or {} + [i.HasParameter] = function(t) + return (t[i.Parameter] or t[i.Tparam]) and { true } + end, + [i.HasReturn] = function(t) + return (t[i.ReturnTypeHint] or t[i.Return]) and { true } + end, + [i.HasThrow] = function(t) + return t[i.Throw] and { true } + end, + [i.Type] = true, + [i.Parameter] = true, + [i.Return] = true, + [i.ReturnTypeHint] = true, + [i.ArbitraryArgs] = true, + [i.Kwargs] = true, + [i.Throw] = true, + [i.Tparam] = true, + }, res) or {} -- Removes generation for returns that are not typed if results[i.ReturnTypeHint] then diff --git a/lua/neogen/generator.lua b/lua/neogen/generator.lua index 38891be..6810b27 100644 --- a/lua/neogen/generator.lua +++ b/lua/neogen/generator.lua @@ -35,6 +35,7 @@ local function todo_text(type) [i.ClassAttribute] = todo["attribute"], [i.HasParameter] = todo["parameter"], [i.HasReturn] = todo["return"], + [i.HasThrow] = todo["throw"], [i.ArbitraryArgs] = todo["args"], [i.Kwargs] = todo["kwargs"], })[type] or todo["description"] diff --git a/lua/neogen/init.lua b/lua/neogen/init.lua index f6d5fa9..6c874f8 100644 --- a/lua/neogen/init.lua +++ b/lua/neogen/init.lua @@ -241,6 +241,8 @@ end --- --- Note: We will only document `major` and `minor` versions, not `patch` ones. (only X and Y in X.Y.z) --- +--- ## 2.14.0~ +--- - Google docstrings now include "Raises:", whenever possible --- ## 2.13.0~ --- - Improve google docstrings template (#124) --- - Fix minor python retriever issues (#124) @@ -295,7 +297,7 @@ end --- with multiple annotation conventions. ---@tag neogen-changelog ---@toc_entry Changes in neogen plugin -neogen.version = "2.13.2" +neogen.version = "2.14.0" --minidoc_afterlines_end return neogen diff --git a/lua/neogen/templates/google_docstrings.lua b/lua/neogen/templates/google_docstrings.lua index cdc78f5..1c29ead 100644 --- a/lua/neogen/templates/google_docstrings.lua +++ b/lua/neogen/templates/google_docstrings.lua @@ -18,6 +18,9 @@ return { { i.ArbitraryArgs, " %s: $1", { type = { "func" } } }, { i.Kwargs, " %s: $1", { type = { "func" } } }, { i.ClassAttribute, " %s: $1", { before_first_item = { "", "Attributes: " } } }, + { i.HasThrow, "", { type = { "func" } } }, + { i.HasThrow, "Raises:", { type = { "func" } } }, + { i.Throw, " %s: $1", { type = { "func" } } }, { i.HasReturn, "", { type = { "func" } } }, { i.HasReturn, "Returns:", { type = { "func" } } }, { i.HasReturn, " $1", { type = { "func" } } }, diff --git a/lua/neogen/types/template.lua b/lua/neogen/types/template.lua index ade0c72..1632ca9 100644 --- a/lua/neogen/types/template.lua +++ b/lua/neogen/types/template.lua @@ -18,6 +18,7 @@ template.item = { ClassAttribute = "attributes", HasParameter = "has_parameters", HasReturn = "has_return", + HasThrow = "has_throw", ArbitraryArgs = "arbitrary_args", Kwargs = "kwargs", }