Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle fix schema renderer #1824

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/doc/Swarm/Doc/Schema/Refined.hs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ getSchemaReferences = \case
Alternatives xs -> concatMap getSchemaReferences xs
Reference x -> pure x
ListOf x -> getSchemaReferences x
EnumList _ -> []

-- | A subset of all JSON schemas, conforming to internal Swarm conventions.
--
Expand Down
2 changes: 2 additions & 0 deletions app/doc/Swarm/Doc/Schema/Render.hs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Control.Monad.IO.Class (liftIO)
import Control.Monad.Trans.Except (except)
import Data.Aeson
import Data.List (intersperse)
import Data.List.NonEmpty qualified as NE
import Data.Map (Map)
import Data.Map.Strict qualified as M
import Data.Maybe (fromMaybe)
Expand Down Expand Up @@ -176,6 +177,7 @@ listToText titleMap = \case
Alternatives xs -> renderAlternatives $ map (listToText titleMap) xs
Reference r@(SchemaIdReference x) -> schemaLink r x
ListOf x -> listToText titleMap x <> text " list"
EnumList xs -> renderAlternatives $ NE.toList $ text <$> xs
where
renderAlternatives = mconcat . intersperse (text " or ")
schemaLink r = link (fragmentHref titleMap r) "Link to object properties" . text
Expand Down
2 changes: 2 additions & 0 deletions app/doc/Swarm/Doc/Schema/SchemaType.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module Swarm.Doc.Schema.SchemaType where

import Control.Applicative ((<|>))
import Data.Aeson
import Data.List.NonEmpty (NonEmpty)
import Data.Text (Text)
import Data.Text qualified as T
import System.FilePath (takeBaseName)
Expand All @@ -29,6 +30,7 @@ data SchemaType
Reference SchemaIdReference
| -- | Members of a list, all of the given schema type
ListOf SchemaType
| EnumList (NonEmpty Text)
deriving (Eq, Ord, Show)

newtype SchemaIdReference = SchemaIdReference Text
Expand Down