lol

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

authored by

Pol Dellaiera and committed by
Valentin Gagarin
58cdd4e3 4d9f9647

+41 -1
+6 -1
doc/doc-support/package.nix
··· 12 nixos-render-docs-redirects, 13 writeShellScriptBin, 14 nixpkgs ? { }, 15 }: 16 17 stdenvNoCC.mkDerivation ( ··· 119 packages = [ 120 devmode' 121 nixos-render-docs-redirects' 122 ]; 123 }; 124 125 - tests.manpage-urls = callPackage ../tests/manpage-urls.nix { }; 126 }; 127 } 128 )
··· 12 nixos-render-docs-redirects, 13 writeShellScriptBin, 14 nixpkgs ? { }, 15 + markdown-code-runner, 16 }: 17 18 stdenvNoCC.mkDerivation ( ··· 120 packages = [ 121 devmode' 122 nixos-render-docs-redirects' 123 + markdown-code-runner 124 ]; 125 }; 126 127 + tests = { 128 + manpage-urls = callPackage ../tests/manpage-urls.nix { }; 129 + check-nix-code-blocks = callPackage ../tests/check-nix-code-blocks.nix { }; 130 + }; 131 }; 132 } 133 )
+32
doc/tests/check-nix-code-blocks.nix
···
··· 1 + { 2 + runCommand, 3 + markdown-code-runner, 4 + nixfmt-rfc-style, 5 + }: 6 + 7 + runCommand "manual_check-nix-code-blocks" 8 + { 9 + nativeBuildInputs = [ 10 + markdown-code-runner 11 + nixfmt-rfc-style 12 + ]; 13 + } 14 + '' 15 + set +e 16 + 17 + mdcr --check --config ${./mdcr-config.toml} ${./..} 18 + 19 + if [ $? -ne 0 ]; then 20 + cat <<EOF 21 + Error: `mdcr` command failed. Please make sure the Nix code snippets in Markdown files are correctly formatted. 22 + 23 + Run this command from the Nixpkgs repository root for automatic formatting: 24 + 25 + mdcr --log debug --config ${toString ./..}/tests/mdcr-config.toml ${toString ./..} 26 + 27 + EOF 28 + exit 1 29 + fi 30 + 31 + touch "$out" 32 + ''
+3
doc/tests/mdcr-config.toml
···
··· 1 + [presets.nixfmt] 2 + language = "nix" 3 + command = ["nixfmt"]