{nixpkgs-manual, nixos-manual}: add new test `check-nix-code-blocks`

Changed files
+41 -1
doc
+6 -1
doc/doc-support/package.nix
···
nixos-render-docs-redirects,
writeShellScriptBin,
nixpkgs ? { },
+
markdown-code-runner,
}:
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
···
+
{
+
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
···
+
[presets.nixfmt]
+
language = "nix"
+
command = ["nixfmt"]