1/*
2 A basic documentation generating module.
3 Declares and defines a `docs` option, suitable for making assertions about
4 the extraction "phase" of documentation generation.
5 */
6{ lib, options, ... }:
7
8let
9 inherit (lib)
10 head
11 length
12 mkOption
13 types
14 ;
15
16 traceListSeq = l: v: lib.foldl' (a: b: lib.traceSeq b a) v l;
17
18in
19
20{
21 options.docs = mkOption {
22 type = types.lazyAttrsOf types.raw;
23 description = ''
24 All options to be rendered, without any visibility filtering applied.
25 '';
26 };
27 config.docs =
28 lib.zipAttrsWith
29 (name: values:
30 if length values > 1 then
31 traceListSeq values
32 abort "Multiple options with the same name: ${name}"
33 else
34 assert length values == 1;
35 head values
36 )
37 (map
38 (opt: { ${opt.name} = opt; })
39 (lib.optionAttrSetToDocList options)
40 );
41}