docs: make template descriptions nicer

This commit is contained in:
Kiana Sheibani 2026-01-19 14:36:06 -05:00
parent 9201edf945
commit 9b96ed7a25
Signed by: toki
GPG key ID: 6CB106C25E86A9F7

View file

@ -6,6 +6,15 @@
concatMapAttrs = func: attr:
foldl' (x: y: x // y) {} (map func attr);
# Display names of languages for template descriptions
display-names = {
bash = "Bash";
fish = "Fish";
c = "C";
python = "Python";
rust = "Rust";
};
# Template Aliases
# Used to pick default template for each language
aliases = {
@ -33,19 +42,18 @@
map (l: [ subd ] ++ l) (flakeSubdirs /${dir}/${subd}))
(subdirs dir);
generateDesc = subds:
"${head subds} template - ${concatStringsSep ", " (tail subds)}";
generateDesc = fields:
let
lang = head fields;
in "${display-names.${lang} or lang} template (${concatStringsSep ", " (tail fields)})";
in {
templates = concatMapAttrs (subds: {
${concatStringsSep "_" subds} = {
description = generateDesc subds;
templates = concatMapAttrs (fields: {
${concatStringsSep "_" fields} = {
description = generateDesc fields;
path = filterSource
(p: _: !(elem (baseNameOf p) template-ignore))
(foldl' (dir: subd: /${dir}/${subd}) ./. subds);
(foldl' (dir: subd: /${dir}/${subd}) ./. fields);
};
}) (flakeSubdirs ./.) // mapAttrs (from: to:
self.templates.${to} // {
description = generateDesc (filter (p: p != []) (split "_" to));
}) aliases;
}) (flakeSubdirs ./.) // mapAttrs (from: to: self.templates.${to}) aliases;
};
}