mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-20 16:15:43 +02:00
docs: move wrapper options to dedicated sub-pages
This commit is contained in:
parent
131e74e560
commit
4726334e44
3 changed files with 49 additions and 52 deletions
|
@ -12,6 +12,7 @@
|
||||||
# Platforms
|
# Platforms
|
||||||
|
|
||||||
- [Nixvim Platforms](./platforms/index.md)
|
- [Nixvim Platforms](./platforms/index.md)
|
||||||
|
@PLATFORM_OPTIONS@
|
||||||
- [Standalone](./platforms/standalone.md)
|
- [Standalone](./platforms/standalone.md)
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
|
|
|
@ -225,58 +225,48 @@ let
|
||||||
"${padding}- [${name}](${path})"
|
"${padding}- [${name}](${path})"
|
||||||
) docs.modules;
|
) docs.modules;
|
||||||
|
|
||||||
wrapperOptionFiles = lib.mapAttrs' (name: options: {
|
# A list of platform-specific docs
|
||||||
name = options.meta.wrapper.name.value;
|
# [ { name, file, path, configuration } ]
|
||||||
# TODO:
|
wrapperOptions =
|
||||||
# value.path = "./platforms/${name}.md";
|
builtins.map
|
||||||
value.file = mkMDDoc options;
|
(filename: rec {
|
||||||
}) wrapperOptions;
|
# Eval a configuration for the platform's module
|
||||||
|
|
||||||
wrapperOptionDocs =
|
|
||||||
pkgs.runCommandNoCCLocal "wrapper-option-doc"
|
|
||||||
{
|
|
||||||
__structuredAttrs = true;
|
|
||||||
files = lib.mapAttrs (name: value: value.file) mdbook.wrapperOptionFiles;
|
|
||||||
# TODO:
|
|
||||||
# paths = lib.mapAttrs (name: value: value.path) mdbook.wrapperOptionFiles;
|
|
||||||
}
|
|
||||||
''
|
|
||||||
for name in "''${!files[@]}"
|
|
||||||
do
|
|
||||||
# $file contains the docs built by mkMDDoc
|
|
||||||
file="''${files[$name]}"
|
|
||||||
# TODO: consider putting wrapper docs in separate files:
|
|
||||||
# path="''${paths[$name]}"
|
|
||||||
echo >> "$out"
|
|
||||||
echo "## $name" >> "$out"
|
|
||||||
echo >> "$out"
|
|
||||||
cat "$file" >> $out
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
|
|
||||||
wrapperOptions =
|
|
||||||
lib.genAttrs
|
|
||||||
[
|
|
||||||
"hm"
|
|
||||||
"nixos"
|
|
||||||
"darwin"
|
|
||||||
]
|
|
||||||
(
|
|
||||||
name:
|
|
||||||
let
|
|
||||||
configuration = lib.evalModules {
|
configuration = lib.evalModules {
|
||||||
modules = [
|
modules = [
|
||||||
../../wrappers/modules/${name}.nix
|
../../wrappers/modules/${filename}.nix
|
||||||
{
|
{
|
||||||
# Ignore definitions for missing options
|
# Ignore definitions for missing options
|
||||||
_module.check = false;
|
_module.check = false;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
in
|
# Also include display name, filepath, and rendered docs
|
||||||
removeUnwanted configuration.options
|
inherit (configuration.config.meta.wrapper) name;
|
||||||
);
|
file = mkMDDoc (removeUnwanted configuration.options);
|
||||||
|
path = "./platforms/${filename}.md";
|
||||||
|
})
|
||||||
|
[
|
||||||
|
"nixos"
|
||||||
|
"hm"
|
||||||
|
"darwin"
|
||||||
|
];
|
||||||
|
|
||||||
|
# Markdown summary for the table of contents
|
||||||
|
wrapperOptionsSummary = lib.foldl (
|
||||||
|
text: { name, path, ... }: text + "\n\t- [${name}](${path})"
|
||||||
|
) "" mdbook.wrapperOptions;
|
||||||
|
|
||||||
|
# Attrset of { filePath = renderedDocs; }
|
||||||
|
wrapperOptionsFiles = lib.listToAttrs (
|
||||||
|
builtins.map (
|
||||||
|
{ path, file, ... }:
|
||||||
|
{
|
||||||
|
name = path;
|
||||||
|
value = file;
|
||||||
|
}
|
||||||
|
) mdbook.wrapperOptions
|
||||||
|
);
|
||||||
|
};
|
||||||
in
|
in
|
||||||
|
|
||||||
pkgs.stdenv.mkDerivation (finalAttrs: {
|
pkgs.stdenv.mkDerivation (finalAttrs: {
|
||||||
|
@ -324,23 +314,31 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
|
||||||
# Copy the generated MD docs into the build directory
|
# Copy the generated MD docs into the build directory
|
||||||
bash -e ${finalAttrs.passthru.copy-docs}
|
bash -e ${finalAttrs.passthru.copy-docs}
|
||||||
|
|
||||||
|
# Copy the generated MD docs for the wrapper options
|
||||||
|
for path in "''${!wrapperOptionsFiles[@]}"
|
||||||
|
do
|
||||||
|
file="''${wrapperOptionsFiles[$path]}"
|
||||||
|
cp "$file" "$path"
|
||||||
|
done
|
||||||
|
|
||||||
# Patch SUMMARY.md - which defiens mdBook's table of contents
|
# Patch SUMMARY.md - which defiens mdBook's table of contents
|
||||||
substituteInPlace ./SUMMARY.md \
|
substituteInPlace ./SUMMARY.md \
|
||||||
|
--replace-fail "@PLATFORM_OPTIONS@" "$wrapperOptionsSummary" \
|
||||||
--replace-fail "@NIXVIM_OPTIONS@" "$nixvimOptionsSummary"
|
--replace-fail "@NIXVIM_OPTIONS@" "$nixvimOptionsSummary"
|
||||||
|
|
||||||
substituteInPlace ./platforms/index.md \
|
|
||||||
--replace-fail "@WRAPPER_OPTIONS@" "$(cat ${finalAttrs.passthru.wrapperOptionDocs})"
|
|
||||||
|
|
||||||
mdbook build
|
mdbook build
|
||||||
cp -r ./book/* $dest
|
cp -r ./book/* $dest
|
||||||
mkdir -p $dest/search
|
mkdir -p $dest/search
|
||||||
cp -r ${search}/* $dest/search
|
cp -r ${search}/* $dest/search
|
||||||
'';
|
'';
|
||||||
|
|
||||||
inherit (mdbook) nixvimOptionsSummary;
|
inherit (mdbook)
|
||||||
|
nixvimOptionsSummary
|
||||||
|
wrapperOptionsSummary
|
||||||
|
wrapperOptionsFiles
|
||||||
|
;
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit (mdbook) wrapperOptionDocs;
|
|
||||||
copy-docs = pkgs.writeShellScript "copy-docs" docs.commands;
|
copy-docs = pkgs.writeShellScript "copy-docs" docs.commands;
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
|
@ -6,7 +6,5 @@ such as our NixOS, home-manager, or nix-darwin modules.
|
||||||
When Nixvim is used standalone (without a wrapper module), its options are available at the "top-level".
|
When Nixvim is used standalone (without a wrapper module), its options are available at the "top-level".
|
||||||
See [Standalone Usage](./standalone.md) for more info.
|
See [Standalone Usage](./standalone.md) for more info.
|
||||||
|
|
||||||
There are a few wrapper specific options that are documented below:
|
There are a few wrapper specific options, which are documented in their respective sub-pages.
|
||||||
|
|
||||||
@WRAPPER_OPTIONS@
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue