forked from clan/clan-core
Add toml frontmatter description to jsonschema
This commit is contained in:
parent
cecd6011d6
commit
3777a4cf02
@ -8,7 +8,6 @@
|
|||||||
evalClanModules = import ./eval-clan-modules { inherit clan-core nixpkgs lib; };
|
evalClanModules = import ./eval-clan-modules { inherit clan-core nixpkgs lib; };
|
||||||
inventory = import ./inventory { inherit lib clan-core; };
|
inventory = import ./inventory { inherit lib clan-core; };
|
||||||
jsonschema = import ./jsonschema { inherit lib; };
|
jsonschema = import ./jsonschema { inherit lib; };
|
||||||
# TODO: migrate to also use toml frontmatter
|
modules = import ./description.nix { inherit clan-core lib; };
|
||||||
# modules = import ./description.nix { inherit clan-core lib; };
|
|
||||||
buildClan = import ./build-clan { inherit clan-core lib nixpkgs; };
|
buildClan = import ./build-clan { inherit clan-core lib nixpkgs; };
|
||||||
}
|
}
|
||||||
|
@ -1,33 +1,34 @@
|
|||||||
{ ... }:
|
{ clan-core, lib }:
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
# getReadme =
|
getReadme =
|
||||||
# modulename:
|
modulename:
|
||||||
# let
|
let
|
||||||
# readme = "${clan-core}/clanModules/${modulename}/README.md";
|
readme = "${clan-core}/clanModules/${modulename}/README.md";
|
||||||
# readmeContents =
|
readmeContents =
|
||||||
# if (builtins.pathExists readme) then
|
if (builtins.pathExists readme) then
|
||||||
# (builtins.readFile readme)
|
(builtins.readFile readme)
|
||||||
# else
|
else
|
||||||
# throw "No README.md found for module ${modulename}";
|
throw "No README.md found for module ${modulename}";
|
||||||
# in
|
in
|
||||||
# readmeContents;
|
readmeContents;
|
||||||
|
|
||||||
# getShortDescription =
|
getShortDescription =
|
||||||
# modulename:
|
modulename:
|
||||||
# let
|
let
|
||||||
# content = (getReadme modulename);
|
content = getReadme modulename;
|
||||||
# parts = lib.splitString "---" content;
|
parts = lib.splitString "---" content;
|
||||||
# description = builtins.head parts;
|
# Partition the parts into the first part (the readme content) and the rest (the metadata)
|
||||||
# number_of_newlines = builtins.length (lib.splitString "\n" description);
|
parsed = builtins.partition ({ index }: if index >= 2 then false else true) (
|
||||||
# in
|
lib.filter ({ index, ... }: index != 0) (lib.imap0 (index: part: { inherit index part; }) parts)
|
||||||
# if (builtins.length parts) > 1 then
|
);
|
||||||
# if number_of_newlines > 4 then
|
|
||||||
# throw "Short description in README.md for module ${modulename} is too long. Max 3 newlines."
|
# Use this if the content is needed
|
||||||
# else if number_of_newlines <= 1 then
|
# readmeContent = lib.concatMapStrings (v: "---" + v.part) parsed.wrong;
|
||||||
# throw "Missing short description in README.md for module ${modulename}."
|
|
||||||
# else
|
meta = builtins.fromTOML (builtins.head parsed.right).part;
|
||||||
# description
|
in
|
||||||
# else
|
if (builtins.length parts >= 3) then
|
||||||
# throw "Short description delimiter `---` not found in README.md for module ${modulename}";
|
meta.description
|
||||||
|
else
|
||||||
|
throw "Short description delimiter `---` not found in README.md for module ${modulename}";
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,7 @@
|
|||||||
|
|
||||||
clanModuleFunctionSchemas = lib.mapAttrsFlatten (modulename: _: {
|
clanModuleFunctionSchemas = lib.mapAttrsFlatten (modulename: _: {
|
||||||
name = modulename;
|
name = modulename;
|
||||||
# TODO: migrate to new toml format
|
description = self.lib.modules.getShortDescription modulename;
|
||||||
# description = self.lib.modules.getShortDescription modulename;
|
|
||||||
parameters = self.lib.jsonschema.parseOptions (optionsFromModule modulename);
|
parameters = self.lib.jsonschema.parseOptions (optionsFromModule modulename);
|
||||||
}) clanModules;
|
}) clanModules;
|
||||||
in
|
in
|
||||||
|
Loading…
Reference in New Issue
Block a user