Skip to content

Commit

Permalink
builtins/diagnostics: add pydoclint (#181)
Browse files Browse the repository at this point in the history
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Zephyr Lykos <[email protected]>
  • Loading branch information
3 people authored Jan 17, 2025
1 parent 3291afd commit b93e44d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
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,
})

0 comments on commit b93e44d

Please sign in to comment.