Skip to content

Commit f584d1d

Browse files
committed
docs/mdbook: support visible = "shallow"
1 parent 2f5374c commit f584d1d

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

docs/mdbook/default.nix

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,31 @@ let
3535
removeWhitespace = builtins.replaceStrings [ " " ] [ "" ];
3636

3737
getSubOptions =
38-
opts: path: lib.optionalAttrs (isVisible opts) (removeUnwanted (opts.type.getSubOptions path));
38+
opts: path:
39+
lib.optionalAttrs (isDeeplyVisible opts) (removeUnwanted (opts.type.getSubOptions path));
3940

40-
isVisible =
41-
opts:
41+
isVisible = isVisibleWith true;
42+
isDeeplyVisible = isVisibleWith false;
43+
44+
isVisibleWith =
45+
shallow: opts:
46+
let
47+
test =
48+
opt:
49+
let
50+
internal = opt.internal or false;
51+
visible = opt.visible or true;
52+
visible' = if visible == "shallow" then shallow else visible;
53+
in
54+
visible' && !internal;
55+
in
4256
if lib.isOption opts then
43-
opts.visible or true && !(opts.internal or false)
57+
test opts
4458
else if opts.isOption then
45-
opts.index.options.visible or true && !(opts.index.options.internal or false)
59+
test opts.index.options
4660
else
4761
let
48-
filterFunc = lib.filterAttrs (_: v: if lib.isAttrs v then isVisible v else true);
49-
62+
filterFunc = lib.filterAttrs (_: v: if lib.isAttrs v then isVisibleWith shallow v else true);
5063
hasEmptyIndex = (filterFunc opts.index.options) == { };
5164
hasEmptyComponents = (filterFunc opts.components) == { };
5265
in

0 commit comments

Comments
 (0)