forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generate links to function definitions
Hydra passes the full revision in to the input, which we pass through. If we don't get this ,we try to get it from other sources, or default to master which should have the definition in a close-ish location. All published docs should have theURL resolve properly, only local hackers will have the link break.
- Loading branch information
Showing
8 changed files
with
135 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ | |
out | ||
manual-full.xml | ||
highlightjs | ||
functions/library/locations.xml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
{ pkgs ? (import ./.. { }), nixpkgs ? { }}: | ||
let | ||
revision = pkgs.lib.trivial.revisionWithDefault (nixpkgs.revision or "master"); | ||
|
||
libDefPos = set: | ||
builtins.map | ||
(name: { | ||
name = name; | ||
location = builtins.unsafeGetAttrPos name set; | ||
}) | ||
(builtins.attrNames set); | ||
|
||
libset = toplib: | ||
builtins.map | ||
(subsetname: { | ||
subsetname = subsetname; | ||
functions = libDefPos toplib."${subsetname}"; | ||
}) | ||
(builtins.filter | ||
(name: builtins.isAttrs toplib."${name}") | ||
(builtins.attrNames toplib)); | ||
|
||
nixpkgsLib = pkgs.lib; | ||
|
||
flattenedLibSubset = { subsetname, functions }: | ||
builtins.map | ||
(fn: { | ||
name = "lib.${subsetname}.${fn.name}"; | ||
value = fn.location; | ||
}) | ||
functions; | ||
|
||
locatedlibsets = libs: builtins.map flattenedLibSubset (libset libs); | ||
removeFilenamePrefix = prefix: filename: | ||
let | ||
prefixLen = (builtins.stringLength prefix) + 1; # +1 to remove the leading / | ||
filenameLen = builtins.stringLength filename; | ||
substr = builtins.substring prefixLen filenameLen filename; | ||
in substr; | ||
|
||
removeNixpkgs = removeFilenamePrefix (builtins.toString pkgs.path); | ||
|
||
liblocations = | ||
builtins.filter | ||
(elem: elem.value != null) | ||
(nixpkgsLib.lists.flatten | ||
(locatedlibsets nixpkgsLib)); | ||
|
||
fnLocationRelative = { name, value }: | ||
{ | ||
inherit name; | ||
value = value // { file = removeNixpkgs value.file; }; | ||
}; | ||
|
||
relativeLocs = (builtins.map fnLocationRelative liblocations); | ||
sanitizeId = builtins.replaceStrings | ||
[ "'" ] | ||
[ "-prime" ]; | ||
|
||
urlPrefix = "https://github.com/NixOS/nixpkgs/blob/${revision}"; | ||
xmlstrings = (nixpkgsLib.strings.concatMapStrings | ||
({ name, value }: | ||
'' | ||
<section><title>${name}</title> | ||
<para xml:id="${sanitizeId name}"> | ||
Located at | ||
<link | ||
xlink:href="${urlPrefix}/${value.file}#L${builtins.toString value.line}">${value.file}:${builtins.toString value.line}</link> | ||
in <literal><nixpkgs></literal>. | ||
</para> | ||
</section> | ||
'') | ||
relativeLocs); | ||
|
||
in pkgs.writeText | ||
"locations.xml" | ||
'' | ||
<section xmlns="http://docbook.org/ns/docbook" | ||
xmlns:xlink="http://www.w3.org/1999/xlink" | ||
version="5"> | ||
<title>All the locations for every lib function</title> | ||
<para>This file is only for inclusion by other files.</para> | ||
${xmlstrings} | ||
</section> | ||
'' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ pkgs ? import ../. {} }: | ||
(import ./default.nix).overrideAttrs (x: { | ||
(import ./default.nix {}).overrideAttrs (x: { | ||
buildInputs = x.buildInputs ++ [ pkgs.xmloscopy pkgs.ruby ]; | ||
|
||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters