meta: extend meta.nixvimInfo support treewide

Rather than supplying a `kind` and `name` pair, we now supply a raw
path.

This path could point to any nixvim option.
This commit is contained in:
Matt Sturgeon 2024-06-07 21:30:00 +01:00
parent b2a477260d
commit f34fda8d99
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
4 changed files with 28 additions and 23 deletions

View file

@ -67,17 +67,18 @@ let
filterAttrs (_: component: component.isOption && (isVisible component)) opts;
path = removeWhitespace (concatStringsSep "/" path);
moduleDoc =
if builtins.length path >= 2 && lib.hasAttrByPath path nixvimInfo then
let
info = lib.getAttrFromPath path nixvimInfo;
maintainers = lib.unique (options.config.meta.maintainers.${info.file} or [ ]);
maintainersNames = builtins.map (m: m.name) maintainers;
in
let
info = optionalAttrs (hasAttrByPath path nixvimInfo) (getAttrFromPath path nixvimInfo);
maintainers = lib.unique (options.config.meta.maintainers.${info.file} or [ ]);
maintainersNames = builtins.map (m: m.name) maintainers;
in
# Make sure this path has a valid info attrset
if info ? file && info ? description && info ? url then
"# ${lib.last path}\n\n"
+ (lib.optionalString (info.description != null) "${info.description}\n\n")
+ (lib.optionalString (info.url != null) "**Url:** [${info.url}](${info.url})\n\n")
+ (lib.optionalString (
builtins.length maintainers > 0
maintainers != [ ]
) "**Maintainers:** ${lib.concatStringsSep ", " maintainersNames}\n\n")
else
null;