docs: Allow to add an url in the online documentation (#1139)

* plugin/committia: Use correct maintainers import

* plugins/neocord: Remove redyf as the entry is not in the list

* docs: Allow to add an URL to the plugin
This commit is contained in:
traxys 2024-02-20 21:20:59 +01:00 committed by GitHub
parent 9d30e87455
commit 82a24d0d42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 88 additions and 6 deletions

View file

@ -12,6 +12,8 @@ with lib; let
specialArgs = {inherit pkgs lib helpers;}; specialArgs = {inherit pkgs lib helpers;};
}; };
inherit (options.config.meta) nixvimInfo;
mkMDDoc = options: mkMDDoc = options:
(nixosOptionsDoc { (nixosOptionsDoc {
inherit options transformOptions; inherit options transformOptions;
@ -59,6 +61,17 @@ with lib; let
then opts then opts
else filterAttrs (_: component: component.isOption && (isVisible component)) opts; else filterAttrs (_: component: component.isOption && (isVisible component)) opts;
path = removeWhitespace (concatStringsSep "/" path); path = removeWhitespace (concatStringsSep "/" path);
moduleDoc =
if builtins.length path >= 2 && lib.hasAttrByPath path nixvimInfo
then let
info = lib.getAttrFromPath path nixvimInfo;
maintainers = options.config.meta.maintainers."${info.file}" or null;
in
"# ${lib.last path}\n\n"
+ (lib.optionalString (maintainers != null && builtins.length maintainers > 0)
"Maintainers: ${lib.concatStringsSep ", " (builtins.map (m: m.name) maintainers)}\n\n")
+ (lib.optionalString (info.url != null) "Url: [${info.url}](${info.url})\n\n")
else null;
}; };
components = components =
@ -114,6 +127,7 @@ with lib; let
index = { index = {
options = {}; options = {};
path = removeWhitespace "${group}"; path = removeWhitespace "${group}";
moduleDoc = null;
}; };
components = {}; components = {};
isGroup = true; isGroup = true;
@ -183,7 +197,18 @@ with lib; let
in in
(optionalString isBranch (optionalString isBranch
"mkdir -p ${opts.index.path}\n") "mkdir -p ${opts.index.path}\n")
+ "cp ${mkMDDoc opts.index.options} ${path}" + (
if opts.index.moduleDoc == null
then "cp ${mkMDDoc opts.index.options} ${path}"
else ''
{
cat <<EOF
${opts.index.moduleDoc}
EOF
cat ${mkMDDoc opts.index.options}
} > ${path}
''
)
) )
modules; modules;
}; };

View file

@ -17,6 +17,47 @@
../modules ../modules
nixpkgsMaintainersList nixpkgsMaintainersList
nixvimExtraArgsModule nixvimExtraArgsModule
({lib, ...}:
with lib; {
# Attribute may contain the following fields:
# - name: Name of the module
# - kind: Either colorschemes or plugins
# - url: Url for the plugin
#
# [kind name] will identify the plugin
#
# We need to use an attrs instead of a submodule to handle the merge.
options.meta.nixvimInfo = mkOption {
type =
(types.nullOr types.attrs)
// {
# This will create an attrset of the form:
# {
# "path"."to"."plugin" = { "<name>" = <info>; };
# }
#
# Where <info> is an attrset of the form:
# {file = "path"; url = null or "<URL>";}
merge = _: defs:
lib.foldl' (acc: def:
lib.recursiveUpdate acc {
"${def.value.kind}"."${def.value.name}" = {
inherit (def.value) url;
inherit (def) file;
};
}) {
plugins = {};
colorschemes = {};
}
defs;
};
internal = true;
default = null;
description = ''
Nixvim related information on the module
'';
};
})
]; ];
}; };

View file

@ -34,6 +34,7 @@ with lib; rec {
name, name,
namespace ? "plugins", namespace ? "plugins",
maintainers, maintainers,
url ? defaultPackage.meta.homepage,
imports ? [], imports ? [],
# deprecations # deprecations
deprecateExtraOptions ? false, deprecateExtraOptions ? false,
@ -51,7 +52,13 @@ with lib; rec {
extraPackages ? [], extraPackages ? [],
callSetup ? true, callSetup ? true,
}: { }: {
meta.maintainers = maintainers; meta = {
inherit maintainers;
nixvimInfo = {
inherit name url;
kind = namespace;
};
};
imports = let imports = let
basePluginPath = [namespace name]; basePluginPath = [namespace name];

View file

@ -7,6 +7,10 @@ with lib; {
mkVimPlugin = config: { mkVimPlugin = config: {
name, name,
namespace ? "plugins", namespace ? "plugins",
url ?
if defaultPackage != null
then defaultPackage.meta.homepage
else null,
maintainers ? [], maintainers ? [],
imports ? [], imports ? [],
# deprecations # deprecations
@ -80,7 +84,13 @@ with lib; {
}; };
}; };
in { in {
meta.maintainers = maintainers; meta = {
inherit maintainers;
nixvimInfo = {
inherit name url;
kind = namespace;
};
};
options.${namespace}.${name} = options.${namespace}.${name} =
{ {
enable = mkEnableOption originalName; enable = mkEnableOption originalName;

View file

@ -1,5 +1,4 @@
{ {
lib,
config, config,
helpers, helpers,
pkgs, pkgs,
@ -12,7 +11,7 @@ helpers.vim-plugin.mkVimPlugin config {
globalPrefix = "committia_"; globalPrefix = "committia_";
extraPackages = [pkgs.git]; extraPackages = [pkgs.git];
maintainers = [lib.maintainers.alisonjenkins]; maintainers = [helpers.maintainers.alisonjenkins];
settingsOptions = { settingsOptions = {
open_only_vim_starting = helpers.defaultNullOpts.mkBool true '' open_only_vim_starting = helpers.defaultNullOpts.mkBool true ''

View file

@ -10,7 +10,7 @@ with lib;
name = "neocord"; name = "neocord";
defaultPackage = pkgs.vimPlugins.neocord; defaultPackage = pkgs.vimPlugins.neocord;
maintainers = [maintainers.redyf]; maintainers = [];
settingsOptions = { settingsOptions = {
# General options. # General options.