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
|
||||
|
||||
- [Nixvim Platforms](./platforms/index.md)
|
||||
@PLATFORM_OPTIONS@
|
||||
- [Standalone](./platforms/standalone.md)
|
||||
|
||||
# Options
|
||||
|
|
|
@ -225,58 +225,48 @@ let
|
|||
"${padding}- [${name}](${path})"
|
||||
) docs.modules;
|
||||
|
||||
wrapperOptionFiles = lib.mapAttrs' (name: options: {
|
||||
name = options.meta.wrapper.name.value;
|
||||
# TODO:
|
||||
# value.path = "./platforms/${name}.md";
|
||||
value.file = mkMDDoc options;
|
||||
}) wrapperOptions;
|
||||
|
||||
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
|
||||
'';
|
||||
};
|
||||
|
||||
# A list of platform-specific docs
|
||||
# [ { name, file, path, configuration } ]
|
||||
wrapperOptions =
|
||||
lib.genAttrs
|
||||
[
|
||||
"hm"
|
||||
"nixos"
|
||||
"darwin"
|
||||
]
|
||||
(
|
||||
name:
|
||||
let
|
||||
builtins.map
|
||||
(filename: rec {
|
||||
# Eval a configuration for the platform's module
|
||||
configuration = lib.evalModules {
|
||||
modules = [
|
||||
../../wrappers/modules/${name}.nix
|
||||
../../wrappers/modules/${filename}.nix
|
||||
{
|
||||
# Ignore definitions for missing options
|
||||
_module.check = false;
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
removeUnwanted configuration.options
|
||||
# Also include display name, filepath, and rendered docs
|
||||
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
|
||||
|
||||
pkgs.stdenv.mkDerivation (finalAttrs: {
|
||||
|
@ -324,23 +314,31 @@ pkgs.stdenv.mkDerivation (finalAttrs: {
|
|||
# Copy the generated MD docs into the build directory
|
||||
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
|
||||
substituteInPlace ./SUMMARY.md \
|
||||
--replace-fail "@PLATFORM_OPTIONS@" "$wrapperOptionsSummary" \
|
||||
--replace-fail "@NIXVIM_OPTIONS@" "$nixvimOptionsSummary"
|
||||
|
||||
substituteInPlace ./platforms/index.md \
|
||||
--replace-fail "@WRAPPER_OPTIONS@" "$(cat ${finalAttrs.passthru.wrapperOptionDocs})"
|
||||
|
||||
mdbook build
|
||||
cp -r ./book/* $dest
|
||||
mkdir -p $dest/search
|
||||
cp -r ${search}/* $dest/search
|
||||
'';
|
||||
|
||||
inherit (mdbook) nixvimOptionsSummary;
|
||||
inherit (mdbook)
|
||||
nixvimOptionsSummary
|
||||
wrapperOptionsSummary
|
||||
wrapperOptionsFiles
|
||||
;
|
||||
|
||||
passthru = {
|
||||
inherit (mdbook) wrapperOptionDocs;
|
||||
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".
|
||||
See [Standalone Usage](./standalone.md) for more info.
|
||||
|
||||
There are a few wrapper specific options that are documented below:
|
||||
|
||||
@WRAPPER_OPTIONS@
|
||||
There are a few wrapper specific options, which are documented in their respective sub-pages.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue