Merge pull request #124 from cdbrendel/fix-python-args

Fix parameters in python docstrings
This commit is contained in:
Daniel
2023-01-12 22:38:13 +01:00
committed by GitHub
3 changed files with 11 additions and 7 deletions

View File

@@ -50,7 +50,7 @@ return {
retrieve = "all", retrieve = "all",
node_type = "typed_default_parameter", node_type = "typed_default_parameter",
as = i.Tparam, as = i.Tparam,
extract = true extract = true,
}, },
{ {
retrieve = "first", retrieve = "first",
@@ -85,6 +85,7 @@ return {
{ {
retrieve = "first", retrieve = "first",
node_type = "identifier", node_type = "identifier",
recursive = true,
extract = true, extract = true,
as = i.Throw, as = i.Throw,
}, },
@@ -126,7 +127,7 @@ return {
-- Check if the function is inside a class -- Check if the function is inside a class
-- If so, remove reference to the first parameter (that can be `self`, `cls`, or a custom name) -- If so, remove reference to the first parameter (that can be `self`, `cls`, or a custom name)
if res.identifier and locator({ current = node }, parent.class) then if res[i.Parameter] and locator({ current = node }, parent.class) then
local remove_identifier = true local remove_identifier = true
-- Check if function is a static method. If so, will not remove the first parameter -- Check if function is a static method. If so, will not remove the first parameter
if node:parent():type() == "decorated_definition" then if node:parent():type() == "decorated_definition" then
@@ -137,9 +138,9 @@ return {
end end
end end
if remove_identifier then if remove_identifier then
table.remove(res.identifier, 1) table.remove(res[i.Parameter], 1)
if vim.tbl_isempty(res.identifier) then if vim.tbl_isempty(res[i.Parameter]) then
res.identifier = nil res[i.Parameter] = nil
end end
end end
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.13.0~
--- - Improve google docstrings template (#124)
--- - Fix minor python retriever issues (#124)
--- ## 2.12.0~ --- ## 2.12.0~
--- - Fetch singleton methods in ruby (#121) --- - Fetch singleton methods in ruby (#121)
--- ## 2.11.0~ --- ## 2.11.0~
@@ -292,7 +295,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.12.0" neogen.version = "2.13.0"
--minidoc_afterlines_end --minidoc_afterlines_end
return neogen return neogen

View File

@@ -14,7 +14,7 @@ return {
{ i.HasParameter, "", { type = { "func" } } }, { i.HasParameter, "", { type = { "func" } } },
{ i.HasParameter, "Args:", { type = { "func" } } }, { i.HasParameter, "Args:", { type = { "func" } } },
{ i.Parameter, " %s ($1): $1", { type = { "func" } } }, { i.Parameter, " %s ($1): $1", { type = { "func" } } },
{ { i.Parameter, i.Type }, " %s (%s): $1", { required = i.Tparam, type = { "func" } } }, { { i.Parameter, i.Type }, " %s: $1", { required = i.Tparam, type = { "func" } } },
{ 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: " } } },