feat(python): Add Raises: block for google_docstrings (#143)

* Added Google docstring Raises: block

* Added Google docstring change to the Changelog

* Fixed duplicate "Raises:" block, for Python google-style docstrings

* doc: Version

---------

Co-authored-by: danymat <d.danymat@gmail.com>
This commit is contained in:
Colin Kennedy
2023-05-31 04:03:58 -07:00
committed by GitHub
parent e449d5b7ff
commit a113ca9a54
6 changed files with 28 additions and 16 deletions

View File

@@ -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) 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~ ## 2.13.0~
- Improve google docstrings template (#124) - Improve google docstrings template (#124)
- Fix minor python retriever issues (#124) - Fix minor python retriever issues (#124)

View File

@@ -151,21 +151,24 @@ return {
end end
local results = helpers.copy({ local results = helpers.copy({
[i.HasParameter] = function(t) [i.HasParameter] = function(t)
return (t[i.Parameter] or t[i.Tparam]) and { true } return (t[i.Parameter] or t[i.Tparam]) and { true }
end, end,
[i.HasReturn] = function(t) [i.HasReturn] = function(t)
return (t[i.ReturnTypeHint] or t[i.Return]) and { true } return (t[i.ReturnTypeHint] or t[i.Return]) and { true }
end, end,
[i.Type] = true, [i.HasThrow] = function(t)
[i.Parameter] = true, return t[i.Throw] and { true }
[i.Return] = true, end,
[i.ReturnTypeHint] = true, [i.Type] = true,
[i.ArbitraryArgs] = true, [i.Parameter] = true,
[i.Kwargs] = true, [i.Return] = true,
[i.Throw] = true, [i.ReturnTypeHint] = true,
[i.Tparam] = true, [i.ArbitraryArgs] = true,
}, res) or {} [i.Kwargs] = true,
[i.Throw] = true,
[i.Tparam] = true,
}, res) or {}
-- Removes generation for returns that are not typed -- Removes generation for returns that are not typed
if results[i.ReturnTypeHint] then if results[i.ReturnTypeHint] then

View File

@@ -35,6 +35,7 @@ local function todo_text(type)
[i.ClassAttribute] = todo["attribute"], [i.ClassAttribute] = todo["attribute"],
[i.HasParameter] = todo["parameter"], [i.HasParameter] = todo["parameter"],
[i.HasReturn] = todo["return"], [i.HasReturn] = todo["return"],
[i.HasThrow] = todo["throw"],
[i.ArbitraryArgs] = todo["args"], [i.ArbitraryArgs] = todo["args"],
[i.Kwargs] = todo["kwargs"], [i.Kwargs] = todo["kwargs"],
})[type] or todo["description"] })[type] or todo["description"]

View File

@@ -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) --- 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~ --- ## 2.13.0~
--- - Improve google docstrings template (#124) --- - Improve google docstrings template (#124)
--- - Fix minor python retriever issues (#124) --- - Fix minor python retriever issues (#124)
@@ -295,7 +297,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.13.2" neogen.version = "2.14.0"
--minidoc_afterlines_end --minidoc_afterlines_end
return neogen return neogen

View File

@@ -18,6 +18,9 @@ return {
{ i.ArbitraryArgs, " %s: $1", { type = { "func" } } }, { i.ArbitraryArgs, " %s: $1", { type = { "func" } } },
{ i.Kwargs, " %s: $1", { type = { "func" } } }, { i.Kwargs, " %s: $1", { type = { "func" } } },
{ i.ClassAttribute, " %s: $1", { before_first_item = { "", "Attributes: " } } }, { 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, "", { type = { "func" } } },
{ i.HasReturn, "Returns:", { type = { "func" } } }, { i.HasReturn, "Returns:", { type = { "func" } } },
{ i.HasReturn, " $1", { type = { "func" } } }, { i.HasReturn, " $1", { type = { "func" } } },

View File

@@ -18,6 +18,7 @@ template.item = {
ClassAttribute = "attributes", ClassAttribute = "attributes",
HasParameter = "has_parameters", HasParameter = "has_parameters",
HasReturn = "has_return", HasReturn = "has_return",
HasThrow = "has_throw",
ArbitraryArgs = "arbitrary_args", ArbitraryArgs = "arbitrary_args",
Kwargs = "kwargs", Kwargs = "kwargs",
} }