Skip to content

Commit

Permalink
Merge pull request #12 from m15a/update-docs
Browse files Browse the repository at this point in the history
Update docs
  • Loading branch information
m15a authored Feb 11, 2024
2 parents bdf21c4 + e47056b commit 5dd1354
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src/Choku/Color.purs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import Data.String.Regex.Flags (ignoreCase) as R
import Data.String.Regex.Unsafe (unsafeRegex) as R

data Color
-- | RGB digits. Each channel has the 8-bit range `0` to `255`.
-- | RGB digits. Each channel has 8-bit range from `0` to `255`.
= RGB { r :: Int, g :: Int, b :: Int }
-- | Hex number representation of the RGB color model, for example `#ED49DF`.
-- | Hex number representation of the RGB color model. Example: `#ED49DF`.
| Hex String
-- | [ANSI 256 colors](https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit),
-- | ranging from `0` to `255`.
Expand All @@ -40,7 +40,7 @@ instance Show Color where

-- | Safe constructor to make a `Color` from RGB values.
-- |
-- | Returns Nothing with out-of-bounds inputs.
-- | Returns `Nothing` with out-of-bounds inputs.
mkRGB :: Int -> Int -> Int -> Maybe Color
mkRGB r g b = do
guard $ r # between 0 255
Expand All @@ -50,7 +50,7 @@ mkRGB r g b = do

-- | Safe constructor to make a `Color` from Hex string.
-- |
-- | Returns Nothing with invalid Hex string.
-- | Returns `Nothing` with invalid Hex string.
-- | Prefix `#` is not mandatory.
-- | Hex digits of either length 6 (e.g., `#0a0b0c`) or 3 (e.g., `#ABC`) are accepted.
mkHex :: String -> Maybe Color
Expand All @@ -65,7 +65,7 @@ isHexStr = R.test $ R.unsafeRegex "^#?([0-9a-f]{6}|[0-9a-f]{3})$" R.ignoreCase

-- | Safe constructor to make a `Color` from ANSI256 integer value between 0 and 255.
-- |
-- | Returns Nothing with out-of-bounds input.
-- | Returns `Nothing` with out-of-bounds input.
mkANSI256 :: Int -> Maybe Color
mkANSI256 i = do
guard $ i # between 0 255
Expand Down
7 changes: 3 additions & 4 deletions src/Choku/Common.purs
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,12 @@ mkChoku = _newChalk <<< colorSupportLevelInt
-- |
-- | ```purescript
-- | import Prelude
-- | import Data.Maybe
-- | import Partial.Unsafe
-- | import Choku
-- |
-- | let
-- | chk = unsafePartial $ fromJust (mkChoku 3) # bold # cyan
-- | chalk = mkChoku Has16mColor # bold # cyan
-- | in
-- | "hello" `withChoku` chk
-- | "hello" `withChoku` chalk
-- | ```
-- |
-- | produces a bold cyan `"hello"` string.
Expand Down
2 changes: 0 additions & 2 deletions src/Choku/Stdout.purs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ foreign import supportsColor
-- | ```purescript
-- | import Prelude
-- | import Effect.Console
-- | import Data.Maybe
-- | import Partial.Unsafe
-- | import Choku
-- |
-- | log =<< "hello" `withStyle` (inverse >>> underline)
Expand Down
8 changes: 4 additions & 4 deletions src/Choku/Style.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
-- |
-- | These styles are of signature `Choku -> Choku`, appending another
-- | modification to any chalk.
-- | The full list of styles can be found [here](https://github.com/chalk/chalk#styles)
-- | in the original chalk's README.
-- |
-- | Check out the full list of styles [here](https://github.com/chalk/chalk#styles)
-- | in the original chalk's README.
-- | An only difference from the original API is that those six methods to apply
-- | styles using RGB/ANSI256 color models, namely `chalk.rgb()`, `chalk.hex()`,
-- | `chalk.ansi256()`, `chalk.bgRgb()`, `chalk.bgHex()`, and `chalk.bgAnsi256()` are
-- | integrated into two functions `fg` and `bg`, thanks to PureScript's GADTs.
-- | `chalk.ansi256()`, `chalk.bgRgb()`, `chalk.bgHex()`, and `chalk.bgAnsi256()`
-- | are integrated into two functions `fg` and `bg`, thanks to PureScript's GADTs.
-- |
-- | ### See also
-- |
Expand Down
8 changes: 4 additions & 4 deletions tools/generate-style-purs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ p("-- | Styles applied to chalks for modifying/colorizing strings.");
p("-- |");
p("-- | These styles are of signature `Choku -> Choku`, appending another");
p("-- | modification to any chalk.");
p("-- | The full list of styles can be found [here](https://github.com/chalk/chalk#styles)");
p("-- | in the original chalk's README.");
p("-- |");
p("-- | Check out the full list of styles [here](https://github.com/chalk/chalk#styles)");
p("-- | in the original chalk's README.");
p("-- | An only difference from the original API is that those six methods to apply");
p("-- | styles using RGB/ANSI256 color models, namely `chalk.rgb()`, `chalk.hex()`,");
p("-- | `chalk.ansi256()`, `chalk.bgRgb()`, `chalk.bgHex()`, and `chalk.bgAnsi256()` are");
p("-- | integrated into two functions `fg` and `bg`, thanks to PureScript's GADTs.");
p("-- | `chalk.ansi256()`, `chalk.bgRgb()`, `chalk.bgHex()`, and `chalk.bgAnsi256()`");
p("-- | are integrated into two functions `fg` and `bg`, thanks to PureScript's GADTs.");
p("-- |");
p("-- | ### See also");
p("-- |");
Expand Down

0 comments on commit 5dd1354

Please sign in to comment.