docs: make template descriptions nicer
This commit is contained in:
parent
9201edf945
commit
9b96ed7a25
1 changed files with 18 additions and 10 deletions
28
flake.nix
28
flake.nix
|
|
@ -6,6 +6,15 @@
|
||||||
concatMapAttrs = func: attr:
|
concatMapAttrs = func: attr:
|
||||||
foldl' (x: y: x // y) {} (map 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
|
# Template Aliases
|
||||||
# Used to pick default template for each language
|
# Used to pick default template for each language
|
||||||
aliases = {
|
aliases = {
|
||||||
|
|
@ -33,19 +42,18 @@
|
||||||
map (l: [ subd ] ++ l) (flakeSubdirs /${dir}/${subd}))
|
map (l: [ subd ] ++ l) (flakeSubdirs /${dir}/${subd}))
|
||||||
(subdirs dir);
|
(subdirs dir);
|
||||||
|
|
||||||
generateDesc = subds:
|
generateDesc = fields:
|
||||||
"${head subds} template - ${concatStringsSep ", " (tail subds)}";
|
let
|
||||||
|
lang = head fields;
|
||||||
|
in "${display-names.${lang} or lang} template (${concatStringsSep ", " (tail fields)})";
|
||||||
in {
|
in {
|
||||||
templates = concatMapAttrs (subds: {
|
templates = concatMapAttrs (fields: {
|
||||||
${concatStringsSep "_" subds} = {
|
${concatStringsSep "_" fields} = {
|
||||||
description = generateDesc subds;
|
description = generateDesc fields;
|
||||||
path = filterSource
|
path = filterSource
|
||||||
(p: _: !(elem (baseNameOf p) template-ignore))
|
(p: _: !(elem (baseNameOf p) template-ignore))
|
||||||
(foldl' (dir: subd: /${dir}/${subd}) ./. subds);
|
(foldl' (dir: subd: /${dir}/${subd}) ./. fields);
|
||||||
};
|
};
|
||||||
}) (flakeSubdirs ./.) // mapAttrs (from: to:
|
}) (flakeSubdirs ./.) // mapAttrs (from: to: self.templates.${to}) aliases;
|
||||||
self.templates.${to} // {
|
|
||||||
description = generateDesc (filter (p: p != []) (split "_" to));
|
|
||||||
}) aliases;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue