2024-06-26 13:10:21 +00:00
|
|
|
{ clan-core, lib }:
|
2024-05-01 21:35:14 +00:00
|
|
|
rec {
|
2024-06-26 13:10:21 +00:00
|
|
|
getReadme =
|
|
|
|
modulename:
|
|
|
|
let
|
|
|
|
readme = "${clan-core}/clanModules/${modulename}/README.md";
|
|
|
|
readmeContents =
|
|
|
|
if (builtins.pathExists readme) then
|
|
|
|
(builtins.readFile readme)
|
|
|
|
else
|
|
|
|
throw "No README.md found for module ${modulename}";
|
|
|
|
in
|
|
|
|
readmeContents;
|
|
|
|
|
|
|
|
getShortDescription =
|
|
|
|
modulename:
|
|
|
|
let
|
|
|
|
content = getReadme modulename;
|
|
|
|
parts = lib.splitString "---" content;
|
|
|
|
# Partition the parts into the first part (the readme content) and the rest (the metadata)
|
2024-06-26 13:16:20 +00:00
|
|
|
parsed = builtins.partition ({ index, ... }: if index >= 2 then false else true) (
|
2024-06-26 13:10:21 +00:00
|
|
|
lib.filter ({ index, ... }: index != 0) (lib.imap0 (index: part: { inherit index part; }) parts)
|
|
|
|
);
|
|
|
|
|
|
|
|
# Use this if the content is needed
|
|
|
|
# readmeContent = lib.concatMapStrings (v: "---" + v.part) parsed.wrong;
|
2024-05-01 21:35:14 +00:00
|
|
|
|
2024-06-26 13:10:21 +00:00
|
|
|
meta = builtins.fromTOML (builtins.head parsed.right).part;
|
|
|
|
in
|
|
|
|
if (builtins.length parts >= 3) then
|
|
|
|
meta.description
|
|
|
|
else
|
|
|
|
throw "Short description delimiter `---` not found in README.md for module ${modulename}";
|
2024-05-01 21:16:17 +00:00
|
|
|
}
|