mirror of
https://github.com/nix-community/home-manager
synced 2024-11-26 21:19:45 +01:00
docs: add htmlOpenTool to manual
This commit extracts the htmlOpenTool from `nmd` into a module in the home-manager docs directory. This is done to provide feature parity with the documentation generated using the docbook .xml files.
This commit is contained in:
parent
728423e6f4
commit
0dcb767676
2 changed files with 39 additions and 1 deletions
|
@ -128,6 +128,8 @@ let
|
|||
};
|
||||
inherit revision home-manager-render-docs;
|
||||
};
|
||||
html = home-manager-manual;
|
||||
htmlOpenTool = pkgs.callPackage ./html-open-tool.nix { } { inherit html; };
|
||||
in {
|
||||
inherit nmdSrc;
|
||||
|
||||
|
@ -150,7 +152,7 @@ in {
|
|||
|
||||
manPages = home-configuration-manual;
|
||||
|
||||
manual = { html = home-manager-manual; };
|
||||
manual = { inherit html htmlOpenTool; };
|
||||
|
||||
# Unstable, mainly for CI.
|
||||
jsonModuleMaintainers = pkgs.writeText "hm-module-maintainers.json" (let
|
||||
|
|
36
docs/html-open-tool.nix
Normal file
36
docs/html-open-tool.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ writeShellScriptBin, makeDesktopItem, symlinkJoin }:
|
||||
{ html, pathName ? "home-manager", projectName ? pathName
|
||||
, name ? "${pathName}-help" }:
|
||||
let
|
||||
helpScript = writeShellScriptBin name ''
|
||||
set -euo pipefail
|
||||
|
||||
if [[ ! -v BROWSER || -z $BROWSER ]]; then
|
||||
for candidate in xdg-open open w3m; do
|
||||
BROWSER="$(type -P $candidate || true)"
|
||||
if [[ -x $BROWSER ]]; then
|
||||
break;
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ ! -v BROWSER || -z $BROWSER ]]; then
|
||||
echo "$0: unable to start a web browser; please set \$BROWSER"
|
||||
exit 1
|
||||
else
|
||||
exec "$BROWSER" "${html}/share/docs/${pathName}/index.html"
|
||||
fi
|
||||
'';
|
||||
|
||||
desktopItem = makeDesktopItem {
|
||||
name = "${pathName}-manual";
|
||||
desktopName = "${projectName} Manual";
|
||||
genericName = "View ${projectName} documentation in a web browser";
|
||||
icon = "nix-snowflake";
|
||||
exec = "${helpScript}/bin/${name}";
|
||||
categories = [ "System" ];
|
||||
};
|
||||
in symlinkJoin {
|
||||
inherit name;
|
||||
paths = [ helpScript desktopItem ];
|
||||
}
|
Loading…
Reference in a new issue