mirror of
https://github.com/NotAShelf/nvf.git
synced 2025-10-01 14:33:28 +00:00
docs: adapt builder functions for ndg
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I6a6a6964720fae8f3db129835efa5d5df956c3ef
This commit is contained in:
parent
cd9a5da852
commit
11d0292539
2 changed files with 94 additions and 90 deletions
|
@ -92,7 +92,7 @@
|
||||||
|
|
||||||
# Generate the HTML manual pages
|
# Generate the HTML manual pages
|
||||||
html = pkgs.callPackage ./manual.nix {
|
html = pkgs.callPackage ./manual.nix {
|
||||||
inherit release;
|
inherit inputs release;
|
||||||
inherit (nvimModuleDocs) optionsJSON;
|
inherit (nvimModuleDocs) optionsJSON;
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
|
182
docs/manual.nix
182
docs/manual.nix
|
@ -1,114 +1,118 @@
|
||||||
{
|
{
|
||||||
lib,
|
inputs,
|
||||||
stdenvNoCC,
|
stdenvNoCC,
|
||||||
fetchzip,
|
|
||||||
runCommandLocal,
|
runCommandLocal,
|
||||||
# build inputs
|
# build inputs
|
||||||
nixos-render-docs,
|
|
||||||
documentation-highlighter,
|
|
||||||
dart-sass,
|
|
||||||
path,
|
path,
|
||||||
# nrd configuration
|
# nrd configuration
|
||||||
release,
|
release,
|
||||||
optionsJSON,
|
optionsJSON,
|
||||||
} @ args: let
|
} @ args: let
|
||||||
manual-release = args.release or "unstable";
|
manual-release = args.release or "unstable";
|
||||||
|
in
|
||||||
|
runCommandLocal "hjem-docs" {
|
||||||
|
nativeBuildInputs = [inputs.ndg.packages.${stdenvNoCC.system}.ndg];
|
||||||
|
} ''
|
||||||
|
mkdir -p $out/share/doc
|
||||||
|
|
||||||
scss-reset = fetchzip {
|
# Copy the markdown sources to be processed by ndg
|
||||||
url = "https://github.com/Frontend-Layers/scss-reset/archive/refs/tags/1.4.2.zip";
|
cp -rvf ${./manual} ./manual
|
||||||
hash = "sha256-cif5Sx8Ca5vxdw/mNAgpulLH15TwmzyJFNM7JURpoaE=";
|
|
||||||
|
substituteInPlace ./manual/options.md \
|
||||||
|
--subst-var-by OPTIONS_JSON ./config-options.json
|
||||||
|
|
||||||
|
substituteInPlace ./manual/index.md \
|
||||||
|
--subst-var-by NVF_VERSION ${manual-release}
|
||||||
|
|
||||||
|
substituteInPlace ./manual/hacking/additional-plugins.md \
|
||||||
|
--subst-var-by NVF_REPO "https://github.com/notashelf/nvf/blob/${manual-release}"
|
||||||
|
|
||||||
|
ndg html \
|
||||||
|
--jobs $NIX_BUILD_CORES --title "NVF" \
|
||||||
|
--module-options ${optionsJSON}/share/doc/nixos/options.json \
|
||||||
|
--manpage-urls ${path}/doc/manpage-urls.json \
|
||||||
|
--options-depth 3 \
|
||||||
|
--generate-search true \
|
||||||
|
--highlight-code true \
|
||||||
|
--input-dir ./manual \
|
||||||
|
--output-dir "$out/share/doc"
|
||||||
|
|
||||||
|
# Hydra support. Probably not necessary.
|
||||||
|
mkdir -p $out/nix-support/
|
||||||
|
echo "doc manual $dest index.html" >> $out/nix-support/hydra-build-products
|
||||||
|
''
|
||||||
|
/*
|
||||||
|
stdenvNoCC.mkDerivation {
|
||||||
|
name = "nvf-manual";
|
||||||
|
src = builtins.path {
|
||||||
|
name = "nvf-manual-${manual-release}";
|
||||||
|
path = lib.sourceFilesBySuffices ./manual [".md" ".md.in"];
|
||||||
};
|
};
|
||||||
|
|
||||||
compileStylesheet = runCommandLocal "compile-nvf-stylesheet" {} ''
|
strictDependencies = true;
|
||||||
mkdir -p $out
|
nativeBuildInputs = [nixos-render-docs];
|
||||||
|
|
||||||
tmpfile=$(mktemp -d)
|
postPatch = ''
|
||||||
trap "rm -r $tmpfile" EXIT
|
ln -s ${optionsJSON}/share/doc/nixos/options.json ./config-options.json
|
||||||
|
|
||||||
ln -s "${scss-reset}/build" "$tmpfile/scss-reset"
|
|
||||||
|
|
||||||
${dart-sass}/bin/sass --load-path "$tmpfile" \
|
|
||||||
${./static/style.scss} "$out/style.css"
|
|
||||||
|
|
||||||
echo "Generated styles"
|
|
||||||
'';
|
'';
|
||||||
in
|
|
||||||
stdenvNoCC.mkDerivation {
|
|
||||||
name = "nvf-manual";
|
|
||||||
src = builtins.path {
|
|
||||||
name = "nvf-manual-${manual-release}";
|
|
||||||
path = lib.sourceFilesBySuffices ./manual [".md" ".md.in"];
|
|
||||||
};
|
|
||||||
|
|
||||||
strictDependencies = true;
|
buildPhase = ''
|
||||||
nativeBuildInputs = [nixos-render-docs];
|
dest="$out/share/doc/nvf"
|
||||||
|
mkdir -p "$(dirname "$dest")"
|
||||||
|
mkdir -p $dest/{highlightjs,script}
|
||||||
|
|
||||||
postPatch = ''
|
# Copy highlight scripts to /highlights in document root.
|
||||||
ln -s ${optionsJSON}/share/doc/nixos/options.json ./config-options.json
|
cp -vt $dest/highlightjs \
|
||||||
'';
|
${documentation-highlighter}/highlight.pack.js \
|
||||||
|
${documentation-highlighter}/LICENSE \
|
||||||
|
${documentation-highlighter}/mono-blue.css \
|
||||||
|
${documentation-highlighter}/loader.js
|
||||||
|
|
||||||
buildPhase = ''
|
# Copy anchor scripts to the script directory in document root.
|
||||||
dest="$out/share/doc/nvf"
|
cp -vt "$dest"/script \
|
||||||
mkdir -p "$(dirname "$dest")"
|
${./static/script}/anchor-min.js \
|
||||||
mkdir -p $dest/{highlightjs,script}
|
${./static/script}/anchor-use.js \
|
||||||
|
${./static/script}/search.js
|
||||||
|
|
||||||
# Copy highlight scripts to /highlights in document root.
|
|
||||||
cp -vt $dest/highlightjs \
|
|
||||||
${documentation-highlighter}/highlight.pack.js \
|
|
||||||
${documentation-highlighter}/LICENSE \
|
|
||||||
${documentation-highlighter}/mono-blue.css \
|
|
||||||
${documentation-highlighter}/loader.js
|
|
||||||
|
|
||||||
# Copy anchor scripts to the script directory in document root.
|
|
||||||
cp -vt "$dest"/script \
|
|
||||||
${./static/script}/anchor-min.js \
|
|
||||||
${./static/script}/anchor-use.js \
|
|
||||||
${./static/script}/search.js
|
|
||||||
|
|
||||||
substituteInPlace ./options.md \
|
# Move compiled stylesheet
|
||||||
--subst-var-by OPTIONS_JSON ./config-options.json
|
cp -vt $dest \
|
||||||
|
${compileStylesheet}/style.css
|
||||||
|
|
||||||
substituteInPlace ./manual.md \
|
# Move release notes
|
||||||
--subst-var-by NVF_VERSION ${manual-release}
|
cp -vr ${./release-notes} release-notes
|
||||||
|
|
||||||
substituteInPlace ./hacking/additional-plugins.md \
|
# Generate final manual from a set of parameters. Explanation of the CLI flags are
|
||||||
--subst-var-by NVF_REPO "https://github.com/notashelf/nvf/blob/${manual-release}"
|
# as follows:
|
||||||
|
#
|
||||||
|
# 1. --manpage-urls will allow you to use manual pages as they are defined in
|
||||||
|
# the nixpkgs documentation.
|
||||||
|
# 2. --revision is the project revision as it is defined in 'release.json' in the
|
||||||
|
# repository root
|
||||||
|
# 3. --script will inject a given Javascript file into the resulting pages inside
|
||||||
|
# the <script> tag.
|
||||||
|
# 4. --toc-depth will determine the depth of the initial Table of Contents while
|
||||||
|
# --section-toc-depth will determine the depth of per-section Table of Contents
|
||||||
|
# sections.
|
||||||
|
nixos-render-docs manual html \
|
||||||
|
--manpage-urls ${path + "/doc/manpage-urls.json"} \
|
||||||
|
--revision ${lib.trivial.revisionWithDefault manual-release} \
|
||||||
|
--stylesheet style.css \
|
||||||
|
--script highlightjs/highlight.pack.js \
|
||||||
|
--script highlightjs/loader.js \
|
||||||
|
--script script/anchor-use.js \
|
||||||
|
--script script/anchor-min.js \
|
||||||
|
--script script/search.js \
|
||||||
|
--toc-depth 1 \
|
||||||
|
--section-toc-depth 1 \
|
||||||
|
manual.md \
|
||||||
|
"$dest/index.xhtml"
|
||||||
|
|
||||||
# Move compiled stylesheet
|
# Hydra support. Probably not necessary.
|
||||||
cp -vt $dest \
|
mkdir -p $out/nix-support/
|
||||||
${compileStylesheet}/style.css
|
echo "doc manual $dest index.html" >> $out/nix-support/hydra-build-products
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
# Move release notes
|
|
||||||
cp -vr ${./release-notes} release-notes
|
|
||||||
|
|
||||||
# Generate final manual from a set of parameters. Explanation of the CLI flags are
|
|
||||||
# as follows:
|
|
||||||
#
|
|
||||||
# 1. --manpage-urls will allow you to use manual pages as they are defined in
|
|
||||||
# the nixpkgs documentation.
|
|
||||||
# 2. --revision is the project revision as it is defined in 'release.json' in the
|
|
||||||
# repository root
|
|
||||||
# 3. --script will inject a given Javascript file into the resulting pages inside
|
|
||||||
# the <script> tag.
|
|
||||||
# 4. --toc-depth will determine the depth of the initial Table of Contents while
|
|
||||||
# --section-toc-depth will determine the depth of per-section Table of Contents
|
|
||||||
# sections.
|
|
||||||
nixos-render-docs manual html \
|
|
||||||
--manpage-urls ${path + "/doc/manpage-urls.json"} \
|
|
||||||
--revision ${lib.trivial.revisionWithDefault manual-release} \
|
|
||||||
--stylesheet style.css \
|
|
||||||
--script highlightjs/highlight.pack.js \
|
|
||||||
--script highlightjs/loader.js \
|
|
||||||
--script script/anchor-use.js \
|
|
||||||
--script script/anchor-min.js \
|
|
||||||
--script script/search.js \
|
|
||||||
--toc-depth 1 \
|
|
||||||
--section-toc-depth 1 \
|
|
||||||
manual.md \
|
|
||||||
"$dest/index.xhtml"
|
|
||||||
|
|
||||||
# Hydra support. Probably not necessary.
|
|
||||||
mkdir -p $out/nix-support/
|
|
||||||
echo "doc manual $dest index.html" >> $out/nix-support/hydra-build-products
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue