Require README.md for every clan module

This commit is contained in:
Luis Hebendanz 2024-05-01 23:35:14 +02:00
parent 853d8221c0
commit a09e680fa0
4 changed files with 18 additions and 11 deletions

View File

@ -1,7 +1,7 @@
Syncthing is a free, open-source file synchronization application designed to allow users to synchronize files between multiple devices over the internet or local networks securely and privately.
It is an alternative to cloud-based file sharing services.
---
## Usage
We recommend configuring this module as an sync-service through the provided options. Although it provides a Web GUI through which more usage scenarios are supported.

View File

@ -38,7 +38,7 @@ let
) clanModules;
clanModulesReadmes = builtins.mapAttrs (
module_name: _module: self.lib.modules.getDescription module_name
module_name: _module: self.lib.modules.getReadme module_name
) clanModules;
# clanCore docs

View File

@ -1,19 +1,26 @@
{ clan-core, ... }:
{
getDescription =
rec {
getReadme =
modulename:
let
readme = "${clan-core}/clanModules/${modulename}/README.md";
readmeContents =
if
builtins.trace "Trying to get Module README.md for ${modulename} from ${readme}"
# TODO: Edge cases
(builtins.pathExists readme)
then
if (builtins.pathExists readme) then
(builtins.readFile readme)
else
null;
throw "No README.md found for module ${modulename}";
in
readmeContents;
getShortDescription =
modulename:
let
content = (getReadme modulename);
parts = builtins.split "---" content;
in
if (builtins.length parts) > 0 then
builtins.head parts
else
throw "Short description delimiter `---` not found in README.md for module ${modulename}";
}

View File

@ -38,7 +38,7 @@
clanModuleFunctionSchemas = lib.mapAttrsFlatten (modulename: module: {
name = modulename;
description = self.lib.modules.getDescription modulename;
description = self.lib.modules.getShortDescription modulename;
parameters = self.lib.jsonschema.parseOptions (optionsFromModule modulename module);
}) clanModules;
in