mirror of
https://github.com/CHN-beta/nixpkgs.git
synced 2026-01-11 18:32:23 +08:00
ci/treefmt: add markdown-code-runner
This was run as a test in `doc/tests/check-nix-code-blocks.nix` before,
but its DX can be improved: By including it in `treefmt` we get better
error reporting and auto-fixing, as well as running it on *all* markdown
files (including READMEs etc.) for free.
(cherry picked from commit a7b3b2584a)
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
{
|
||||
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"
|
||||
''
|
||||
@@ -1,3 +0,0 @@
|
||||
[presets.nixfmt]
|
||||
language = "nix"
|
||||
command = ["nixfmt"]
|
||||
Reference in New Issue
Block a user