mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
docs/mdbook: clean up derivation
This commit is contained in:
parent
28bdec9cf7
commit
c2dbf7acf1
1 changed files with 32 additions and 24 deletions
|
@ -205,7 +205,7 @@ let
|
||||||
};
|
};
|
||||||
|
|
||||||
mdbook = {
|
mdbook = {
|
||||||
nixvimOptions = mapModulesToString (
|
nixvimOptionsSummary = mapModulesToString (
|
||||||
name: opts:
|
name: opts:
|
||||||
let
|
let
|
||||||
isBranch = name == "index" || (opts.hasComponents && opts.index.options != { });
|
isBranch = name == "index" || (opts.hasComponents && opts.index.options != { });
|
||||||
|
@ -277,36 +277,21 @@ let
|
||||||
in
|
in
|
||||||
removeUnwanted configuration.options
|
removeUnwanted configuration.options
|
||||||
);
|
);
|
||||||
|
|
||||||
prepareMD = ''
|
|
||||||
# Copy inputs into the build directory
|
|
||||||
cp -r --no-preserve=all $inputs/* ./
|
|
||||||
cp ${../../CONTRIBUTING.md} ./CONTRIBUTING.md
|
|
||||||
cp -r ${../user-guide} ./user-guide
|
|
||||||
cp -r ${../modules} ./modules
|
|
||||||
|
|
||||||
# Copy the generated MD docs into the build directory
|
|
||||||
# Using pkgs.writeShellScript helps to avoid the "bash: argument list too long" error
|
|
||||||
bash -e ${pkgs.writeShellScript "copy_docs" docs.commands}
|
|
||||||
|
|
||||||
# Prepare SUMMARY.md for mdBook
|
|
||||||
# Using pkgs.writeText helps to avoid the same error as above
|
|
||||||
substituteInPlace ./SUMMARY.md \
|
|
||||||
--replace-fail "@NIXVIM_OPTIONS@" "$(cat ${pkgs.writeText "nixvim-options-summary.md" mdbook.nixvimOptions})"
|
|
||||||
|
|
||||||
substituteInPlace ./modules/wrapper-options.md \
|
|
||||||
--replace-fail "@WRAPPER_OPTIONS@" "$(cat ${mdbook.wrapperOptionDocs})"
|
|
||||||
'';
|
|
||||||
in
|
in
|
||||||
pkgs.stdenv.mkDerivation {
|
|
||||||
|
pkgs.stdenv.mkDerivation (finalAttrs: {
|
||||||
name = "nixvim-docs";
|
name = "nixvim-docs";
|
||||||
|
|
||||||
|
# Use structured attrs to avoid "bash: argument list too long" errors
|
||||||
|
__structuredAttrs = true;
|
||||||
|
|
||||||
phases = [ "buildPhase" ];
|
phases = [ "buildPhase" ];
|
||||||
|
|
||||||
buildInputs = [
|
buildInputs = [
|
||||||
pkgs.mdbook
|
pkgs.mdbook
|
||||||
pkgs.mdbook-alerts
|
pkgs.mdbook-alerts
|
||||||
];
|
];
|
||||||
|
|
||||||
inputs = lib.sourceFilesBySuffices ./. [
|
inputs = lib.sourceFilesBySuffices ./. [
|
||||||
".md"
|
".md"
|
||||||
".toml"
|
".toml"
|
||||||
|
@ -316,10 +301,33 @@ pkgs.stdenv.mkDerivation {
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
dest=$out/share/doc/nixvim
|
dest=$out/share/doc/nixvim
|
||||||
mkdir -p $dest
|
mkdir -p $dest
|
||||||
${prepareMD}
|
|
||||||
|
# Copy inputs into the build directory
|
||||||
|
cp -r --no-preserve=all $inputs/* ./
|
||||||
|
cp ${../../CONTRIBUTING.md} ./CONTRIBUTING.md
|
||||||
|
cp -r ${../user-guide} ./user-guide
|
||||||
|
cp -r ${../modules} ./modules
|
||||||
|
|
||||||
|
# Copy the generated MD docs into the build directory
|
||||||
|
bash -e ${finalAttrs.passthru.copy-docs}
|
||||||
|
|
||||||
|
# Patch SUMMARY.md - which defiens mdBook's table of contents
|
||||||
|
substituteInPlace ./SUMMARY.md \
|
||||||
|
--replace-fail "@NIXVIM_OPTIONS@" "$nixvimOptionsSummary"
|
||||||
|
|
||||||
|
substituteInPlace ./modules/wrapper-options.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;
|
||||||
|
|
||||||
|
passthru = {
|
||||||
|
inherit (mdbook) wrapperOptionDocs;
|
||||||
|
copy-docs = pkgs.writeShellScript "copy-docs" docs.commands;
|
||||||
|
};
|
||||||
|
})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue