From 1c6dd6579a9325aa7b438c271c1a264c0836a7dd Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Thu, 15 May 2025 14:24:55 +0100 Subject: [PATCH] docs: include function docs Embed the function reference docs into the main docs website. --- docs/default.nix | 2 +- docs/mdbook/SUMMARY.md | 4 ++++ docs/mdbook/default.nix | 11 +++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/default.nix b/docs/default.nix index 43cd9023..e83e24eb 100644 --- a/docs/default.nix +++ b/docs/default.nix @@ -127,7 +127,7 @@ lib.fix ( # > sandbox-exec: pattern serialization length 69298 exceeds maximum (65535) docs = pkgs.callPackage ./mdbook { inherit evaledModules transformOptions; - inherit (self) search; + inherit (self) search lib-docs; }; } ) diff --git a/docs/mdbook/SUMMARY.md b/docs/mdbook/SUMMARY.md index d08c19fd..ab132ab3 100644 --- a/docs/mdbook/SUMMARY.md +++ b/docs/mdbook/SUMMARY.md @@ -10,6 +10,10 @@ - [Configuration examples](./user-guide/config-examples.md) - [Lazy Loading](./user-guide/lazy-loading.md) +# Functions + +@FUNCTIONS_MENU@ + # Platforms - [Nixvim Platforms](./platforms/index.md) diff --git a/docs/mdbook/default.nix b/docs/mdbook/default.nix index a75c0b5e..d8e77970 100644 --- a/docs/mdbook/default.nix +++ b/docs/mdbook/default.nix @@ -7,6 +7,7 @@ nixosOptionsDoc, transformOptions, search, + lib-docs, # The root directory of the site baseHref ? "/", # A list of all available docs that should be linked to @@ -359,6 +360,13 @@ pkgs.stdenv.mkDerivation (finalAttrs: { # Copy the contributing file cp $contributing ./CONTRIBUTING.md + # Symlink the function docs + for path in ${lib-docs}/* + do + echo "symlinking \"$path\" to \"$(basename "$path")\"" + ln -s "$path" $(basename "$path") + done + # Copy the generated MD docs into the build directory bash -e ${finalAttrs.passthru.copy-docs} @@ -375,6 +383,7 @@ pkgs.stdenv.mkDerivation (finalAttrs: { # Patch SUMMARY.md - which defiens mdBook's table of contents substituteInPlace ./SUMMARY.md \ + --replace-fail "@FUNCTIONS_MENU@" "$functionsSummary" \ --replace-fail "@PLATFORM_OPTIONS@" "$wrapperOptionsSummary" \ --replace-fail "@NIXVIM_OPTIONS@" "$nixvimOptionsSummary" @@ -401,6 +410,8 @@ pkgs.stdenv.mkDerivation (finalAttrs: { wrapperOptionsFiles ; + functionsSummary = lib-docs.menu; + passthru = { fix-links = callPackage ../fix-links { # FIXME: determine values from availableVersions & baseHref