1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 11:40:45 +00:00
nixpkgs/lib/tests/modules/docs.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

42 lines
892 B
Nix
Raw Normal View History

2024-01-29 06:10:14 +00:00
/*
A basic documentation generating module.
Declares and defines a `docs` option, suitable for making assertions about
the extraction "phase" of documentation generation.
*/
{ lib, options, ... }:
let
inherit (lib)
head
length
mkOption
types
;
traceListSeq = l: v: lib.foldl' (a: b: lib.traceSeq b a) v l;
in
{
options.docs = mkOption {
type = types.lazyAttrsOf types.raw;
description = ''
All options to be rendered, without any visibility filtering applied.
'';
};
config.docs =
lib.zipAttrsWith
(name: values:
if length values > 1 then
traceListSeq values
abort "Multiple options with the same name: ${name}"
else
assert length values == 1;
head values
)
(map
(opt: { ${opt.name} = opt; })
(lib.optionAttrSetToDocList options)
);
}