mirror of
https://github.com/nix-community/nixvim.git
synced 2025-12-19 15:31:13 +01:00
docs/mdbook: handle visible = "transparent"
This commit is contained in:
parent
51bbde565a
commit
5ef378a006
1 changed files with 15 additions and 11 deletions
|
|
@ -48,31 +48,35 @@ let
|
||||||
removeWhitespace = builtins.replaceStrings [ " " ] [ "" ];
|
removeWhitespace = builtins.replaceStrings [ " " ] [ "" ];
|
||||||
|
|
||||||
getSubOptions =
|
getSubOptions =
|
||||||
opts: path:
|
opt:
|
||||||
lib.optionalAttrs (isDeeplyVisible opts) (removeUnwanted (opts.type.getSubOptions path));
|
let
|
||||||
|
visible = opt.visible or true;
|
||||||
|
visible' = if lib.isBool visible then visible else visible != "shallow";
|
||||||
|
subOpts = opt.type.getSubOptions opt.loc;
|
||||||
|
in
|
||||||
|
lib.optionalAttrs visible' (removeUnwanted subOpts);
|
||||||
|
|
||||||
isVisible = isVisibleWith true;
|
isVisible =
|
||||||
isDeeplyVisible = isVisibleWith false;
|
|
||||||
|
|
||||||
isVisibleWith =
|
|
||||||
shallow: opts:
|
|
||||||
let
|
let
|
||||||
test =
|
test =
|
||||||
opt:
|
opt:
|
||||||
let
|
let
|
||||||
internal = opt.internal or false;
|
internal = opt.internal or false;
|
||||||
visible = opt.visible or true;
|
visible = opt.visible or true;
|
||||||
visible' = if visible == "shallow" then shallow else visible;
|
visible' = if lib.isBool visible then visible else visible != "transparent";
|
||||||
in
|
in
|
||||||
visible' && !internal;
|
visible' && !internal;
|
||||||
in
|
in
|
||||||
|
opts:
|
||||||
if lib.isOption opts then
|
if lib.isOption opts then
|
||||||
test opts
|
test opts
|
||||||
else if opts.isOption then
|
else if opts.isOption then
|
||||||
test opts.index.options
|
test opts.index.options
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
filterFunc = lib.filterAttrs (_: v: if lib.isAttrs v then isVisibleWith shallow v else true);
|
# FIXME: isVisible is not a perfect check;
|
||||||
|
# it will false-positive on `visible = "transparent"`
|
||||||
|
filterFunc = lib.filterAttrs (_: v: if lib.isAttrs v then isVisible v else true);
|
||||||
hasEmptyIndex = (filterFunc opts.index.options) == { };
|
hasEmptyIndex = (filterFunc opts.index.options) == { };
|
||||||
hasEmptyComponents = (filterFunc opts.components) == { };
|
hasEmptyComponents = (filterFunc opts.components) == { };
|
||||||
in
|
in
|
||||||
|
|
@ -136,7 +140,7 @@ let
|
||||||
wrapOptionDocPage (path ++ [ name ]) (go (path ++ [ name ]) opts) false
|
wrapOptionDocPage (path ++ [ name ]) (go (path ++ [ name ]) opts) false
|
||||||
else
|
else
|
||||||
let
|
let
|
||||||
subOpts = getSubOptions opts (path ++ [ name ]);
|
subOpts = getSubOptions opts;
|
||||||
in
|
in
|
||||||
# If this node is an option with sub-options...
|
# If this node is an option with sub-options...
|
||||||
# Pass wrapOptionDocPage a set containing it and its sub-options.
|
# Pass wrapOptionDocPage a set containing it and its sub-options.
|
||||||
|
|
@ -144,7 +148,7 @@ let
|
||||||
if subOpts != { } then
|
if subOpts != { } then
|
||||||
wrapOptionDocPage (path ++ [ name ]) (
|
wrapOptionDocPage (path ++ [ name ]) (
|
||||||
(go (path ++ [ name ]) subOpts)
|
(go (path ++ [ name ]) subOpts)
|
||||||
// {
|
// lib.optionalAttrs (isVisible opts) {
|
||||||
# This is necessary to include the option itself in the docs.
|
# This is necessary to include the option itself in the docs.
|
||||||
# For instance, this helps submodules like "autoCmd" to include their base declaration in the docs.
|
# For instance, this helps submodules like "autoCmd" to include their base declaration in the docs.
|
||||||
# Though there must be a better, less "hacky" solution than this.
|
# Though there must be a better, less "hacky" solution than this.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue