From 4ba2591e51d5752c6de393bca170bfacb9670842 Mon Sep 17 00:00:00 2001 From: Ben Fradet Date: Mon, 4 May 2020 11:58:28 +0200 Subject: [PATCH] Update scalafmt-core to 2.5.1 (#481) --- .scalafmt.conf | 2 +- build.sbt | 2 +- project/plugins.sbt | 24 +- src/main/scala/microsites/MicrositeKeys.scala | 40 +-- .../scala/microsites/github/GitHubOps.scala | 18 +- src/main/scala/microsites/ioops/ioops.scala | 13 +- .../scala/microsites/layouts/Layout.scala | 34 +- .../microsites/util/MicrositeHelper.scala | 8 +- .../scala/microsites/util/YamlFormats.scala | 42 +-- src/test/scala/microsites/LayoutTest.scala | 7 +- .../scala/microsites/util/Arbitraries.scala | 324 +++++++++--------- 11 files changed, 267 insertions(+), 247 deletions(-) diff --git a/.scalafmt.conf b/.scalafmt.conf index 316b8a7f..22c0e6c6 100644 --- a/.scalafmt.conf +++ b/.scalafmt.conf @@ -1,4 +1,4 @@ -version=2.4.2 +version = 2.5.1 style = defaultWithAlign maxColumn = 100 diff --git a/build.sbt b/build.sbt index 549bb8ba..2628ca50 100644 --- a/build.sbt +++ b/build.sbt @@ -5,7 +5,7 @@ inThisBuild( ) ) -addCommandAlias("ci-test", "scalafmtCheck; scalafmtSbtCheck; docs/tut; compile; test; scripted") +addCommandAlias("ci-test", "scalafmtCheckAll; scalafmtSbtCheck; docs/tut; compile; test; scripted") addCommandAlias("ci-docs", "project-docs/mdoc; headerCreateAll") addCommandAlias("ci-microsite", "docs/publishMicrosite") diff --git a/project/plugins.sbt b/project/plugins.sbt index d5cca319..de9028c0 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -2,18 +2,18 @@ import sbt.Resolver.sonatypeRepo resolvers ++= Seq(sonatypeRepo("snapshots"), sonatypeRepo("releases")) -addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") -addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.4") -addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.4.0") -addSbtPlugin("com.alejandrohdezma" %% "sbt-github" % "0.6.0") -addSbtPlugin("com.alejandrohdezma" % "sbt-github-header" % "0.6.0") -addSbtPlugin("com.alejandrohdezma" % "sbt-github-mdoc" % "0.6.0") -addSbtPlugin("com.alejandrohdezma" % "sbt-mdoc-toc" % "0.2") -addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.13") -addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.1.5") -addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") -addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.0") +addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.9.0") +addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.3") +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.4") +addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.4.0") +addSbtPlugin("com.alejandrohdezma" %% "sbt-github" % "0.6.0") +addSbtPlugin("com.alejandrohdezma" % "sbt-github-header" % "0.6.0") +addSbtPlugin("com.alejandrohdezma" % "sbt-github-mdoc" % "0.6.0") +addSbtPlugin("com.alejandrohdezma" % "sbt-mdoc-toc" % "0.2") +addSbtPlugin("org.tpolecat" % "tut-plugin" % "0.6.13") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "2.1.5") +addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") +addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.0") unmanagedSourceDirectories in Compile ++= Seq( baseDirectory.in(ThisBuild).value.getParentFile / "src" / "main" / "scala" diff --git a/src/main/scala/microsites/MicrositeKeys.scala b/src/main/scala/microsites/MicrositeKeys.scala index 6b3a1e3c..7a63eb08 100644 --- a/src/main/scala/microsites/MicrositeKeys.scala +++ b/src/main/scala/microsites/MicrositeKeys.scala @@ -265,7 +265,7 @@ trait MicrositeAutoImportSettings extends MicrositeKeys { val pluginName = "microsites.MicrositesPlugin" val sbtMicrositesProjects = pluginProjects(pluginName) sbtMicrositesProjects match { - case Some(projects) => { + case Some(projects) => List( "sbt", s"""clean; project ${projects(0)}; set micrositeBaseUrl := "$newBaseUrl"; makeMicrosite""" @@ -276,7 +276,6 @@ trait MicrositeAutoImportSettings extends MicrositeKeys { StandardCopyOption.REPLACE_EXISTING ) () - } case None => System.err.println(s"$pluginName not found in version $version") } } @@ -412,21 +411,18 @@ trait MicrositeAutoImportSettings extends MicrositeKeys { val re = tutNameFilter.value.pattern.toString _root_.tut.TutPlugin.tutOne(streams.value, r, in, out, cp, opts, pOpts, re).map(_._1) }, - makeTut := { - Def.sequential(tut, micrositeTutExtraMdFiles) - }.value, - makeMdoc := { - Def.sequential(mdoc.toTask(""), micrositeMakeExtraMdFiles) - }.value, + makeTut := + Def.sequential(tut, micrositeTutExtraMdFiles).value, + makeMdoc := + Def.sequential(mdoc.toTask(""), micrositeMakeExtraMdFiles).value, makeDocs := Def.taskDyn { micrositeCompilingDocsTool.value match { case WithTut => Def.sequential(makeTut) case WithMdoc => Def.sequential(makeMdoc) } }.value, - makeMicrosite := { - Def.sequential(microsite, makeDocs, makeSite) - }.value, + makeMicrosite := + Def.sequential(microsite, makeDocs, makeSite).value, makeVersionsJson := { "which git".! match { case 0 => () @@ -481,12 +477,12 @@ trait MicrositeAutoImportSettings extends MicrositeKeys { ) } }, - makeVersionedMicrosite := { - Def.sequential(microsite, makeVersionsJson, makeDocs, makeSite) - }.value, - makeMultiversionMicrosite := { - Def.sequential(createMicrositeVersions, clean, makeVersionedMicrosite, moveMicrositeVersions) - }.value, + makeVersionedMicrosite := + Def.sequential(microsite, makeVersionsJson, makeDocs, makeSite).value, + makeMultiversionMicrosite := + Def + .sequential(createMicrositeVersions, clean, makeVersionedMicrosite, moveMicrositeVersions) + .value, ghpagesPrivateMappings := { sbt.Path.allSubpaths((target in makeSite).value).toList }, @@ -552,12 +548,10 @@ trait MicrositeAutoImportSettings extends MicrositeKeys { ) } }.value, - publishMicrosite := { - Def.sequential(clean, makeMicrosite, pushMicrosite) - }.value, - publishMultiversionMicrosite := { - Def.sequential(clean, makeMultiversionMicrosite, pushMicrosite) - }.value + publishMicrosite := + Def.sequential(clean, makeMicrosite, pushMicrosite).value, + publishMultiversionMicrosite := + Def.sequential(clean, makeMultiversionMicrosite, pushMicrosite).value ) val pushMicrositeCommand: Command = Command(pushMicrositeCommandKey)(_ => OptNotSpace) { diff --git a/src/main/scala/microsites/github/GitHubOps.scala b/src/main/scala/microsites/github/GitHubOps.scala index c247b789..f6ad2ecb 100644 --- a/src/main/scala/microsites/github/GitHubOps.scala +++ b/src/main/scala/microsites/github/GitHubOps.scala @@ -128,12 +128,13 @@ class GitHubOps[F[_]: ConcurrentEffect: Timer]( filePath: String, array: Array[Byte] ): OptionT[F, TreeData] = - if (blobConfig.acceptedExtensions.exists(s => file.getName.toLowerCase.endsWith(s)) && - array.length < blobConfig.maximumSize) { + if ( + blobConfig.acceptedExtensions.exists(s => file.getName.toLowerCase.endsWith(s)) && + array.length < blobConfig.maximumSize + ) OptionT(createTreeDataBlob(filePath, array).map(Option(_))) - } else { + else OptionT(createTreeDataSha(filePath, array).map(Option(_))) - } def processFile(file: File): F[TreeData] = (for { @@ -167,10 +168,11 @@ class GitHubOps[F[_]: ConcurrentEffect: Timer]( ) } yield res - def parentCommitSha: F[String] = commitSha match { - case Some(sha) => Sync[F].pure(sha) - case None => fetchHeadCommit(branch).map(_.`object`.sha) - } + def parentCommitSha: F[String] = + commitSha match { + case Some(sha) => Sync[F].pure(sha) + case None => fetchHeadCommit(branch).map(_.`object`.sha) + } for { parentCommit <- parentCommitSha diff --git a/src/main/scala/microsites/ioops/ioops.scala b/src/main/scala/microsites/ioops/ioops.scala index 63fc1132..36fbae02 100644 --- a/src/main/scala/microsites/ioops/ioops.scala +++ b/src/main/scala/microsites/ioops/ioops.scala @@ -38,12 +38,13 @@ package object ioops { final class FilteredEitherOps[T](either: Either[Throwable, T]) { - def withFilter(f: T => Boolean): Either[Throwable, T] = either match { - case Right(r) if !f(r) => - new IllegalStateException("Filter condition has not been satisfied").asLeft[T] - case _ => - either - } + def withFilter(f: T => Boolean): Either[Throwable, T] = + either match { + case Right(r) if !f(r) => + new IllegalStateException("Filter condition has not been satisfied").asLeft[T] + case _ => + either + } } final class FileNameOps(filename: String) { diff --git a/src/main/scala/microsites/layouts/Layout.scala b/src/main/scala/microsites/layouts/Layout.scala index c2012ff7..4c1405e3 100644 --- a/src/main/scala/microsites/layouts/Layout.scala +++ b/src/main/scala/microsites/layouts/Layout.scala @@ -76,14 +76,14 @@ abstract class Layout(config: MicrositeSettings) { else None val twitter: Option[TypedTag[String]] = - if (config.identity.twitter.nonEmpty) { + if (config.identity.twitter.nonEmpty) Some(meta(name := "twitter:site", content := config.identity.twitter)) - } else None + else None val twitterCreator: Option[TypedTag[String]] = - if (config.identity.twitterCreator.nonEmpty) { + if (config.identity.twitterCreator.nonEmpty) Some(meta(name := "twitter:creator", content := config.identity.twitterCreator)) - } else None + else None def metas: List[TypedTag[String]] = { val pageTitle = s"${config.identity.name}{% if page.title %}: {{page.title}}{% endif %}" @@ -125,11 +125,10 @@ abstract class Layout(config: MicrositeSettings) { } def favicons: List[TypedTag[String]] = - (if (config.visualSettings.favicons.nonEmpty) { + (if (config.visualSettings.favicons.nonEmpty) config.visualSettings.favicons - } else { - micrositeHelper.faviconDescriptions - }).map { icon => + else + micrositeHelper.faviconDescriptions).map { icon => link( rel := "icon", `type` := "image/png", @@ -141,7 +140,10 @@ abstract class Layout(config: MicrositeSettings) { def styles: List[TypedTag[String]] = { val customCssList = - fr.fetchFilesRecursively(List(config.fileLocations.micrositeCssDirectory), validFile("css")) match { + fr.fetchFilesRecursively( + List(config.fileLocations.micrositeCssDirectory), + validFile("css") + ) match { case Right(cssList) => cssList.map(css => link(rel := "stylesheet", href := s"{{site.baseurl}}/css/${css.getName}") @@ -150,7 +152,10 @@ abstract class Layout(config: MicrositeSettings) { } val customScssList = - fr.fetchFilesRecursively(List(config.fileLocations.micrositeCssDirectory), validFile("scss")) match { + fr.fetchFilesRecursively( + List(config.fileLocations.micrositeCssDirectory), + validFile("scss") + ) match { case Right(scssList) => scssList.map { scss => val fileNameWithOutExt = scss.getName.replaceFirst("[.][^.]+$", "") @@ -205,7 +210,10 @@ abstract class Layout(config: MicrositeSettings) { def scripts: List[TypedTag[String]] = { val customJsList = - fr.fetchFilesRecursively(List(config.fileLocations.micrositeJsDirectory), validFile("js")) match { + fr.fetchFilesRecursively( + List(config.fileLocations.micrositeJsDirectory), + validFile("js") + ) match { case Right(jsList) => jsList.map(js => script(src := s"{{site.url}}{{site.baseurl}}/js/${js.getName}")) case _ => Nil @@ -273,7 +281,9 @@ abstract class Layout(config: MicrositeSettings) { """console.info('\x57\x65\x62\x73\x69\x74\x65\x20\x62\x75\x69\x6c\x74\x20\x77\x69\x74\x68\x3a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5f\x5f\x20\x20\x20\x20\x5f\x5f\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5f\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x5f\x20\x5f\x5f\x0a\x20\x20\x20\x5f\x5f\x5f\x5f\x5f\x2f\x20\x2f\x5f\x20\x20\x2f\x20\x2f\x5f\x20\x20\x20\x20\x20\x20\x5f\x5f\x5f\x5f\x20\x5f\x5f\x5f\x20\x20\x28\x5f\x29\x5f\x5f\x5f\x5f\x5f\x5f\x5f\x5f\x5f\x5f\x5f\x5f\x5f\x20\x20\x5f\x5f\x5f\x5f\x5f\x28\x5f\x29\x20\x2f\x5f\x5f\x5f\x5f\x20\x20\x5f\x5f\x5f\x5f\x5f\x0a\x20\x20\x2f\x20\x5f\x5f\x5f\x2f\x20\x5f\x5f\x20\x5c\x2f\x20\x5f\x5f\x2f\x5f\x5f\x5f\x5f\x5f\x2f\x20\x5f\x5f\x20\x60\x5f\x5f\x20\x5c\x2f\x20\x2f\x20\x5f\x5f\x5f\x2f\x20\x5f\x5f\x5f\x2f\x20\x5f\x5f\x20\x5c\x2f\x20\x5f\x5f\x5f\x2f\x20\x2f\x20\x5f\x5f\x2f\x20\x5f\x20\x5c\x2f\x20\x5f\x5f\x5f\x2f\x0a\x20\x28\x5f\x5f\x20\x20\x29\x20\x2f\x5f\x2f\x20\x2f\x20\x2f\x5f\x2f\x5f\x5f\x5f\x5f\x5f\x2f\x20\x2f\x20\x2f\x20\x2f\x20\x2f\x20\x2f\x20\x2f\x20\x2f\x5f\x5f\x2f\x20\x2f\x20\x20\x2f\x20\x2f\x5f\x2f\x20\x28\x5f\x5f\x20\x20\x29\x20\x2f\x20\x2f\x5f\x2f\x20\x20\x5f\x5f\x28\x5f\x5f\x20\x20\x29\x0a\x2f\x5f\x5f\x5f\x5f\x2f\x5f\x2e\x5f\x5f\x5f\x2f\x5c\x5f\x5f\x2f\x20\x20\x20\x20\x20\x2f\x5f\x2f\x20\x2f\x5f\x2f\x20\x2f\x5f\x2f\x5f\x2f\x5c\x5f\x5f\x5f\x2f\x5f\x2f\x20\x20\x20\x5c\x5f\x5f\x5f\x5f\x2f\x5f\x5f\x5f\x5f\x2f\x5f\x2f\x5c\x5f\x5f\x2f\x5c\x5f\x5f\x5f\x2f\x5f\x5f\x5f\x5f\x2f\x0a\x0a\x68\x74\x74\x70\x73\x3a\x2f\x2f\x34\x37\x64\x65\x67\x2e\x67\x69\x74\x68\x75\x62\x2e\x69\x6f\x2f\x73\x62\x74\x2d\x6d\x69\x63\x72\x6f\x73\x69\x74\x65\x73')""" ) - auxScripts ++ languageScripts ++ List(highlightingScript) ++ customJsList ++ customCDNList ++ (message :: gitSidecar) + auxScripts ++ languageScripts ++ List( + highlightingScript + ) ++ customJsList ++ customCDNList ++ (message :: gitSidecar) } def versionScript: TypedTag[String] = diff --git a/src/main/scala/microsites/util/MicrositeHelper.scala b/src/main/scala/microsites/util/MicrositeHelper.scala index 511a66fd..a7a49c04 100644 --- a/src/main/scala/microsites/util/MicrositeHelper.scala +++ b/src/main/scala/microsites/util/MicrositeHelper.scala @@ -126,8 +126,8 @@ class MicrositeHelper(config: MicrositeSettings) { s"""--- |layout: ${targetFileConfig.layout} |${targetFileConfig.metaProperties map { - case (key, value) => "%s: %s" format (key, value) - } mkString ("", "\n", "")} + case (key, value) => "%s: %s" format (key, value) + } mkString ("", "\n", "")} |--- |${Source.fromFile(sourceFile.getAbsolutePath).mkString} |""".stripMargin @@ -151,9 +151,9 @@ class MicrositeHelper(config: MicrositeSettings) { yaml.yamlInline.parseYaml.asYamlObject.fields else Map.empty[YamlValue, YamlValue] val fileYaml = yaml.yamlPath.fold(Map.empty[YamlValue, YamlValue])(f => - if (f.exists()) { + if (f.exists()) Source.fromFile(f.getAbsolutePath).mkString.parseYaml.asYamlObject.fields - } else Map.empty[YamlValue, YamlValue] + else Map.empty[YamlValue, YamlValue] ) writeContentToFile( diff --git a/src/main/scala/microsites/util/YamlFormats.scala b/src/main/scala/microsites/util/YamlFormats.scala index 4c3e7cf6..40e88fae 100644 --- a/src/main/scala/microsites/util/YamlFormats.scala +++ b/src/main/scala/microsites/util/YamlFormats.scala @@ -21,26 +21,28 @@ import net.jcazevedo.moultingyaml._ object YamlFormats extends DefaultYamlProtocol { implicit object AnyYamlFormat extends YamlFormat[Any] { - def write(x: Any): YamlValue = x match { - case n: Int => YamlNumber(n) - case n: Long => YamlNumber(n) - case n: Double => YamlNumber(n) - case s: String => YamlString(s) - case b: Boolean => YamlBoolean(b) - case x: Seq[_] => seqFormat[Any].write(x) - case m: Map[String, _] => mapFormat[String, Any].write(m) - case t => - serializationError("Serialization Error - Non expected type " + t.getClass.getName) - } + def write(x: Any): YamlValue = + x match { + case n: Int => YamlNumber(n) + case n: Long => YamlNumber(n) + case n: Double => YamlNumber(n) + case s: String => YamlString(s) + case b: Boolean => YamlBoolean(b) + case x: Seq[_] => seqFormat[Any].write(x) + case m: Map[String, _] => mapFormat[String, Any].write(m) + case t => + serializationError("Serialization Error - Non expected type " + t.getClass.getName) + } - def read(value: YamlValue): Any = value match { - case YamlNumber(n) => n.intValue() - case YamlString(s) => s - case YamlBoolean(b) => b - case _: YamlArray => listFormat[Any].read(value) - case _: YamlObject => mapFormat[String, Any].read(value) - case x => - deserializationError("Deserialization Error - it failed the deserialization of " + x) - } + def read(value: YamlValue): Any = + value match { + case YamlNumber(n) => n.intValue() + case YamlString(s) => s + case YamlBoolean(b) => b + case _: YamlArray => listFormat[Any].read(value) + case _: YamlObject => mapFormat[String, Any].read(value) + case x => + deserializationError("Deserialization Error - it failed the deserialization of " + x) + } } } diff --git a/src/test/scala/microsites/LayoutTest.scala b/src/test/scala/microsites/LayoutTest.scala index 90b2d204..48812817 100644 --- a/src/test/scala/microsites/LayoutTest.scala +++ b/src/test/scala/microsites/LayoutTest.scala @@ -28,9 +28,10 @@ import org.scalatest.matchers.should.Matchers class LayoutTest extends AnyFunSuite with Checkers with Matchers with Arbitraries { - def buildParentLayout(implicit settings: MicrositeSettings) = new Layout(settings) { - override def render: TypedTag[String] = html - } + def buildParentLayout(implicit settings: MicrositeSettings) = + new Layout(settings) { + override def render: TypedTag[String] = html + } test("meta TypeTag list shouldn't be empty") { diff --git a/src/test/scala/microsites/util/Arbitraries.scala b/src/test/scala/microsites/util/Arbitraries.scala index f4daf8b9..ab70e970 100644 --- a/src/test/scala/microsites/util/Arbitraries.scala +++ b/src/test/scala/microsites/util/Arbitraries.scala @@ -25,171 +25,181 @@ import org.scalacheck.Gen._ trait Arbitraries { - implicit def fileArbitrary: Arbitrary[File] = Arbitrary { - uuid map (randomFileName => new File(randomFileName.toString)) - } + implicit def fileArbitrary: Arbitrary[File] = + Arbitrary { + uuid map (randomFileName => new File(randomFileName.toString)) + } - implicit def paletteMapArbitrary: Arbitrary[Map[String, String]] = Arbitrary { - for { - stringList <- listOfN[String](6, Arbitrary.arbitrary[String]) - map <- (stringList map (s => s -> s"value of $s")).toMap - } yield map - } + implicit def paletteMapArbitrary: Arbitrary[Map[String, String]] = + Arbitrary { + for { + stringList <- listOfN[String](6, Arbitrary.arbitrary[String]) + map <- (stringList map (s => s -> s"value of $s")).toMap + } yield map + } - implicit def configYamlArbitrary: Arbitrary[ConfigYml] = Arbitrary { - for { - yamlCustomProperties ← paletteMapArbitrary.arbitrary - yamlPath ← Arbitrary.arbitrary[Option[File]] - yamlInline ← Arbitrary.arbitrary[String] - } yield ConfigYml(yamlCustomProperties, yamlPath, yamlInline) - } + implicit def configYamlArbitrary: Arbitrary[ConfigYml] = + Arbitrary { + for { + yamlCustomProperties ← paletteMapArbitrary.arbitrary + yamlPath ← Arbitrary.arbitrary[Option[File]] + yamlInline ← Arbitrary.arbitrary[String] + } yield ConfigYml(yamlCustomProperties, yamlPath, yamlInline) + } - implicit def extraMdConfigArbitrary: Arbitrary[ExtraMdFileConfig] = Arbitrary { - for { - file ← Arbitrary.arbitrary[String] - target ← Arbitrary.arbitrary[String] - mapArbValue ← paletteMapArbitrary.arbitrary - } yield ExtraMdFileConfig(file, target, mapArbValue) - } + implicit def extraMdConfigArbitrary: Arbitrary[ExtraMdFileConfig] = + Arbitrary { + for { + file ← Arbitrary.arbitrary[String] + target ← Arbitrary.arbitrary[String] + mapArbValue ← paletteMapArbitrary.arbitrary + } yield ExtraMdFileConfig(file, target, mapArbValue) + } - implicit def cdnDirectivesArbitrary: Arbitrary[CdnDirectives] = Arbitrary { - for { - jsList <- listOf[String](Arbitrary.arbitrary[String]) - cssList <- listOf[String](Arbitrary.arbitrary[String]) - } yield CdnDirectives(jsList, cssList) - } + implicit def cdnDirectivesArbitrary: Arbitrary[CdnDirectives] = + Arbitrary { + for { + jsList <- listOf[String](Arbitrary.arbitrary[String]) + cssList <- listOf[String](Arbitrary.arbitrary[String]) + } yield CdnDirectives(jsList, cssList) + } - implicit def markdownMapArbitrary: Arbitrary[Map[File, ExtraMdFileConfig]] = Arbitrary { - for { - n ← choose(1, 100) - fileList <- listOfN[File](n, Arbitrary.arbitrary[File]) - config ← extraMdConfigArbitrary.arbitrary - map <- (fileList map (f => f -> config)).toMap - } yield map - } + implicit def markdownMapArbitrary: Arbitrary[Map[File, ExtraMdFileConfig]] = + Arbitrary { + for { + n ← choose(1, 100) + fileList <- listOfN[File](n, Arbitrary.arbitrary[File]) + config ← extraMdConfigArbitrary.arbitrary + map <- (fileList map (f => f -> config)).toMap + } yield map + } - implicit def hostingServiceArbitrary: Arbitrary[GitHostingService] = Arbitrary { - oneOf( - oneOf(GitHub, GitLab, Bitbucket), - Arbitrary.arbitrary[String].map(Other(_)) - ) - } + implicit def hostingServiceArbitrary: Arbitrary[GitHostingService] = + Arbitrary { + oneOf( + oneOf(GitHub, GitLab, Bitbucket), + Arbitrary.arbitrary[String].map(Other(_)) + ) + } - implicit def micrositeFaviconArbitrary: Arbitrary[MicrositeFavicon] = Arbitrary { - for { - filename <- Arbitrary.arbitrary[String] - size <- Arbitrary.arbitrary[String] - } yield MicrositeFavicon(filename, size) - } + implicit def micrositeFaviconArbitrary: Arbitrary[MicrositeFavicon] = + Arbitrary { + for { + filename <- Arbitrary.arbitrary[String] + size <- Arbitrary.arbitrary[String] + } yield MicrositeFavicon(filename, size) + } - implicit def micrositeEditButtonArbitrary: Arbitrary[Option[MicrositeEditButton]] = Arbitrary { - for { - text <- Arbitrary.arbitrary[String] - basePath <- Arbitrary.arbitrary[String] - } yield Some(MicrositeEditButton(text, basePath)) - } + implicit def micrositeEditButtonArbitrary: Arbitrary[Option[MicrositeEditButton]] = + Arbitrary { + for { + text <- Arbitrary.arbitrary[String] + basePath <- Arbitrary.arbitrary[String] + } yield Some(MicrositeEditButton(text, basePath)) + } - implicit def settingsArbitrary: Arbitrary[MicrositeSettings] = Arbitrary { - for { - name ← Arbitrary.arbitrary[String] - description ← Arbitrary.arbitrary[String] - author ← Arbitrary.arbitrary[String] - homepage ← Arbitrary.arbitrary[String] - organizationHomepage ← Arbitrary.arbitrary[String] - twitter ← Arbitrary.arbitrary[String] - twitterCreator ← Arbitrary.arbitrary[String] - analytics ← Arbitrary.arbitrary[String] - highlightTheme ← Arbitrary.arbitrary[String] - highlightLanguages ← Arbitrary.arbitrary[Seq[String]] - theme ← Arbitrary.arbitrary[String] - micrositeConfigYaml ← configYamlArbitrary.arbitrary - micrositeImgDirectory ← Arbitrary.arbitrary[File] - micrositeCssDirectory ← Arbitrary.arbitrary[File] - micrositeSassDirectory ← Arbitrary.arbitrary[File] - micrositeJsDirectory ← Arbitrary.arbitrary[File] - micrositeCDNDirectives <- cdnDirectivesArbitrary.arbitrary - micrositeExternalLayoutsDirectory ← Arbitrary.arbitrary[File] - micrositeExternalIncludesDirectory ← Arbitrary.arbitrary[File] - micrositeDataDirectory ← Arbitrary.arbitrary[File] - micrositeStaticDirectory ← Arbitrary.arbitrary[File] - micrositeExtraMdFiles ← markdownMapArbitrary.arbitrary - micrositeExtraMdFilesOutput ← Arbitrary.arbitrary[File] - micrositePluginsDirectory ← Arbitrary.arbitrary[File] - micrositeUrl ← Arbitrary.arbitrary[String] - micrositeBaseUrl ← Arbitrary.arbitrary[String] - micrositeDocumentationUrl ← Arbitrary.arbitrary[String] - micrositeDocumentationLabelDescription ← Arbitrary.arbitrary[String] - palette ← paletteMapArbitrary.arbitrary - favicon ← listOf[MicrositeFavicon](micrositeFaviconArbitrary.arbitrary) - githubOwner ← Arbitrary.arbitrary[String] - githubRepo ← Arbitrary.arbitrary[String] - gitHostingService ← Arbitrary.arbitrary[GitHostingService] - gitHostingUrl ← Arbitrary.arbitrary[String] - githubLinks ← Arbitrary.arbitrary[Boolean] - gitSidecarChat ← Arbitrary.arbitrary[Boolean] - gitSidecarChatUrl ← Arbitrary.arbitrary[String] - shareOnSocial ← Arbitrary.arbitrary[Boolean] - micrositeFooterText ← Arbitrary.arbitrary[Option[String]] - micrositeEditButton ← micrositeEditButtonArbitrary.arbitrary - micrositeVersionList ← Arbitrary.arbitrary[Seq[String]] - } yield MicrositeSettings( - MicrositeIdentitySettings( - name, - description, - author, - homepage, - organizationHomepage, - twitter, - twitterCreator, - analytics - ), - MicrositeVisualSettings( - highlightTheme, - highlightLanguages, - palette, - favicon, - shareOnSocial, - theme - ), - MicrositeTemplateTexts( - micrositeFooterText - ), - micrositeConfigYaml, - MicrositeFileLocations( - micrositeImgDirectory, - micrositeCssDirectory, - micrositeSassDirectory, - micrositeJsDirectory, - micrositeCDNDirectives, - micrositeExternalLayoutsDirectory, - micrositeExternalIncludesDirectory, - micrositeDataDirectory, - micrositeStaticDirectory, - micrositeExtraMdFiles, - micrositeExtraMdFilesOutput, - micrositePluginsDirectory - ), - MicrositeUrlSettings( - micrositeUrl, - micrositeBaseUrl, - micrositeDocumentationUrl, - micrositeDocumentationLabelDescription - ), - MicrositeGitSettings( - githubOwner, - githubRepo, - githubLinks, - gitHostingService, - gitHostingUrl, - gitSidecarChat, - gitSidecarChatUrl - ), - MicrositeEditButtonSettings( - micrositeEditButton - ), - MicrositeMultiversionSettings( - micrositeVersionList + implicit def settingsArbitrary: Arbitrary[MicrositeSettings] = + Arbitrary { + for { + name ← Arbitrary.arbitrary[String] + description ← Arbitrary.arbitrary[String] + author ← Arbitrary.arbitrary[String] + homepage ← Arbitrary.arbitrary[String] + organizationHomepage ← Arbitrary.arbitrary[String] + twitter ← Arbitrary.arbitrary[String] + twitterCreator ← Arbitrary.arbitrary[String] + analytics ← Arbitrary.arbitrary[String] + highlightTheme ← Arbitrary.arbitrary[String] + highlightLanguages ← Arbitrary.arbitrary[Seq[String]] + theme ← Arbitrary.arbitrary[String] + micrositeConfigYaml ← configYamlArbitrary.arbitrary + micrositeImgDirectory ← Arbitrary.arbitrary[File] + micrositeCssDirectory ← Arbitrary.arbitrary[File] + micrositeSassDirectory ← Arbitrary.arbitrary[File] + micrositeJsDirectory ← Arbitrary.arbitrary[File] + micrositeCDNDirectives <- cdnDirectivesArbitrary.arbitrary + micrositeExternalLayoutsDirectory ← Arbitrary.arbitrary[File] + micrositeExternalIncludesDirectory ← Arbitrary.arbitrary[File] + micrositeDataDirectory ← Arbitrary.arbitrary[File] + micrositeStaticDirectory ← Arbitrary.arbitrary[File] + micrositeExtraMdFiles ← markdownMapArbitrary.arbitrary + micrositeExtraMdFilesOutput ← Arbitrary.arbitrary[File] + micrositePluginsDirectory ← Arbitrary.arbitrary[File] + micrositeUrl ← Arbitrary.arbitrary[String] + micrositeBaseUrl ← Arbitrary.arbitrary[String] + micrositeDocumentationUrl ← Arbitrary.arbitrary[String] + micrositeDocumentationLabelDescription ← Arbitrary.arbitrary[String] + palette ← paletteMapArbitrary.arbitrary + favicon ← listOf[MicrositeFavicon](micrositeFaviconArbitrary.arbitrary) + githubOwner ← Arbitrary.arbitrary[String] + githubRepo ← Arbitrary.arbitrary[String] + gitHostingService ← Arbitrary.arbitrary[GitHostingService] + gitHostingUrl ← Arbitrary.arbitrary[String] + githubLinks ← Arbitrary.arbitrary[Boolean] + gitSidecarChat ← Arbitrary.arbitrary[Boolean] + gitSidecarChatUrl ← Arbitrary.arbitrary[String] + shareOnSocial ← Arbitrary.arbitrary[Boolean] + micrositeFooterText ← Arbitrary.arbitrary[Option[String]] + micrositeEditButton ← micrositeEditButtonArbitrary.arbitrary + micrositeVersionList ← Arbitrary.arbitrary[Seq[String]] + } yield MicrositeSettings( + MicrositeIdentitySettings( + name, + description, + author, + homepage, + organizationHomepage, + twitter, + twitterCreator, + analytics + ), + MicrositeVisualSettings( + highlightTheme, + highlightLanguages, + palette, + favicon, + shareOnSocial, + theme + ), + MicrositeTemplateTexts( + micrositeFooterText + ), + micrositeConfigYaml, + MicrositeFileLocations( + micrositeImgDirectory, + micrositeCssDirectory, + micrositeSassDirectory, + micrositeJsDirectory, + micrositeCDNDirectives, + micrositeExternalLayoutsDirectory, + micrositeExternalIncludesDirectory, + micrositeDataDirectory, + micrositeStaticDirectory, + micrositeExtraMdFiles, + micrositeExtraMdFilesOutput, + micrositePluginsDirectory + ), + MicrositeUrlSettings( + micrositeUrl, + micrositeBaseUrl, + micrositeDocumentationUrl, + micrositeDocumentationLabelDescription + ), + MicrositeGitSettings( + githubOwner, + githubRepo, + githubLinks, + gitHostingService, + gitHostingUrl, + gitSidecarChat, + gitSidecarChatUrl + ), + MicrositeEditButtonSettings( + micrositeEditButton + ), + MicrositeMultiversionSettings( + micrositeVersionList + ) ) - ) - } + } }