Skip to content

Commit f09ff46

Browse files
committed
lib/plugins: define docs description for plugins
1 parent d6eafb1 commit f09ff46

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

lib/plugins/utils.nix

+31
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,24 @@
9696
{ options, ... }:
9797
let
9898
opts = lib.getAttrFromPath loc options;
99+
docsfile = lib.concatStringsSep "/" loc;
99100
url =
100101
if args.url or null == null then
101102
opts.package.default.meta.homepage or (throw "unable to get URL for `${lib.showOption loc}`.")
102103
else
103104
args.url;
105+
maintainersString =
106+
let
107+
toMD = m: if m ? github then "[${m.name}](https://github.com/${m.github})" else m.name;
108+
names = builtins.map toMD (lib.unique maintainers);
109+
count = builtins.length names;
110+
in
111+
if count == 1 then
112+
builtins.head names
113+
else if count == 2 then
114+
lib.concatStringsSep " and " names
115+
else
116+
lib.concatMapStrings (name: "\n- ${name}") names;
104117
in
105118
{
106119
meta = {
@@ -110,5 +123,23 @@
110123
path = loc;
111124
};
112125
};
126+
127+
docs.pages.${docsfile}.text = lib.mkMerge (
128+
[
129+
"# ${lib.last loc}"
130+
""
131+
"**URL:** [${url}](${url})"
132+
""
133+
]
134+
++ lib.optionals (maintainers != [ ]) [
135+
"**Maintainers:** ${maintainersString}"
136+
""
137+
]
138+
++ lib.optionals (description != null && description != "") [
139+
"---"
140+
""
141+
description
142+
]
143+
);
113144
};
114145
}

0 commit comments

Comments
 (0)