mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-11 18:32:23 +08:00
{nixpkgs-manual, nixos-manual}: add new test check-nix-code-blocks
This commit is contained in:
committed by
Valentin Gagarin
parent
4d9f964794
commit
58cdd4e315
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"]
|
||||
Reference in New Issue
Block a user