From 89a9bc32a0b1bec33df6239ec95d7a50a17e92b2 Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Sat, 24 Feb 2024 21:39:02 +0800 Subject: [PATCH] bahaghari/lib: reformat and update comments --- subprojects/bahaghari/lib/default.nix | 3 ++- subprojects/bahaghari/lib/hex.nix | 6 +++-- subprojects/bahaghari/lib/tinted-theming.nix | 27 +++++++++++++++++--- 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/subprojects/bahaghari/lib/default.nix b/subprojects/bahaghari/lib/default.nix index ae0f4458..387e07f0 100644 --- a/subprojects/bahaghari/lib/default.nix +++ b/subprojects/bahaghari/lib/default.nix @@ -20,6 +20,7 @@ pkgs.lib.makeExtensible # a top-level attribute. 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; }) diff --git a/subprojects/bahaghari/lib/hex.nix b/subprojects/bahaghari/lib/hex.nix index cb691e7f..f8d43fab 100644 --- a/subprojects/bahaghari/lib/hex.nix +++ b/subprojects/bahaghari/lib/hex.nix @@ -11,9 +11,11 @@ rec { Type: range :: Int -> Int -> [ String ] 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. diff --git a/subprojects/bahaghari/lib/tinted-theming.nix b/subprojects/bahaghari/lib/tinted-theming.nix index 05837166..6eed89d8 100644 --- a/subprojects/bahaghari/lib/tinted-theming.nix +++ b/subprojects/bahaghari/lib/tinted-theming.nix @@ -21,10 +21,31 @@ in # image. generateScheme = image: { }; - # A very naive implementation of checking if a Tinted Theming scheme is a - # Base16 scheme. + /* A very naive implementation of checking whether the given palette is a + 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; - # 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; }