mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-17 15:22:59 +01:00
Add buildDhall*Package
support for generating documentation
The `buildDhall{Directory,GitHub}Package` utilities now take an optional `document` argument for generating documentation using `dhall-docs`. The documentation is stored underneath the `./docs` subdirectory of the build product.
This commit is contained in:
parent
86b651f169
commit
6dac8e6817
4 changed files with 57 additions and 29 deletions
|
@ -14,12 +14,17 @@ lib.makePackageOverridable
|
|||
, src
|
||||
, # The file to import, relative to the root directory
|
||||
file ? "package.dhall"
|
||||
# Set to `true` to generate documentation for the package
|
||||
, document ? false
|
||||
}:
|
||||
|
||||
buildDhallPackage {
|
||||
inherit name dependencies source;
|
||||
buildDhallPackage
|
||||
( { inherit name dependencies source;
|
||||
|
||||
code = "${src}/${file}";
|
||||
|
||||
}
|
||||
// lib.optionalAttrs document { documentationRoot = src; }
|
||||
)
|
||||
)
|
||||
|
||||
|
|
|
@ -12,6 +12,8 @@ lib.makePackageOverridable
|
|||
directory ? ""
|
||||
, # The file to import, relative to the above directory
|
||||
file ? "package.dhall"
|
||||
# Set to `true` to generate documentation for the package
|
||||
, document ? false
|
||||
|
||||
# Arguments passed through to `fetchFromGitHub`
|
||||
, owner
|
||||
|
@ -22,10 +24,6 @@ lib.makePackageOverridable
|
|||
, ...
|
||||
}@args:
|
||||
|
||||
buildDhallPackage {
|
||||
inherit name dependencies source;
|
||||
|
||||
code =
|
||||
let
|
||||
src = fetchFromGitHub ({
|
||||
name = "${name}-source";
|
||||
|
@ -34,6 +32,7 @@ lib.makePackageOverridable
|
|||
} // removeAttrs args [
|
||||
"name"
|
||||
"dependencies"
|
||||
"document"
|
||||
"source"
|
||||
"directory"
|
||||
"file"
|
||||
|
@ -45,6 +44,12 @@ lib.makePackageOverridable
|
|||
prefix = lib.optionalString (directory != "") "${directory}/";
|
||||
|
||||
in
|
||||
"${src}/${prefix}${file}";
|
||||
buildDhallPackage
|
||||
( { inherit name dependencies source;
|
||||
|
||||
code = "${src}/${prefix}${file}";
|
||||
}
|
||||
// lib.optionalAttrs document
|
||||
{ documentationRoot = "${src}/${prefix}"; }
|
||||
)
|
||||
)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{ dhall, haskell, lib, lndir, runCommand, writeText }:
|
||||
{ dhall, dhall-docs, haskell, lib, lndir, runCommand, writeText }:
|
||||
|
||||
{ name
|
||||
|
||||
|
@ -31,6 +31,12 @@
|
|||
# space within the Nix store, but if you set the following `source` option to
|
||||
# `true` then the package will also include `source.dhall`.
|
||||
, source ? false
|
||||
|
||||
# Directory to generate documentation for (i.e. as the `--input` option to the
|
||||
# `dhall-docs` command.)
|
||||
#
|
||||
# If `null`, then no documentation is generated.
|
||||
, documentationRoot ? null
|
||||
}:
|
||||
|
||||
let
|
||||
|
@ -42,8 +48,12 @@ let
|
|||
|
||||
cache = ".cache";
|
||||
|
||||
data = ".local/share";
|
||||
|
||||
cacheDhall = "${cache}/dhall";
|
||||
|
||||
dataDhall = "${data}/dhall";
|
||||
|
||||
sourceFile = "source.dhall";
|
||||
|
||||
in
|
||||
|
@ -71,4 +81,10 @@ in
|
|||
echo "missing $SHA_HASH" > $out/binary.dhall
|
||||
|
||||
${lib.optionalString (!source) "rm $out/${sourceFile}"}
|
||||
|
||||
${lib.optionalString (documentationRoot != null) ''
|
||||
mkdir -p $out/${dataDhall}
|
||||
|
||||
XDG_DATA_HOME=$out/${data} ${dhall-docs}/bin/dhall-docs --input '${documentationRoot}' --output-link $out/docs
|
||||
''}
|
||||
''
|
||||
|
|
|
@ -10310,13 +10310,15 @@ in
|
|||
|
||||
dhall = haskell.lib.justStaticExecutables haskellPackages.dhall;
|
||||
|
||||
dhall-nix = haskell.lib.justStaticExecutables haskellPackages.dhall-nix;
|
||||
|
||||
dhall-bash = haskell.lib.justStaticExecutables haskellPackages.dhall-bash;
|
||||
|
||||
dhall-docs = haskell.lib.justStaticExecutables haskellPackages.dhall-docs;
|
||||
|
||||
dhall-lsp-server = haskell.lib.justStaticExecutables haskellPackages.dhall-lsp-server;
|
||||
|
||||
dhall-json = haskell.lib.justStaticExecutables haskellPackages.dhall-json;
|
||||
|
||||
dhall-lsp-server = haskell.lib.justStaticExecutables haskellPackages.dhall-lsp-server;
|
||||
dhall-nix = haskell.lib.justStaticExecutables haskellPackages.dhall-nix;
|
||||
|
||||
dhall-text = haskell.lib.justStaticExecutables haskellPackages.dhall-text;
|
||||
|
||||
|
|
Loading…
Reference in a new issue