diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml
new file mode 100644
index 0000000..c7698ac
--- /dev/null
+++ b/.github/workflows/format.yml
@@ -0,0 +1,23 @@
+name: Scalafmt
+
+permissions: {}
+
+on:
+ pull_request:
+ branches: ['**']
+
+jobs:
+ build:
+ name: Code is formatted
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout current branch (full)
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ persist-credentials: false
+
+ - name: Check project is formatted
+ uses: jrouly/scalafmt-native-action@v3
+ with:
+ arguments: '--list --mode diff-ref=origin/main'
diff --git a/.scalafmt.conf b/.scalafmt.conf
new file mode 100644
index 0000000..75e1b1f
--- /dev/null
+++ b/.scalafmt.conf
@@ -0,0 +1,26 @@
+version = 3.7.17
+runner.dialect = scala212
+maxColumn = 120
+project.git = true
+
+# http://docs.scala-lang.org/style/scaladoc.html recommends the JavaDoc style.
+# scala/scala is written that way too https://github.com/scala/scala/blob/v2.12.2/src/library/scala/Predef.scala
+docstrings.style = Asterisk
+
+# This also seems more idiomatic to include whitespace in import x.{ yyy }
+spaces.inImportCurlyBraces = true
+
+align.tokens."+" = [
+ {
+ code = "%"
+ owners = [
+ { regex = "Term.ApplyInfix" }
+ ]
+ },
+ {
+ code = "%%"
+ owners = [
+ { regex = "Term.ApplyInfix" }
+ ]
+ }
+]
diff --git a/build.sbt b/build.sbt
index b30ce8d..f050d89 100644
--- a/build.sbt
+++ b/build.sbt
@@ -37,47 +37,47 @@ lazy val root = project("paradox-material-theme-parent", file("."))
"project.name" -> "Paradox Material Theme",
"github.base_url" -> "https://github.com/sbt/sbt-paradox-material-theme"
),
- //#color
+ // #color
Compile / paradoxMaterialTheme ~= {
_.withColor("teal", "indigo")
}
- //#color
+ // #color
,
- //#repository
+ // #repository
Compile / paradoxMaterialTheme ~= {
_.withRepository(uri("https://github.com/sbt/sbt-paradox-material-theme"))
}
- //#repository
+ // #repository
,
- //#social
+ // #social
Compile / paradoxMaterialTheme ~= {
_.withSocial(
uri("https://github.com/jonas"),
uri("https://twitter.com/priorarts")
)
}
- //#social
+ // #social
,
- //#language
+ // #language
Compile / paradoxMaterialTheme ~= {
_.withLanguage(java.util.Locale.ENGLISH)
}
- //#language
+ // #language
,
- //#analytics
+ // #analytics
Compile / paradoxMaterialTheme ~= {
_.withGoogleAnalytics("UA-107934279-1") // Remember to change this!
}
- //#analytics
+ // #analytics
,
- //#copyright
+ // #copyright
Compile / paradoxMaterialTheme ~= {
_.withCopyright("""
Based on MkDocs Material
by Martin Donath
""")
}
- //#copyright
+ // #copyright
)
.aggregate(theme, plugin)
@@ -90,7 +90,7 @@ lazy val plugin = project("sbt-paradox-material-theme", file("plugin"))
scriptedBufferLog := false,
publishLocal := publishLocal.dependsOn(theme / publishLocal).value,
addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.4.4"),
- libraryDependencies += "org.jsoup" % "jsoup" % "1.10.3",
+ libraryDependencies += "org.jsoup" % "jsoup" % "1.10.3",
libraryDependencies += "io.circe" %% "circe-core" % "0.9.3",
Compile / resourceGenerators += Def.task {
val file = (Compile / resourceManaged).value / "paradox-material-theme.properties"
@@ -105,96 +105,99 @@ lazy val theme = project("paradox-material-theme", file("theme"))
description := "Material Design theme for Paradox",
Assets / WebKeys.webJars := {
val out = (Assets / WebKeys.webJars).value
- (Assets / WebKeys.webJarsDirectory).value.**(
- "*.min.js" | "*.min.css" | "lang-*.js" | "prettify.css" | "prettify.js"
- ).get.filter(_.isFile)
+ (Assets / WebKeys.webJarsDirectory).value
+ .**(
+ "*.min.js" | "*.min.css" | "lang-*.js" | "prettify.css" | "prettify.js"
+ )
+ .get
+ .filter(_.isFile)
},
previewSite := {},
libraryDependencies += "org.webjars" % "prettify" % "4-Mar-2013-1" % Provided,
libraryDependencies +=
Seq("animation", "base", "ripple", "rtl", "theme", "typography")
- .foldLeft("org.webjars.npm" % "material__tabs" % "0.3.1" % Provided) {
- (lib, dep) => lib.exclude("org.webjars.npm", s"material__$dep")
+ .foldLeft("org.webjars.npm" % "material__tabs" % "0.3.1" % Provided) { (lib, dep) =>
+ lib.exclude("org.webjars.npm", s"material__$dep")
}
)
lazy val optionExamples = Def.settings(
- //#builder-api
+ // #builder-api
Compile / paradoxMaterialTheme := {
ParadoxMaterialTheme()
.withColor("red", "orange")
.withLogoIcon("cloud")
.withCopyright("Copyleft © Jonas Fonseca")
}
- //#builder-api
+ // #builder-api
,
- //#builder-api-v2
+ // #builder-api-v2
Compile / paradoxMaterialTheme ~= {
_.withColor("red", "orange")
- .withLogoIcon("cloud")
- .withCopyright("Copyleft © Jonas Fonseca")
+ .withLogoIcon("cloud")
+ .withCopyright("Copyleft © Jonas Fonseca")
}
- //#builder-api-v2
+ // #builder-api-v2
,
- //#font
+ // #font
Compile / paradoxMaterialTheme ~= {
_.withFont("Ubuntu", "Ubuntu Mono")
}
- //#font
+ // #font
,
- //#font-disable
+ // #font-disable
Compile / paradoxMaterialTheme ~= {
_.withoutFont()
}
- //#font-disable
+ // #font-disable
,
- //#favicon
+ // #favicon
Compile / paradoxMaterialTheme ~= {
_.withFavicon("assets/images/favicon.png")
}
- //#favicon
+ // #favicon
,
- //#logo
+ // #logo
Compile / paradoxMaterialTheme ~= {
_.withLogo("assets/images/logo.png")
}
- //#logo
+ // #logo
,
- //#logo-icon
+ // #logo-icon
Compile / paradoxMaterialTheme ~= {
_.withLogoIcon("cloud")
}
- //#logo-icon
+ // #logo-icon
,
- //#logo-uri
+ // #logo-uri
Compile / paradoxMaterialTheme ~= {
_.withLogoUri(uri("https://example.org/logo.png"))
}
- //#logo-uri
+ // #logo-uri
,
- //#custom-stylesheet
+ // #custom-stylesheet
Compile / paradoxMaterialTheme ~= {
_.withCustomStylesheet("assets/custom.css")
}
- //#custom-stylesheet
+ // #custom-stylesheet
,
- //#custom-javascript
+ // #custom-javascript
Compile / paradoxMaterialTheme ~= {
_.withCustomJavaScript("assets/custom.js")
}
- //#custom-javascript
+ // #custom-javascript
,
- //#disable-search
+ // #disable-search
Compile / paradoxMaterialTheme ~= {
_.withoutSearch()
}
- //#disable-search
+ // #disable-search
,
- //#search-tokenizer
+ // #search-tokenizer
Compile / paradoxMaterialTheme ~= {
_.withSearch(tokenizer = "[\\s\\-\\.]+")
}
- //#search-tokenizer
+ // #search-tokenizer
)
lazy val scala212 = "2.12.18"
@@ -204,5 +207,5 @@ def project(id: String, base: File): Project = {
.settings(
crossScalaVersions := Seq(scala212),
scalaVersion := scala212
- )
+ )
}
diff --git a/plugin/src/main/scala/io.github.jonas.paradox.material.theme/ParadoxMaterialTheme.scala b/plugin/src/main/scala/io.github.jonas.paradox.material.theme/ParadoxMaterialTheme.scala
index d7aa0af..000d9b1 100644
--- a/plugin/src/main/scala/io.github.jonas.paradox.material.theme/ParadoxMaterialTheme.scala
+++ b/plugin/src/main/scala/io.github.jonas.paradox.material.theme/ParadoxMaterialTheme.scala
@@ -1,6 +1,6 @@
package io.github.jonas.paradox.material.theme
-import java.net.{URI, URLEncoder}
+import java.net.{ URI, URLEncoder }
import java.util.Locale
import org.stringtemplate.v4.StringRenderer
@@ -104,9 +104,10 @@ case class ParadoxMaterialTheme(properties: Map[String, String]) {
object ParadoxMaterialTheme {
val Tlds = List("com", "org")
def findSite(sites: String*): URI => Option[String] =
- uri => sites.find { service =>
- Tlds.exists(tld => uri.getHost.endsWith(service + "." + tld))
- }
+ uri =>
+ sites.find { service =>
+ Tlds.exists(tld => uri.getHost.endsWith(service + "." + tld))
+ }
val SocialSite = findSite("bitbucket", "facebook", "github", "gitlab", "linkedin", "twitter")
val RepositoryType = findSite("bitbucket", "github", "gitlab")
@@ -121,42 +122,42 @@ object ParadoxMaterialTheme {
object Palette {
val Primary = Map(
- "red" -> "#ef5350",
- "pink" -> "#e91e63",
- "purple" -> "#ab47bc",
+ "red" -> "#ef5350",
+ "pink" -> "#e91e63",
+ "purple" -> "#ab47bc",
"deep-purple" -> "#7e57c2",
- "indigo" -> "#3f51b5",
- "blue" -> "#2196f3",
- "light-blue" -> "#03a9f4",
- "cyan" -> "#00bcd4",
- "teal" -> "#009688",
- "green" -> "#4caf50",
+ "indigo" -> "#3f51b5",
+ "blue" -> "#2196f3",
+ "light-blue" -> "#03a9f4",
+ "cyan" -> "#00bcd4",
+ "teal" -> "#009688",
+ "green" -> "#4caf50",
"light-green" -> "#7cb342",
- "lime" -> "#c0ca33",
- "yellow" -> "#f9a825",
- "amber" -> "#ffa000",
- "orange" -> "#fb8c00",
+ "lime" -> "#c0ca33",
+ "yellow" -> "#f9a825",
+ "amber" -> "#ffa000",
+ "orange" -> "#fb8c00",
"deep-orange" -> "#ff7043",
- "brown" -> "#795548",
- "grey" -> "#757575",
- "blue-grey" -> "#546e7a"
+ "brown" -> "#795548",
+ "grey" -> "#757575",
+ "blue-grey" -> "#546e7a"
)
val Accent = Map(
- "red" -> "#ff1744",
- "pink" -> "#f50057",
- "purple" -> "#e040fb",
+ "red" -> "#ff1744",
+ "pink" -> "#f50057",
+ "purple" -> "#e040fb",
"deep-purple" -> "#7c4dff",
- "indigo" -> "#536dfe",
- "blue" -> "#448aff",
- "light-blue" -> "#0091ea",
- "cyan" -> "#00b8d4",
- "teal" -> "#00bfa5",
- "green" -> "#00c853",
+ "indigo" -> "#536dfe",
+ "blue" -> "#448aff",
+ "light-blue" -> "#0091ea",
+ "cyan" -> "#00b8d4",
+ "teal" -> "#00bfa5",
+ "green" -> "#00c853",
"light-green" -> "#64dd17",
- "lime" -> "#aeea00",
- "yellow" -> "#ffd600",
- "amber" -> "#ffab00",
- "orange" -> "#ff9100",
+ "lime" -> "#aeea00",
+ "yellow" -> "#ffd600",
+ "amber" -> "#ffab00",
+ "orange" -> "#ff9100",
"deep-orange" -> "#ff6e40"
)
}
diff --git a/plugin/src/main/scala/io.github.jonas.paradox.material.theme/ParadoxMaterialThemePlugin.scala b/plugin/src/main/scala/io.github.jonas.paradox.material.theme/ParadoxMaterialThemePlugin.scala
index 2bbe5a5..bdf8afb 100644
--- a/plugin/src/main/scala/io.github.jonas.paradox.material.theme/ParadoxMaterialThemePlugin.scala
+++ b/plugin/src/main/scala/io.github.jonas.paradox.material.theme/ParadoxMaterialThemePlugin.scala
@@ -30,17 +30,19 @@ object ParadoxMaterialThemePlugin extends AutoPlugin {
)
def paradoxMaterialThemeSettings(config: Configuration): Seq[Setting[_]] =
- inConfig(config)(Def.settings(
- paradoxMaterialTheme := ParadoxMaterialTheme(),
- paradoxProperties += ("material.theme.version" -> (paradoxMaterialTheme / version).value),
- paradoxProperties ++= paradoxMaterialTheme.value.paradoxProperties,
- paradoxMaterialTheme / mappings := Def.taskDyn {
- if (paradoxProperties.value.contains("material.search"))
- Def.task(Seq(SearchIndex.mapping(config).value))
- else
- Def.task(Seq.empty[(File, String)])
- }.value,
- paradox / mappings ++= (paradoxMaterialTheme / mappings).value
- ))
+ inConfig(config)(
+ Def.settings(
+ paradoxMaterialTheme := ParadoxMaterialTheme(),
+ paradoxProperties += ("material.theme.version" -> (paradoxMaterialTheme / version).value),
+ paradoxProperties ++= paradoxMaterialTheme.value.paradoxProperties,
+ paradoxMaterialTheme / mappings := Def.taskDyn {
+ if (paradoxProperties.value.contains("material.search"))
+ Def.task(Seq(SearchIndex.mapping(config).value))
+ else
+ Def.task(Seq.empty[(File, String)])
+ }.value,
+ paradox / mappings ++= (paradoxMaterialTheme / mappings).value
+ )
+ )
}
diff --git a/plugin/src/main/scala/io.github.jonas.paradox.material.theme/SearchIndex.scala b/plugin/src/main/scala/io.github.jonas.paradox.material.theme/SearchIndex.scala
index 7f87f26..de01447 100644
--- a/plugin/src/main/scala/io.github.jonas.paradox.material.theme/SearchIndex.scala
+++ b/plugin/src/main/scala/io.github.jonas.paradox.material.theme/SearchIndex.scala
@@ -16,8 +16,8 @@ object SearchIndex {
case class Section(location: String, title: String, text: String)
object Section {
- implicit val encoder: ObjectEncoder[Section] = Encoder.forProduct3("location", "text", "title")(
- page => ("/" + page.location, page.text, page.title))
+ implicit val encoder: ObjectEncoder[Section] =
+ Encoder.forProduct3("location", "text", "title")(page => ("/" + page.location, page.text, page.title))
}
val Headers = Set("h1", "h2", "h3", "h4", "h5", "h6")
diff --git a/plugin/src/sbt-test/paradox/can-use-theme/build.sbt b/plugin/src/sbt-test/paradox/can-use-theme/build.sbt
index 29fedbd..da44665 100644
--- a/plugin/src/sbt-test/paradox/can-use-theme/build.sbt
+++ b/plugin/src/sbt-test/paradox/can-use-theme/build.sbt
@@ -10,8 +10,8 @@ paradoxProperties in Compile ++= Map(
paradoxMaterialTheme in Compile ~= {
_.withCopyright("test-copyright")
- .withLogo("test-logo")
- .withFavicon("test-favicon")
+ .withLogo("test-logo")
+ .withFavicon("test-favicon")
}
def fileContains(file: File, texts: String*) = {
@@ -29,12 +29,17 @@ TaskKey[Unit]("checkContent") := {
fileContains(
dest / "index.html",
- "Paradox Site", "Nicely themed", "mkdocs-material", "test-copyright",
- "test-logo", "test-favicon"
+ "Paradox Site",
+ "Nicely themed",
+ "mkdocs-material",
+ "test-copyright",
+ "test-logo",
+ "test-favicon"
)
fileContains(
dest / "search" / "search_index.json",
- "Paradox Site", "Nicely themed"
+ "Paradox Site",
+ "Nicely themed"
)
}
diff --git a/plugin/src/sbt-test/sbt-site/can-use-theme/build.sbt b/plugin/src/sbt-test/sbt-site/can-use-theme/build.sbt
index fdfae57..1e69be6 100644
--- a/plugin/src/sbt-test/sbt-site/can-use-theme/build.sbt
+++ b/plugin/src/sbt-test/sbt-site/can-use-theme/build.sbt
@@ -12,8 +12,8 @@ paradoxProperties in Paradox ++= Map(
paradoxMaterialTheme in Paradox ~= {
_.withCopyright("test-copyright")
- .withLogo("test-logo")
- .withFavicon("test-favicon")
+ .withLogo("test-logo")
+ .withFavicon("test-favicon")
}
def fileContains(file: File, texts: String*) = {
@@ -31,12 +31,17 @@ TaskKey[Unit]("checkContent") := {
fileContains(
dest / "index.html",
- "Paradox Site", "Nicely themed", "mkdocs-material", "test-copyright",
- "test-logo", "test-favicon"
+ "Paradox Site",
+ "Nicely themed",
+ "mkdocs-material",
+ "test-copyright",
+ "test-logo",
+ "test-favicon"
)
fileContains(
dest / "search" / "search_index.json",
- "Paradox Site", "Nicely themed"
+ "Paradox Site",
+ "Nicely themed"
)
}
diff --git a/plugin/src/sbt-test/sbt-site/can-use-theme/project/plugins.sbt b/plugin/src/sbt-test/sbt-site/can-use-theme/project/plugins.sbt
index a7fc8a1..85a2e71 100644
--- a/plugin/src/sbt-test/sbt-site/can-use-theme/project/plugins.sbt
+++ b/plugin/src/sbt-test/sbt-site/can-use-theme/project/plugins.sbt
@@ -1,2 +1,2 @@
-addSbtPlugin("com.github.sbt" % "sbt-paradox-material-theme" % sys.props("project.version"))
-addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.1")
+addSbtPlugin("com.github.sbt" % "sbt-paradox-material-theme" % sys.props("project.version"))
+addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.1")
diff --git a/project/plugins.sbt b/project/plugins.sbt
index cbac8ac..e1380d5 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -1,14 +1,15 @@
-addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.4.4")
+addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.4.4")
addSbtPlugin("com.lightbend.paradox" % "sbt-paradox-theme" % "0.4.4")
-addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.2")
-addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2")
-addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.6")
-addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")
-addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0")
+addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.2")
+addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.2")
+addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.6")
+addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0")
+addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0")
+addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2")
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
// This project is its own plugin :)
unmanagedSourceDirectories in Compile += baseDirectory.value.getParentFile / "plugin" / "src" / "main" / "scala"
-libraryDependencies += "org.jsoup" % "jsoup" % "1.10.3"
+libraryDependencies += "org.jsoup" % "jsoup" % "1.10.3"
libraryDependencies += "io.circe" %% "circe-core" % "0.8.0"
diff --git a/publish.sbt b/publish.sbt
index 3afd0ec..c519e0d 100644
--- a/publish.sbt
+++ b/publish.sbt
@@ -4,43 +4,45 @@ val repo = new {
val path = org + "/" + name
}
-inThisBuild(Def.settings(
- organization := "com.github.sbt",
- licenses += "MIT" -> url("https://github.com/sbt/sbt-paradox-material-theme/blob/master/LICENSE"),
- homepage := Some(url(s"https://${repo.org}.github.io/${repo.name}")),
- scmInfo := Some(
- ScmInfo(
- url(s"https://github.com/${repo.path}"),
- s"scm:git:git@github.com:${repo.path}.git"
- )
- ),
- developers := List(
- Developer("jonas", "Jonas Fonseca", "jonas.fonseca@gmail.com", url("https://github.com/jonas"))
- ),
- // Workaround NPE when publishing: https://github.com/sbt/sbt/issues/3519
- updateOptions := updateOptions.value.withGigahorse(false),
- publishMavenStyle := true,
- Test / publishArtifact := false,
- pomIncludeRepository := { _ => false },
- publishTo := {
- val nexus = "https://oss.sonatype.org/"
- if (isSnapshot.value)
- Some("snapshots" at nexus + "content/repositories/snapshots")
- else
- Some("releases" at nexus + "service/local/staging/deploy/maven2")
- },
- credentials ++= (
- for {
- username <- Option(System.getenv().get("SONATYPE_USERNAME"))
- password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
- } yield Credentials(
- "Sonatype Nexus Repository Manager",
- "oss.sonatype.org",
- username,
- password
- )
- ).toSeq,
- versionWithGit,
- git.useGitDescribe := true,
- git.remoteRepo := s"git@github.com:${repo.path}.git"
-))
+inThisBuild(
+ Def.settings(
+ organization := "com.github.sbt",
+ licenses += "MIT" -> url("https://github.com/sbt/sbt-paradox-material-theme/blob/master/LICENSE"),
+ homepage := Some(url(s"https://${repo.org}.github.io/${repo.name}")),
+ scmInfo := Some(
+ ScmInfo(
+ url(s"https://github.com/${repo.path}"),
+ s"scm:git:git@github.com:${repo.path}.git"
+ )
+ ),
+ developers := List(
+ Developer("jonas", "Jonas Fonseca", "jonas.fonseca@gmail.com", url("https://github.com/jonas"))
+ ),
+ // Workaround NPE when publishing: https://github.com/sbt/sbt/issues/3519
+ updateOptions := updateOptions.value.withGigahorse(false),
+ publishMavenStyle := true,
+ Test / publishArtifact := false,
+ pomIncludeRepository := { _ => false },
+ publishTo := {
+ val nexus = "https://oss.sonatype.org/"
+ if (isSnapshot.value)
+ Some("snapshots" at nexus + "content/repositories/snapshots")
+ else
+ Some("releases" at nexus + "service/local/staging/deploy/maven2")
+ },
+ credentials ++= (
+ for {
+ username <- Option(System.getenv().get("SONATYPE_USERNAME"))
+ password <- Option(System.getenv().get("SONATYPE_PASSWORD"))
+ } yield Credentials(
+ "Sonatype Nexus Repository Manager",
+ "oss.sonatype.org",
+ username,
+ password
+ )
+ ).toSeq,
+ versionWithGit,
+ git.useGitDescribe := true,
+ git.remoteRepo := s"git@github.com:${repo.path}.git"
+ )
+)