Fix python docstrings (#120)

* fix(py): Return "Args:" if parameters
* fix(py): catch typed default parameters
This commit is contained in:
Daniel
2022-12-28 11:43:40 +01:00
committed by GitHub
parent 05e7ca83bb
commit 254301a044
3 changed files with 15 additions and 28 deletions

View File

@@ -49,15 +49,8 @@ return {
{
retrieve = "all",
node_type = "typed_default_parameter",
extract = true,
subtree = {
{
retrieve = "all",
node_type = "identifier",
extract = true,
as = i.Tparam,
},
},
as = i.Tparam,
extract = true
},
{
retrieve = "first",
@@ -153,14 +146,14 @@ return {
local results = helpers.copy({
[i.HasParameter] = function(t)
return t[i.Parameter] and { true } or nil
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] = function(t)
return t[i.Parameter]
end,
[i.Parameter] = true,
[i.Return] = true,
[i.HasReturn] = true,
[i.ReturnTypeHint] = true,
[i.ArbitraryArgs] = true,
[i.Kwargs] = true,
@@ -168,9 +161,6 @@ return {
[i.Tparam] = true,
}, res) or {}
-- Generates a "flag" return
results[i.HasReturn] = (results[i.ReturnTypeHint] or results[i.Return]) and { true } or nil
-- Removes generation for returns that are not typed
if results[i.ReturnTypeHint] then
results[i.Return] = nil