at master 825 B view raw
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 = lib.zipAttrsWith ( 28 name: values: 29 if length values > 1 then 30 traceListSeq values abort "Multiple options with the same name: ${name}" 31 else 32 assert length values == 1; 33 head values 34 ) (map (opt: { ${opt.name} = opt; }) (lib.optionAttrSetToDocList options)); 35}