dhall: Use --base-import-url flag for documentation (#128588)

This updates `pkgs.dhallPackages.buildDhallGitHubPackage` to use the
newly added `--base-import-url` `dhall-docs` flag.  This flag is used
by the generated documentation so that paths copied to the clipboard
represent complete URLs that can be imported instead of only the
relative path to the import.
This commit is contained in:
Gabriel Gonzalez 2021-06-29 19:09:29 -07:00 committed by GitHub
parent c865d03690
commit ef0a42347e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 4 deletions

View file

@ -43,7 +43,7 @@ lib.makePackageOverridable
"rev"
]);
prefix = lib.optionalString (directory != "") "${directory}/";
prefix = lib.optionalString (directory != "") "/${directory}";
in
buildDhallPackage
@ -51,9 +51,12 @@ lib.makePackageOverridable
name = versionedName;
code = "${src}/${prefix}${file}";
code = "${src}${prefix}/${file}";
}
// lib.optionalAttrs document
{ documentationRoot = "${src}/${prefix}"; }
{ documentationRoot = "${src}/${prefix}";
baseImportUrl = "https://raw.githubusercontent.com/${owner}/${repo}/${rev}${prefix}";
}
)
)

View file

@ -37,6 +37,12 @@
#
# If `null`, then no documentation is generated.
, documentationRoot ? null
# Base URL prepended to paths copied to the clipboard
#
# This is used in conjunction with `documentationRoot`, and is unused if
# `documentationRoot` is `null`.
, baseImportUrl ? null
}:
let
@ -85,6 +91,12 @@ in
${lib.optionalString (documentationRoot != null) ''
mkdir -p $out/${dataDhall}
XDG_DATA_HOME=$out/${data} ${dhall-docs}/bin/dhall-docs --input '${documentationRoot}' --package-name '${name}' --output-link $out/docs
XDG_DATA_HOME=$out/${data} ${dhall-docs}/bin/dhall-docs --output-link $out/docs ${lib.cli.toGNUCommandLineShell { } {
base-import-url = baseImportUrl;
input = documentationRoot;
package-name = name;
}}
''}
''