mirror of
https://github.com/NorfairKing/autodocodec.git
synced 2024-11-22 22:33:01 +03:00
output text instead of bytestrings
This commit is contained in:
parent
176a4eced3
commit
d9a36061ac
@ -1,5 +1,11 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [0.2.0.1] - 2022-04-28
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
* Changed `renderPlainSchemaVia`, `renderPlainSchemaViaCodec`, `renderColouredSchemaVia` and `renderColouredSchemaViaCodec` to output `Text` instead of `ByteString`.
|
||||||
|
|
||||||
## [0.1.0.1] - 2022-04-26
|
## [0.1.0.1] - 2022-04-26
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
cabal-version: 1.12
|
cabal-version: 1.12
|
||||||
|
|
||||||
-- This file has been generated from package.yaml by hpack version 0.34.5.
|
-- This file has been generated from package.yaml by hpack version 0.34.7.
|
||||||
--
|
--
|
||||||
-- see: https://github.com/sol/hpack
|
-- see: https://github.com/sol/hpack
|
||||||
|
|
||||||
name: autodocodec-yaml
|
name: autodocodec-yaml
|
||||||
version: 0.1.0.1
|
version: 0.2.0.0
|
||||||
synopsis: Autodocodec interpreters for yaml
|
synopsis: Autodocodec interpreters for yaml
|
||||||
homepage: https://github.com/NorfairKing/autodocodec#readme
|
homepage: https://github.com/NorfairKing/autodocodec#readme
|
||||||
bug-reports: https://github.com/NorfairKing/autodocodec/issues
|
bug-reports: https://github.com/NorfairKing/autodocodec/issues
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: autodocodec-yaml
|
name: autodocodec-yaml
|
||||||
version: 0.1.0.1
|
version: 0.2.0.0
|
||||||
github: "NorfairKing/autodocodec"
|
github: "NorfairKing/autodocodec"
|
||||||
license: MIT
|
license: MIT
|
||||||
author: "Tom Sydney Kerckhove"
|
author: "Tom Sydney Kerckhove"
|
||||||
|
@ -8,8 +8,6 @@ import Autodocodec
|
|||||||
import Autodocodec.Yaml.Schema
|
import Autodocodec.Yaml.Schema
|
||||||
import qualified Data.ByteString as SB
|
import qualified Data.ByteString as SB
|
||||||
import qualified Data.Text as T
|
import qualified Data.Text as T
|
||||||
import qualified Data.Text.Encoding as TE
|
|
||||||
import qualified Data.Text.Encoding.Error as TE
|
|
||||||
import qualified Data.Yaml as Yaml
|
import qualified Data.Yaml as Yaml
|
||||||
import Path
|
import Path
|
||||||
import Path.IO
|
import Path.IO
|
||||||
@ -50,7 +48,7 @@ readFirstYamlConfigFile files = go files
|
|||||||
fs -> "While parsing files:" : map (("* " <>) . toFilePath) fs
|
fs -> "While parsing files:" : map (("* " <>) . toFilePath) fs
|
||||||
referenceMsgs =
|
referenceMsgs =
|
||||||
[ "Reference: ",
|
[ "Reference: ",
|
||||||
T.unpack $ TE.decodeUtf8With TE.lenientDecode (renderColouredSchemaViaCodec @a)
|
T.unpack $ renderColouredSchemaViaCodec @a
|
||||||
]
|
]
|
||||||
die $
|
die $
|
||||||
unlines $
|
unlines $
|
||||||
|
@ -9,7 +9,6 @@ module Autodocodec.Yaml.Schema where
|
|||||||
|
|
||||||
import Autodocodec
|
import Autodocodec
|
||||||
import Autodocodec.Schema
|
import Autodocodec.Schema
|
||||||
import Data.ByteString (ByteString)
|
|
||||||
import Data.List.NonEmpty (NonEmpty (..))
|
import Data.List.NonEmpty (NonEmpty (..))
|
||||||
import qualified Data.List.NonEmpty as NE
|
import qualified Data.List.NonEmpty as NE
|
||||||
import qualified Data.Map as M
|
import qualified Data.Map as M
|
||||||
@ -22,20 +21,20 @@ import Data.Yaml as Yaml
|
|||||||
import Text.Colour
|
import Text.Colour
|
||||||
|
|
||||||
-- | Render a human-readable schema for a type's 'codec', in colour.
|
-- | Render a human-readable schema for a type's 'codec', in colour.
|
||||||
renderColouredSchemaViaCodec :: forall a. HasCodec a => ByteString
|
renderColouredSchemaViaCodec :: forall a. HasCodec a => Text
|
||||||
renderColouredSchemaViaCodec = renderColouredSchemaVia (codec @a)
|
renderColouredSchemaViaCodec = renderColouredSchemaVia (codec @a)
|
||||||
|
|
||||||
-- | Render a human-readable schema for a given codec, in colour.
|
-- | Render a human-readable schema for a given codec, in colour.
|
||||||
renderColouredSchemaVia :: ValueCodec input output -> ByteString
|
renderColouredSchemaVia :: ValueCodec input output -> Text
|
||||||
renderColouredSchemaVia = renderChunksBS With24BitColours . schemaChunksVia
|
renderColouredSchemaVia = renderChunksText With24BitColours . schemaChunksVia
|
||||||
|
|
||||||
-- | Render a human-readable schema for a type's 'codec', without colour.
|
-- | Render a human-readable schema for a type's 'codec', without colour.
|
||||||
renderPlainSchemaViaCodec :: forall a. HasCodec a => ByteString
|
renderPlainSchemaViaCodec :: forall a. HasCodec a => Text
|
||||||
renderPlainSchemaViaCodec = renderPlainSchemaVia (codec @a)
|
renderPlainSchemaViaCodec = renderPlainSchemaVia (codec @a)
|
||||||
|
|
||||||
-- | Render a human-readable schema for a given codec, without colour.
|
-- | Render a human-readable schema for a given codec, without colour.
|
||||||
renderPlainSchemaVia :: ValueCodec input output -> ByteString
|
renderPlainSchemaVia :: ValueCodec input output -> Text
|
||||||
renderPlainSchemaVia = renderChunksBS WithoutColours . schemaChunksVia
|
renderPlainSchemaVia = renderChunksText WithoutColours . schemaChunksVia
|
||||||
|
|
||||||
-- | Produce potentially-coloured 'Chunk's for a human-readable schema for a type's 'codec'.
|
-- | Produce potentially-coloured 'Chunk's for a human-readable schema for a type's 'codec'.
|
||||||
schemaChunksViaCodec :: forall a. HasCodec a => [Chunk]
|
schemaChunksViaCodec :: forall a. HasCodec a => [Chunk]
|
||||||
|
@ -29,10 +29,10 @@
|
|||||||
"homepage": "",
|
"homepage": "",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "d17a56d90ecbd1b8fc908d49598fb854ef188461",
|
"rev": "cd90e773eae83ba7733d2377b6cdf84d45558780",
|
||||||
"sha256": "04a9ry0kk4qzy622mk3izh4azdp7plf1847mfp3zkn9gk0innswg",
|
"sha256": "1b2wn1ncx9x4651vfcgyqrm93pd7ghnrgqjbkf6ckkpidah69m03",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/NixOS/nixpkgs/archive/d17a56d90ecbd1b8fc908d49598fb854ef188461.tar.gz",
|
"url": "https://github.com/NixOS/nixpkgs/archive/cd90e773eae83ba7733d2377b6cdf84d45558780.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"nixpkgs-22_05": {
|
"nixpkgs-22_05": {
|
||||||
@ -41,10 +41,10 @@
|
|||||||
"homepage": "",
|
"homepage": "",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "d17a56d90ecbd1b8fc908d49598fb854ef188461",
|
"rev": "cd90e773eae83ba7733d2377b6cdf84d45558780",
|
||||||
"sha256": "04a9ry0kk4qzy622mk3izh4azdp7plf1847mfp3zkn9gk0innswg",
|
"sha256": "1b2wn1ncx9x4651vfcgyqrm93pd7ghnrgqjbkf6ckkpidah69m03",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/NixOS/nixpkgs/archive/d17a56d90ecbd1b8fc908d49598fb854ef188461.tar.gz",
|
"url": "https://github.com/NixOS/nixpkgs/archive/cd90e773eae83ba7733d2377b6cdf84d45558780.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"pre-commit-hooks": {
|
"pre-commit-hooks": {
|
||||||
@ -53,10 +53,10 @@
|
|||||||
"homepage": "",
|
"homepage": "",
|
||||||
"owner": "cachix",
|
"owner": "cachix",
|
||||||
"repo": "pre-commit-hooks.nix",
|
"repo": "pre-commit-hooks.nix",
|
||||||
"rev": "521a524771a8e93caddaa0ac1d67d03766a8b0b3",
|
"rev": "db3bd555d3a3ceab208bed48f983ccaa6a71a25e",
|
||||||
"sha256": "16qfrylk41r7gc7g4352hxz7b3vk9w7bc6893apmmr6yy08ra0m9",
|
"sha256": "1jq33qaayi253xvpa1clh5ib83zh2dfgcxmp6d3ya894x9md3l6b",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/cachix/pre-commit-hooks.nix/archive/521a524771a8e93caddaa0ac1d67d03766a8b0b3.tar.gz",
|
"url": "https://github.com/cachix/pre-commit-hooks.nix/archive/db3bd555d3a3ceab208bed48f983ccaa6a71a25e.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"safe-coloured-text": {
|
"safe-coloured-text": {
|
||||||
@ -65,22 +65,22 @@
|
|||||||
"homepage": "https://cs-syd.eu/posts/2021-03-07-safe-coloured-text",
|
"homepage": "https://cs-syd.eu/posts/2021-03-07-safe-coloured-text",
|
||||||
"owner": "NorfairKing",
|
"owner": "NorfairKing",
|
||||||
"repo": "safe-coloured-text",
|
"repo": "safe-coloured-text",
|
||||||
"rev": "71c5940a3b84eeb498304d8e584e7638f875d51b",
|
"rev": "d3fb43703a4b927362b7b83d8f2313173ad091a5",
|
||||||
"sha256": "05lw5xxwzikricmkpbxf04rk2ikak05wwbihqy6dql7mckavfyda",
|
"sha256": "0vva5qlqzgmbj7vslxqvm2h91kq49c0gqbvsrdnszbbnmbgjh545",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/NorfairKing/safe-coloured-text/archive/71c5940a3b84eeb498304d8e584e7638f875d51b.tar.gz",
|
"url": "https://github.com/NorfairKing/safe-coloured-text/archive/d3fb43703a4b927362b7b83d8f2313173ad091a5.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"sydtest": {
|
"sydtest": {
|
||||||
"branch": "master",
|
"branch": "development",
|
||||||
"description": "A modern testing framework for Haskell with good defaults and advanced testing features.",
|
"description": "A modern testing framework for Haskell with good defaults and advanced testing features.",
|
||||||
"homepage": "",
|
"homepage": "",
|
||||||
"owner": "NorfairKing",
|
"owner": "NorfairKing",
|
||||||
"repo": "sydtest",
|
"repo": "sydtest",
|
||||||
"rev": "263745786c277fab6d82ff6f48b6d745ade7a314",
|
"rev": "934bbf9cef011ea16ee0e8d8144e221d4a7cf2fb",
|
||||||
"sha256": "0r6xh7ajz15m7bgcsnrbk529hnkfahmfv1ay1lyb98850lh3v7xk",
|
"sha256": "001s7z0s6rb0ahbw0crdzzqvsm25mpz1lzgh9kmxdbqnv8zl1cyc",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/NorfairKing/sydtest/archive/263745786c277fab6d82ff6f48b6d745ade7a314.tar.gz",
|
"url": "https://github.com/NorfairKing/sydtest/archive/934bbf9cef011ea16ee0e8d8144e221d4a7cf2fb.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"validity": {
|
"validity": {
|
||||||
@ -89,10 +89,10 @@
|
|||||||
"homepage": "https://www.youtube.com/watch?v=eIs9qNh17SM",
|
"homepage": "https://www.youtube.com/watch?v=eIs9qNh17SM",
|
||||||
"owner": "NorfairKing",
|
"owner": "NorfairKing",
|
||||||
"repo": "validity",
|
"repo": "validity",
|
||||||
"rev": "160e846cc5de8e92e6758172da341f5d81fe0374",
|
"rev": "d88be911a7e2a84f6c089e9269aaed8d10a74acd",
|
||||||
"sha256": "03a4s2gq1mjjd452xbhs0h1iycjpdidxprpvjiwy55hx0lzqfpli",
|
"sha256": "088zl9vp7579qj1gqh1j8kb0035zjjp41k1yiww58x57pym200g7",
|
||||||
"type": "tarball",
|
"type": "tarball",
|
||||||
"url": "https://github.com/NorfairKing/validity/archive/160e846cc5de8e92e6758172da341f5d81fe0374.tar.gz",
|
"url": "https://github.com/NorfairKing/validity/archive/d88be911a7e2a84f6c089e9269aaed8d10a74acd.tar.gz",
|
||||||
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz"
|
||||||
},
|
},
|
||||||
"yamlparse-applicative": {
|
"yamlparse-applicative": {
|
||||||
|
@ -8,7 +8,7 @@ packages:
|
|||||||
- autodocodec-yaml
|
- autodocodec-yaml
|
||||||
extra-deps:
|
extra-deps:
|
||||||
- github: NorfairKing/validity
|
- github: NorfairKing/validity
|
||||||
commit: 160e846cc5de8e92e6758172da341f5d81fe0374
|
commit: d88be911a7e2a84f6c089e9269aaed8d10a74acd
|
||||||
subdirs:
|
subdirs:
|
||||||
- validity
|
- validity
|
||||||
- validity-aeson
|
- validity-aeson
|
||||||
@ -23,13 +23,13 @@ extra-deps:
|
|||||||
- genvalidity-text
|
- genvalidity-text
|
||||||
|
|
||||||
- github: NorfairKing/safe-coloured-text
|
- github: NorfairKing/safe-coloured-text
|
||||||
commit: 71c5940a3b84eeb498304d8e584e7638f875d51b
|
commit: d3fb43703a4b927362b7b83d8f2313173ad091a5
|
||||||
subdirs:
|
subdirs:
|
||||||
- safe-coloured-text
|
- safe-coloured-text
|
||||||
- safe-coloured-text-terminfo
|
- safe-coloured-text-terminfo
|
||||||
|
|
||||||
- github: NorfairKing/sydtest
|
- github: NorfairKing/sydtest
|
||||||
commit: 263745786c277fab6d82ff6f48b6d745ade7a314
|
commit: 934bbf9cef011ea16ee0e8d8144e221d4a7cf2fb
|
||||||
subdirs:
|
subdirs:
|
||||||
- sydtest
|
- sydtest
|
||||||
- sydtest-aeson
|
- sydtest-aeson
|
||||||
|
Loading…
Reference in New Issue
Block a user