Skip to content

Commit 1e11f8f

Browse files
committed
docs/mdbook: support visible = "shallow"
1 parent 964d98a commit 1e11f8f

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

docs/mdbook/default.nix

+20-7
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,31 @@ let
3636
removeWhitespace = builtins.replaceStrings [ " " ] [ "" ];
3737

3838
getSubOptions =
39-
opts: path: lib.optionalAttrs (isVisible opts) (removeUnwanted (opts.type.getSubOptions path));
39+
opts: path:
40+
lib.optionalAttrs (isDeeplyVisible opts) (removeUnwanted (opts.type.getSubOptions path));
4041

41-
isVisible =
42-
opts:
42+
isVisible = isVisibleWith true;
43+
isDeeplyVisible = isVisibleWith false;
44+
45+
isVisibleWith =
46+
shallow: opts:
47+
let
48+
test =
49+
opt:
50+
let
51+
internal = opt.internal or false;
52+
visible = opt.visible or true;
53+
visible' = if visible == "shallow" then shallow else visible;
54+
in
55+
visible' && !internal;
56+
in
4357
if lib.isOption opts then
44-
opts.visible or true && !(opts.internal or false)
58+
test opts
4559
else if opts.isOption then
46-
opts.index.options.visible or true && !(opts.index.options.internal or false)
60+
test opts.index.options
4761
else
4862
let
49-
filterFunc = lib.filterAttrs (_: v: if lib.isAttrs v then isVisible v else true);
50-
63+
filterFunc = lib.filterAttrs (_: v: if lib.isAttrs v then isVisibleWith shallow v else true);
5164
hasEmptyIndex = (filterFunc opts.index.options) == { };
5265
hasEmptyComponents = (filterFunc opts.components) == { };
5366
in

0 commit comments

Comments
 (0)