mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-23 15:33:13 +00:00
Merge pull request #205643 from ncfavier/doc-lib
doc/lib-functions: remove warnings, add `versions`, `cli`
This commit is contained in:
commit
7ba7b45993
@ -3,8 +3,22 @@ let
|
||||
inherit (pkgs) lib;
|
||||
inherit (lib) hasPrefix removePrefix;
|
||||
|
||||
locationsXml = import ./lib-function-locations.nix { inherit pkgs nixpkgs; };
|
||||
functionDocs = import ./lib-function-docs.nix { inherit locationsXml pkgs; };
|
||||
libsets = [
|
||||
{ name = "asserts"; description = "assertion functions"; }
|
||||
{ name = "attrsets"; description = "attribute set functions"; }
|
||||
{ name = "strings"; description = "string manipulation functions"; }
|
||||
{ name = "versions"; description = "version string functions"; }
|
||||
{ name = "trivial"; description = "miscellaneous functions"; }
|
||||
{ name = "lists"; description = "list manipulation functions"; }
|
||||
{ name = "debug"; description = "debugging functions"; }
|
||||
{ name = "options"; description = "NixOS / nixpkgs option handling"; }
|
||||
{ name = "filesystem"; description = "filesystem functions"; }
|
||||
{ name = "sources"; description = "source filtering functions"; }
|
||||
{ name = "cli"; description = "command-line serialization functions"; }
|
||||
];
|
||||
|
||||
locationsXml = import ./lib-function-locations.nix { inherit pkgs nixpkgs libsets; };
|
||||
functionDocs = import ./lib-function-docs.nix { inherit locationsXml pkgs libsets; };
|
||||
version = pkgs.lib.version;
|
||||
|
||||
epub-xsl = pkgs.writeText "epub.xsl" ''
|
||||
|
@ -1,30 +1,32 @@
|
||||
# Generates the documentation for library functions via nixdoc. To add
|
||||
# another library function file to this list, the include list in the
|
||||
# file `doc/functions/library.xml` must also be updated.
|
||||
# Generates the documentation for library functions via nixdoc.
|
||||
|
||||
{ pkgs ? import ./.. {}, locationsXml }:
|
||||
{ pkgs, locationsXml, libsets }:
|
||||
|
||||
with pkgs; stdenv.mkDerivation {
|
||||
name = "nixpkgs-lib-docs";
|
||||
src = ./../../lib;
|
||||
src = ../../lib;
|
||||
|
||||
buildInputs = [ nixdoc ];
|
||||
installPhase = ''
|
||||
function docgen {
|
||||
nixdoc -c "$1" -d "$2" -f "../lib/$1.nix" > "$out/$1.xml"
|
||||
# TODO: wrap lib.$1 in <literal>, make nixdoc not escape it
|
||||
nixdoc -c "$1" -d "lib.$1: $2" -f "$1.nix" > "$out/$1.xml"
|
||||
echo "<xi:include href='$1.xml' />" >> "$out/index.xml"
|
||||
}
|
||||
|
||||
mkdir -p $out
|
||||
ln -s ${locationsXml} $out/locations.xml
|
||||
mkdir -p "$out"
|
||||
|
||||
docgen asserts 'Assert functions'
|
||||
docgen attrsets 'Attribute-set functions'
|
||||
docgen strings 'String manipulation functions'
|
||||
docgen trivial 'Miscellaneous functions'
|
||||
docgen lists 'List manipulation functions'
|
||||
docgen debug 'Debugging functions'
|
||||
docgen options 'NixOS / nixpkgs option handling'
|
||||
docgen filesystem 'Filesystem functions'
|
||||
docgen sources 'Source filtering functions'
|
||||
cat > "$out/index.xml" << 'EOF'
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root xmlns:xi="http://www.w3.org/2001/XInclude">
|
||||
EOF
|
||||
|
||||
${lib.concatMapStrings ({ name, description }: ''
|
||||
docgen ${name} ${lib.escapeShellArg description}
|
||||
'') libsets}
|
||||
|
||||
echo "</root>" >> "$out/index.xml"
|
||||
|
||||
ln -s ${locationsXml} $out/locations.xml
|
||||
'';
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
{ pkgs ? (import ./.. { }), nixpkgs ? { }}:
|
||||
{ pkgs, nixpkgs ? { }, libsets }:
|
||||
let
|
||||
revision = pkgs.lib.trivial.revisionWithDefault (nixpkgs.revision or "master");
|
||||
|
||||
@ -16,9 +16,7 @@ let
|
||||
subsetname = subsetname;
|
||||
functions = libDefPos toplib.${subsetname};
|
||||
})
|
||||
(builtins.filter
|
||||
(name: builtins.isAttrs toplib.${name})
|
||||
(builtins.attrNames toplib));
|
||||
(builtins.map (x: x.name) libsets);
|
||||
|
||||
nixpkgsLib = pkgs.lib;
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
<xsl:param name="html.script" select="'./highlightjs/highlight.pack.js ./highlightjs/loader.js'" />
|
||||
<xsl:param name="xref.with.number.and.title" select="0" />
|
||||
<xsl:param name="use.id.as.filename" select="1" />
|
||||
<xsl:param name="generate.section.toc.level" select="1" />
|
||||
<xsl:param name="toc.section.depth" select="0" />
|
||||
<xsl:param name="admon.style" select="''" />
|
||||
<xsl:param name="callout.graphics.extension" select="'.svg'" />
|
||||
|
@ -8,25 +8,7 @@
|
||||
Nixpkgs provides a standard library at <varname>pkgs.lib</varname>, or through <code>import <nixpkgs/lib></code>.
|
||||
</para>
|
||||
|
||||
<!-- These docs are generated via nixdoc. To add another generated
|
||||
library function file to this list, the file
|
||||
`lib-function-docs.nix` must also be updated. -->
|
||||
|
||||
<xi:include href="./library/generated/asserts.xml" />
|
||||
|
||||
<xi:include href="./library/generated/attrsets.xml" />
|
||||
|
||||
<xi:include href="./library/generated/strings.xml" />
|
||||
|
||||
<xi:include href="./library/generated/trivial.xml" />
|
||||
|
||||
<xi:include href="./library/generated/lists.xml" />
|
||||
|
||||
<xi:include href="./library/generated/debug.xml" />
|
||||
|
||||
<xi:include href="./library/generated/options.xml" />
|
||||
|
||||
<xi:include href="./library/generated/filesystem.xml" />
|
||||
|
||||
<xi:include href="./library/generated/sources.xml" />
|
||||
<!-- The index must have a root element to declare namespaces, but we
|
||||
don't want to include it, so we select all of its children. -->
|
||||
<xi:include href="./library/generated/index.xml" xpointer="xpointer(/root/*)" />
|
||||
</section>
|
||||
|
Loading…
Reference in New Issue
Block a user