1{ lib
2, buildPythonPackage
3, docutils
4, fetchFromGitHub
5, importlib-metadata
6, poetry-core
7, pydantic
8, pytestCheckHook
9, pythonOlder
10, rstcheck-core
11, typer
12, types-docutils
13, typing-extensions
14}:
15
16buildPythonPackage rec {
17 pname = "rstcheck";
18 version = "6.1.0";
19 format = "pyproject";
20
21 disabled = pythonOlder "3.7";
22
23 src = fetchFromGitHub {
24 owner = "rstcheck";
25 repo = pname;
26 rev = "v${version}";
27 hash = "sha256-dw/KggiZpKaFZMcTIaSBUhR4oQsZI3iSmEj9Sy80wTs=";
28 };
29
30 nativeBuildInputs = [
31 poetry-core
32 ];
33
34 propagatedBuildInputs = [
35 docutils
36 rstcheck-core
37 types-docutils
38 typing-extensions
39 pydantic
40 typer
41 ] ++ lib.optionals (pythonOlder "3.8") [
42 typing-extensions
43 importlib-metadata
44 ] ++ typer.optional-dependencies.all;
45
46 checkInputs = [
47 pytestCheckHook
48 ];
49
50 postPatch = ''
51 substituteInPlace pyproject.toml \
52 --replace 'docutils = ">=0.7, <0.19"' 'docutils = ">=0.7"' \
53 --replace 'types-docutils = ">=0.18, <0.19"' 'types-docutils = ">=0.18"'
54 '';
55
56 pythonImportsCheck = [
57 "rstcheck"
58 ];
59
60 preCheck = ''
61 # The tests need to find and call the rstcheck executable
62 export PATH="$PATH:$out/bin";
63 '';
64
65 meta = with lib; {
66 description = "Checks syntax of reStructuredText and code blocks nested within it";
67 homepage = "https://github.com/myint/rstcheck";
68 license = licenses.mit;
69 maintainers = with maintainers; [ staccato ];
70 };
71}