module Summoner.Template.Doc
( docFiles
) where
import Summoner.License (License (..), LicenseName (NONE))
import Summoner.Settings (Settings (..))
import Summoner.Tree (TreeFs (..))
import qualified Data.Text as T
docFiles :: Settings -> [TreeFs]
docFiles :: Settings -> [TreeFs]
docFiles Settings{..} =
[ FilePath -> Text -> TreeFs
File "README.md" Text
readme
, FilePath -> Text -> TreeFs
File "CHANGELOG.md" Text
changelog ] [TreeFs] -> [TreeFs] -> [TreeFs]
forall a. [a] -> [a] -> [a]
++
[ FilePath -> Text -> TreeFs
File "LICENSE" (License -> Text
unLicense License
settingsLicenseText) | Bool
hasLicense ]
where
hasLicense :: Bool
hasLicense :: Bool
hasLicense = LicenseName
settingsLicenseName LicenseName -> LicenseName -> Bool
forall a. Eq a => a -> a -> Bool
/= LicenseName
NONE
licenseName :: Text
licenseName :: Text
licenseName = LicenseName -> Text
forall b a. (Show a, IsString b) => a -> b
show LicenseName
settingsLicenseName
readme :: Text
readme :: Text
readme = [Text] -> Text
forall t. IsText t "unlines" => [t] -> t
unlines ([Text] -> Text) -> [Text] -> Text
forall a b. (a -> b) -> a -> b
$
[ "# " Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
settingsRepo
, ""
]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [Text
githubActionsBadge | Bool
settingsGhActions]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [Text
travisBadge | Bool
settingsTravis]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [Text
appVeyorBadge | Bool
settingsAppVeyor]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [Text
hackageBadge]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [Text
stackLtsBadge | Bool
settingsStack]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [Text
stackNightlyBadge | Bool
settingsStack]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [Text
licenseBadge | Bool
hasLicense]
[Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++ [""
, Text
settingsDescription
]
where
shieldsIo :: Text
shieldsIo :: Text
shieldsIo = "https://img.shields.io/"
hackageShield, hackageLink, hackageBadge :: Text
hackageShield :: Text
hackageShield = Text
shieldsIo Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "hackage/v/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
settingsRepo Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> ".svg?logo=haskell"
hackageLink :: Text
hackageLink = "https://hackage.haskell.org/package/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
settingsRepo
hackageBadge :: Text
hackageBadge = Text -> Text -> Text -> Text
makeBadge "Hackage" Text
hackageShield Text
hackageLink
licenseShield, licenseBadge :: Text
licenseShield :: Text
licenseShield = Text
shieldsIo Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "badge/license-" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text -> Text -> Text -> Text
T.replace "-" "--" Text
licenseName Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "-blue.svg"
licenseBadge :: Text
licenseBadge = Text -> Text -> Text -> Text
makeBadge (Text
licenseName Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> " license") Text
licenseShield "LICENSE"
stackOrg, stackLtsShield, stackLtsLink, stackLtsBadge :: Text
stackOrg :: Text
stackOrg = "http://stackage.org/"
stackLtsShield :: Text
stackLtsShield = Text
stackOrg Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "package/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
settingsRepo Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "/badge/lts"
stackLtsLink :: Text
stackLtsLink = Text
stackOrg Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "lts/package/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
settingsRepo
stackLtsBadge :: Text
stackLtsBadge = Text -> Text -> Text -> Text
makeBadge "Stackage Lts" Text
stackLtsShield Text
stackLtsLink
stackNightlyShield, stackNightlyLink, stackNightlyBadge :: Text
stackNightlyShield :: Text
stackNightlyShield = Text
stackOrg Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "package/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
settingsRepo Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "/badge/nightly"
stackNightlyLink :: Text
stackNightlyLink = Text
stackOrg Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "nightly/package/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
settingsRepo
stackNightlyBadge :: Text
stackNightlyBadge = Text -> Text -> Text -> Text
makeBadge "Stackage Nightly" Text
stackNightlyShield Text
stackNightlyLink
githubActionsShield, githubActionsLink, githubActionsBadge :: Text
githubActionsShield :: Text
githubActionsShield = "https://github.com/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ownerRepo Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "/workflows/CI/badge.svg"
githubActionsLink :: Text
githubActionsLink = "https://github.com/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ownerRepo Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "/actions"
githubActionsBadge :: Text
githubActionsBadge = Text -> Text -> Text -> Text
makeBadge "GitHub CI" Text
githubActionsShield Text
githubActionsLink
travisShield, travisLink, travisBadge :: Text
travisShield :: Text
travisShield = Text
shieldsIo Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "travis/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ownerRepo Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> ".svg?logo=travis"
travisLink :: Text
travisLink = "https://travis-ci.org/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ownerRepo
travisBadge :: Text
travisBadge = Text -> Text -> Text -> Text
makeBadge "Build status" Text
travisShield Text
travisLink
appVeyorCom, appVeyorShield, appVeyorLink, appVeyorBadge :: Text
appVeyorCom :: Text
appVeyorCom = "https://ci.appveyor.com/"
appVeyorShield :: Text
appVeyorShield = Text
appVeyorCom Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "api/projects/status/github/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ownerRepo Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "?branch=master&svg=true"
appVeyorLink :: Text
appVeyorLink = Text
appVeyorCom Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "project/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
ownerRepo
appVeyorBadge :: Text
appVeyorBadge = Text -> Text -> Text -> Text
makeBadge "Windows build status" Text
appVeyorShield Text
appVeyorLink
makeBadge :: Text -> Text -> Text -> Text
makeBadge :: Text -> Text -> Text -> Text
makeBadge title :: Text
title shield :: Text
shield link :: Text
link = "[![" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
title Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "](" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
shield Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> ")](" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
link Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> ")"
ownerRepo :: Text
ownerRepo :: Text
ownerRepo = Text
settingsOwner Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
settingsRepo
changelog :: Text
changelog :: Text
changelog = [Text] -> Text
forall t. IsText t "unlines" => [t] -> t
unlines ([Text] -> Text) -> [Text] -> Text
forall a b. (a -> b) -> a -> b
$
[ "# Changelog"
, ""
, "`" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
settingsRepo Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "` uses [PVP Versioning][1]."
] [Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++
[ Text
githubLine | Bool
settingsGitHub ] [Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++
[ ""
, "## 0.0.0.0"
, ""
, "* Initially created."
, ""
, "[1]: https://pvp.haskell.org"
] [Text] -> [Text] -> [Text]
forall a. [a] -> [a] -> [a]
++
[ Text
githubFootNote | Bool
settingsGitHub ]
where
githubLine, githubFootNote :: Text
githubLine :: Text
githubLine = "The changelog is available [on GitHub][2]."
githubFootNote :: Text
githubFootNote = "[2]: https://github.com/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
settingsOwner Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "/" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
settingsRepo Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> "/releases"