Skip to content

Commit a7b3b25

Browse files
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.
1 parent fed181f commit a7b3b25

File tree

4 files changed

+17
-36
lines changed

4 files changed

+17
-36
lines changed

ci/default.nix

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,23 @@ let
7575
includes = [ "*" ];
7676
priority = 1;
7777
};
78+
79+
# TODO: Upstream this into treefmt-nix eventually:
80+
# https://github.com/numtide/treefmt-nix/issues/387
81+
settings.formatter.markdown-code-runner = {
82+
command = pkgs.lib.getExe pkgs.markdown-code-runner;
83+
options =
84+
let
85+
config = pkgs.writers.writeTOML "markdown-code-runner-config" {
86+
presets.nixfmt = {
87+
language = "nix";
88+
command = [ (pkgs.lib.getExe pkgs.nixfmt) ];
89+
};
90+
};
91+
in
92+
[ "--config=${config}" ];
93+
includes = [ "*.md" ];
94+
};
7895
};
7996
fs = pkgs.lib.fileset;
8097
nixFilesSrc = fs.toSource {

doc/doc-support/package.nix

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ stdenvNoCC.mkDerivation (
137137

138138
tests = {
139139
manpage-urls = callPackage ../tests/manpage-urls.nix { };
140-
check-nix-code-blocks = callPackage ../tests/check-nix-code-blocks.nix { };
141140
};
142141
};
143142
}

doc/tests/check-nix-code-blocks.nix

Lines changed: 0 additions & 32 deletions
This file was deleted.

doc/tests/mdcr-config.toml

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)