bahaghari/lib: reformat and update comments

This commit is contained in:
Gabriel Arazas 2024-02-24 21:39:02 +08:00
parent 4834595351
commit 89a9bc32a0
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC
3 changed files with 30 additions and 6 deletions

View File

@ -20,6 +20,7 @@ pkgs.lib.makeExtensible
# a top-level attribute. # a top-level attribute.
tinted-theming = callLibs ./tinted-theming.nix; tinted-theming = callLibs ./tinted-theming.nix;
inherit (self.trivial) importYAML toYAML toBaseDigitsWithGlyphs generateGlyphSet; inherit (self.trivial) importYAML toYAML toBaseDigitsWithGlyphs
generateGlyphSet;
inherit (self.hex) toHexString isHexString; inherit (self.hex) toHexString isHexString;
}) })

View File

@ -11,9 +11,11 @@ rec {
Type: range :: Int -> Int -> [ String ] Type: range :: Int -> Int -> [ String ]
Example: Example:
range 15 18 => [ "F" "10" "11" ] range 15 18
=> [ "F" "10" "11" ]
*/ */
range = first: last: builtins.map (n: toHexString n) (pkgs.lib.lists.range first last); range = first: last:
builtins.map (n: toHexString n) (pkgs.lib.lists.range first last);
/* Checks if the given hex string is valid or not. /* Checks if the given hex string is valid or not.

View File

@ -21,10 +21,31 @@ in
# image. # image.
generateScheme = image: { }; generateScheme = image: { };
# A very naive implementation of checking if a Tinted Theming scheme is a /* A very naive implementation of checking whether the given palette is a
# Base16 scheme. valid Base16 palette. It simply checks if `base00` to `base0F` is present.
Type: isBase16 :: Attrs -> Bool
Example:
isBase16 (bahaghariLib.importYAML ./base16.yml).palette
=> true
isBase16 (bahaghariLib.importYAML ./base16-scheme-with-missing-base0F.yml).palette
=> false
*/
isBase16 = isBaseX 16; isBase16 = isBaseX 16;
# Same but with Base24 scheme. /* Similar to `isBase16` but for Base24 schemes. It considers the scheme as
valid if `base00` to `base17` from the palette are present.
Type: isBase24 :: Attrs -> Bool
Example:
isBase24 (bahaghariLib.importYAML ./base24.yml).palette
=> true
isBase24 (bahaghariLib.importYAML ./base24-scheme-with-missing-base0F.yml).palette
=> false
*/
isBase24 = isBaseX 24; isBase24 = isBaseX 24;
} }