mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-09 19:13:26 +03:00
{nixpkgs-manual, nixos-manual}: add new test check-nix-code-blocks
This commit is contained in:
parent
4d9f964794
commit
58cdd4e315
3 changed files with 41 additions and 1 deletions
|
@ -12,6 +12,7 @@
|
|||
nixos-render-docs-redirects,
|
||||
writeShellScriptBin,
|
||||
nixpkgs ? { },
|
||||
markdown-code-runner,
|
||||
}:
|
||||
|
||||
stdenvNoCC.mkDerivation (
|
||||
|
@ -119,10 +120,14 @@ stdenvNoCC.mkDerivation (
|
|||
packages = [
|
||||
devmode'
|
||||
nixos-render-docs-redirects'
|
||||
markdown-code-runner
|
||||
];
|
||||
};
|
||||
|
||||
tests.manpage-urls = callPackage ../tests/manpage-urls.nix { };
|
||||
tests = {
|
||||
manpage-urls = callPackage ../tests/manpage-urls.nix { };
|
||||
check-nix-code-blocks = callPackage ../tests/check-nix-code-blocks.nix { };
|
||||
};
|
||||
};
|
||||
}
|
||||
)
|
||||
|
|
32
doc/tests/check-nix-code-blocks.nix
Normal file
32
doc/tests/check-nix-code-blocks.nix
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
runCommand,
|
||||
markdown-code-runner,
|
||||
nixfmt-rfc-style,
|
||||
}:
|
||||
|
||||
runCommand "manual_check-nix-code-blocks"
|
||||
{
|
||||
nativeBuildInputs = [
|
||||
markdown-code-runner
|
||||
nixfmt-rfc-style
|
||||
];
|
||||
}
|
||||
''
|
||||
set +e
|
||||
|
||||
mdcr --check --config ${./mdcr-config.toml} ${./..}
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
cat <<EOF
|
||||
Error: `mdcr` command failed. Please make sure the Nix code snippets in Markdown files are correctly formatted.
|
||||
|
||||
Run this command from the Nixpkgs repository root for automatic formatting:
|
||||
|
||||
mdcr --log debug --config ${toString ./..}/tests/mdcr-config.toml ${toString ./..}
|
||||
|
||||
EOF
|
||||
exit 1
|
||||
fi
|
||||
|
||||
touch "$out"
|
||||
''
|
3
doc/tests/mdcr-config.toml
Normal file
3
doc/tests/mdcr-config.toml
Normal file
|
@ -0,0 +1,3 @@
|
|||
[presets.nixfmt]
|
||||
language = "nix"
|
||||
command = ["nixfmt"]
|
Loading…
Add table
Add a link
Reference in a new issue