mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 03:23:29 +03:00
tests.nixosOptionsDoc: init
This commit is contained in:
parent
9e0b42e0f7
commit
e2078ef31e
3 changed files with 63 additions and 0 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
# Tests: ./tests.nix
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Generates documentation for [nix modules](https://nix.dev/tutorials/module-system/index.html).
|
Generates documentation for [nix modules](https://nix.dev/tutorials/module-system/index.html).
|
||||||
|
|
||||||
|
|
59
nixos/lib/make-options-doc/tests.nix
Normal file
59
nixos/lib/make-options-doc/tests.nix
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
# Run tests: nix-build -A tests.nixosOptionsDoc
|
||||||
|
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
nixosOptionsDoc,
|
||||||
|
runCommand,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib) mkOption types;
|
||||||
|
|
||||||
|
eval = lib.evalModules {
|
||||||
|
modules = [
|
||||||
|
{
|
||||||
|
options.foo.bar.enable = mkOption {
|
||||||
|
type = types.bool;
|
||||||
|
default = false;
|
||||||
|
description = ''
|
||||||
|
Enable the foo bar feature.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
doc = nixosOptionsDoc {
|
||||||
|
inherit (eval) options;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
Test that
|
||||||
|
- the `nixosOptionsDoc` function can be invoked
|
||||||
|
- integration of the module system and `nixosOptionsDoc` (limited coverage)
|
||||||
|
|
||||||
|
The more interesting tests happen in the `nixos-render-docs` package.
|
||||||
|
*/
|
||||||
|
commonMark =
|
||||||
|
runCommand "test-nixosOptionsDoc-commonMark"
|
||||||
|
{
|
||||||
|
commonMarkDefault = doc.optionsCommonMark;
|
||||||
|
commonMarkAnchors = doc.optionsCommonMark.overrideAttrs {
|
||||||
|
extraArgs = [
|
||||||
|
"--anchor-prefix"
|
||||||
|
"my-opt-"
|
||||||
|
"--anchor-style"
|
||||||
|
"legacy"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
''
|
||||||
|
env | grep ^commonMark | sed -e 's/=/ = /'
|
||||||
|
(
|
||||||
|
set -x
|
||||||
|
grep -F 'foo\.bar\.enable' $commonMarkDefault >/dev/null
|
||||||
|
grep -F '{#my-opt-foo.bar.enable}' $commonMarkAnchors >/dev/null
|
||||||
|
)
|
||||||
|
touch $out
|
||||||
|
'';
|
||||||
|
}
|
|
@ -155,6 +155,8 @@ with pkgs;
|
||||||
|
|
||||||
nixos-functions = callPackage ./nixos-functions { };
|
nixos-functions = callPackage ./nixos-functions { };
|
||||||
|
|
||||||
|
nixosOptionsDoc = callPackage ../../nixos/lib/make-options-doc/tests.nix { };
|
||||||
|
|
||||||
overriding = callPackage ./overriding.nix { };
|
overriding = callPackage ./overriding.nix { };
|
||||||
|
|
||||||
texlive = callPackage ./texlive { };
|
texlive = callPackage ./texlive { };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue