Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtins/diagnostics: add pydoclint #181

Merged
merged 8 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions doc/BUILTINS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1010,6 +1010,23 @@ local sources = { null_ls.builtins.diagnostics.mypy }
- Command: `mypy`
- Args: dynamically resolved (see [source](https://github.com/nvimtools/none-ls.nvim/blob/main/lua/null-ls/builtins/diagnostics/mypy.lua))

### [pydoclint](https://jsh9.github.io/pydoclint/)

Pydoclint is a Python docstring linter to check whether a docstring's sections (arguments, returns, raises, ...) match the function signature or function implementation.
Usage

```lua
local sources = { null_ls.builtins.diagnostics.pydoclint }
```

#### Defaults

- Filetypes: `{ "python" }`
- Method: `diagnostics`
- Command: `pydoclint`
- Args: dynamically resolved (see source)


### [npm_groovy_lint](https://github.com/nvuillam/npm-groovy-lint)

Lint, format and auto-fix Groovy, Jenkinsfile, and Gradle files.
Expand Down
36 changes: 36 additions & 0 deletions lua/null-ls/builtins/diagnostics/pydoclint.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
local h = require("null-ls.helpers")
local methods = require("null-ls.methods")

local DIAGNOSTICS = methods.internal.DIAGNOSTICS

return h.make_builtin({
name = "pydoclint",
meta = {
url = "https://github.com/jsh9/pydoclint",
description = "Pydoclint is a Python docstring linter to check whether a docstring's sections (arguments, returns, raises, ...) match the function signature or function implementation. To see all violation codes go to [pydoclint](https://jsh9.github.io/pydoclint/violation_codes.html)",
},
method = DIAGNOSTICS,
filetypes = { "python" },
generator_opts = {
command = "pydoclint",
args = {
"--show-filenames-in-every-violation-message=true",
"-q",
"$FILENAME",
},
to_temp_file = true,
from_stderr = true,
format = "line",
check_exit_code = function(code)
return code <= 2
end,
multiple_files = false,
on_output = function(line, params)
local path = params.temp_path
-- rel/path/to/file.py:42: DOC000: Diagnostic message
local pattern = path .. [[:(%d+): (DOC%d+: .*)]]
return h.diagnostics.from_pattern(pattern, { "row", "message" })(line, params)
end,
},
factory = h.generator_factory,
})
Loading