Skip to content

Commit

Permalink
Style.
Browse files Browse the repository at this point in the history
  • Loading branch information
damianfral committed Jun 10, 2024
1 parent 00c73d1 commit a47ff69
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion ghcaniuse.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.12

-- This file has been generated from package.yaml by hpack version 0.35.2.
-- This file has been generated from package.yaml by hpack version 0.36.0.
--
-- see: https://github.com/sol/hpack

Expand Down
17 changes: 10 additions & 7 deletions src/GHCanIUse/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ instance ParseRecord (Options Wrapped) where
runCLI :: IO ()
runCLI = do
options <-
unwrapRecord $
unwords ["GHCanIUse", "v" <> pack (showVersion GHCanIUse.version)]
unwrapRecord
$ unwords ["GHCanIUse", "v" <> pack (showVersion GHCanIUse.version)]
releases <- getGHCReleases options
stopGlobalPool
renderToFile "index.html" $ generatePage $ ghcReleasesToExtensionsMap releases
Expand All @@ -66,8 +66,11 @@ processVersion Options {..} ghcVersion = do
where
getFilePath = (directory </>) . unpack . getLanguagesFileName
logEntry (ext, url) =
putStrLn . unpack $
displayLangAtVersion ext ghcVersion <> " -> " <> maybe "" render url
putStrLn
. unpack
$ displayLangAtVersion ext ghcVersion
<> " -> "
<> maybe "" render url

getLanguagesFromFile :: FilePath -> IO (Set LanguageExtension)
getLanguagesFromFile fp = do
Expand All @@ -92,15 +95,15 @@ makeGHCRelease releaseVersion releaseLanguages =

ghcUserGuideURL :: GHCVersion -> URI
ghcUserGuideURL v@(GHCVersion {..}) =
fromMaybe baseURI $
emptyURI
fromMaybe baseURI
$ emptyURI
{ uriScheme = Nothing,
uriAuthority = Left False,
uriPath = sequence pathsNE >>= \paths -> pure (True, paths),
uriQuery = [],
uriFragment = Nothing
}
`relativeTo` baseURI
`relativeTo` baseURI
where
versionNumbers = [major, minor, patch]
ghcPath = mkPathPiece $ pack "~ghc"
Expand Down
19 changes: 11 additions & 8 deletions src/GHCanIUse/Render.hs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import qualified Paths_ghcaniuse as GHCanIUse
import Relude
import Text.URI (render)

(!) :: With a => a -> Attribute -> a
(!) :: (With a) => a -> Attribute -> a
(!) a b = a `with` [b]

flexRow :: (With (arg -> result), Term arg result) => arg -> result
Expand All @@ -34,13 +34,16 @@ arrows = p_ [class_ "arrows tc f3 pl2"] do
span_ ! class_ "up-arrow ml-1" $ ""

generateHTMLTable :: LanguageExtensionsMap -> Html ()
generateHTMLTable languageExtensions = article_ ! class_ "w100" $
table_ [id_ "ghc-extensions-table", class_ "bg-white m0"] do
generateHTMLTable languageExtensions = article_
! class_ "w100"
$ table_ [id_ "ghc-extensions-table", class_ "bg-white m0"] do
thead_ $ tr_ [class_ "bg-white"] do
th_ $ flexRow $ h4_ "Language Extensions" >> arrows
mapM_ th_ $ displayReleaseHTML <$> allReleases
tbody_ ! class_ "lh-solid" $
forM_ allExtensions $ \extension -> tr_ do
tbody_
! class_ "lh-solid"
$ forM_ allExtensions
$ \extension -> tr_ do
th_ ! class_ "tl bg-white" $ toHtml $ unLanguageExtension extension
forM_ allReleases $ renderCell extension
where
Expand Down Expand Up @@ -90,9 +93,9 @@ template content = doctypehtml_ do
body_ [class_ "f4 bg-black pr flex flex-column"] do
header
content
script_ [type_ "text/javascript"] $
tableSort
<> "\nnew Tablesort(document.getElementById('ghc-extensions-table'));"
script_ [type_ "text/javascript"]
$ tableSort
<> "\nnew Tablesort(document.getElementById('ghc-extensions-table'));"
where
keywords = "GHC, haskell, language extensions, table, nix, NixOS, table"
description = "Browse the supported language extensions for different GHC versions."
Expand Down
6 changes: 3 additions & 3 deletions test/GHCanIUseSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@

module GHCanIUseSpec where

import Control.Concurrent.ParallelIO (parallelInterleaved)
import qualified Data.Map as Map
import qualified Data.Set as Set
import Data.Text (unpack)
import GHCanIUse.CLI
import GHCanIUse.Types
import Network.HTTP.Req
import Options.Generic (Unwrapped)
import Relude
import Test.Syd
import Text.URI
import Options.Generic (Unwrapped)
import Control.Concurrent.ParallelIO (parallelInterleaved)

checkURLDocExists :: URI -> IO ()
checkURLDocExists url' = do
Expand Down Expand Up @@ -43,6 +43,6 @@ spec =
[release] -> do
let docs = releaseLanguages release
let urls = catMaybes $ Map.elems $ unLanguageExtensionsDocs docs
void $ liftIO $ parallelInterleaved $ checkURLDocExists <$> urls
void $ liftIO $ parallelInterleaved $ checkURLDocExists <$> urls
[] -> expectationFailure $ "Couldn't process " <> show v
_ -> expectationFailure "Produced mored releases than 1"

0 comments on commit a47ff69

Please sign in to comment.