-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathlibrary.nix
89 lines (68 loc) · 1.64 KB
/
library.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{
inputs,
cell,
site,
}: let
inherit (inputs) nixpkgs;
inherit (cell) docslib styxlib;
l = nixpkgs.lib // builtins;
namespaces = let
fqFunctionName = namespace: name: "lib.${namespace}.${name}";
in
l.mapAttrs (
namespace: _: let
libset = site.loaded.lib.${namespace};
docFunctons = l.filterAttrs (_: styxlib.utils.isDocFunction) libset;
functions = l.mapAttrsToList (name: fn:
fn
// {
inherit namespace name;
fullname = fqFunctionName namespace name;
})
docFunctons;
in {
inherit functions;
documentation = l.optionalString (libset ? _documentation) (libset._documentation true);
}
)
{
"conf" = null;
"data" = null;
"generation" = null;
"pages" = null;
"proplist" = null;
"template" = null;
"themes" = null;
"utils" = null;
};
doc = nixpkgs.writeText "lib.adoc" ''
////
File automatically generated, do not edit
////
${l.concatStringsSep "\n" (
l.mapAttrsToList (namespace: data: ''
== ${namespace}
${data.documentation}
---
${l.concatStringsSep "\n\n---\n\n" (map docslib.mkFunctionDoc data.functions)}
---
'')
namespaces
)}
'';
in
nixpkgs.stdenv.mkDerivation {
name = "styx-docs";
preferLocalBuild = true;
allowSubstitutes = false;
unpackPhase = ":";
buildInputs = [nixpkgs.asciidoctor];
buildPhase = ''
mkdir build
cp ${doc} build/library-generated.adoc
'';
installPhase = ''
mkdir $out
cp build/* $out
'';
}