Skip to content

Commit

Permalink
Merge pull request #227 from http4s/update/sbt-typelevel-0.5.0
Browse files Browse the repository at this point in the history
Update to sbt-typelevel 0.5.0
  • Loading branch information
armanbilge authored Aug 21, 2023
2 parents 4414114 + 751731d commit 4b94a3a
Show file tree
Hide file tree
Showing 9 changed files with 209 additions and 232 deletions.
276 changes: 146 additions & 130 deletions .github/workflows/ci.yml

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ lazy val core = project
.in(file("core"))
.enablePlugins(SbtPlugin)
.settings(
name := "sbt-http4s-org"
name := "sbt-http4s-org",
unusedCompileDependenciesFilter -= moduleFilter("org.typelevel", "sbt-typelevel"),
unusedCompileDependenciesFilter -= moduleFilter("org.typelevel", "sbt-typelevel-scalafix"),
unusedCompileDependenciesFilter -= moduleFilter("org.typelevel", "sbt-typelevel-site")
)

lazy val docs = project
.in(file("site"))
.enablePlugins(Http4sOrgSitePlugin)
.settings(
tlSiteRelatedProjects += "sbt-typelevel" -> url("https://typelevel.org/sbt-typelevel/")
)

ThisBuild / tlBaseVersion := "0.14"
ThisBuild / tlBaseVersion := "0.15"
ThisBuild / crossScalaVersions := Seq("2.12.18")
ThisBuild / developers := List(
Developer(
Expand Down
3 changes: 1 addition & 2 deletions core/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
val sbtTypelevelVersion = "0.4.22"
val sbtTypelevelVersion = "0.5.0-RC12"
addSbtPlugin("org.typelevel" % "sbt-typelevel" % sbtTypelevelVersion)
addSbtPlugin("org.typelevel" % "sbt-typelevel-site" % sbtTypelevelVersion)
addSbtPlugin("org.typelevel" % "sbt-typelevel-scalafix" % sbtTypelevelVersion)
addSbtPlugin("com.github.cb372" % "sbt-explicit-dependencies" % "0.3.1")
addSbtPlugin("org.scala-native" % "sbt-scala-native" % "0.4.0")
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 0 additions & 5 deletions core/src/main/resources/org/http4s/sbt/site/site/styles.css

This file was deleted.

11 changes: 1 addition & 10 deletions core/src/main/scala/org/http4s/sbt/Http4sOrgPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,10 @@ import scalafix.sbt.ScalafixPlugin.autoImport._

import ExplicitDepsPlugin.autoImport._
import GenerativeKeys._
import TypelevelKernelPlugin._
import autoImport._
import TypelevelCiPlugin.autoImport._
import TypelevelSonatypePlugin.autoImport._

object Http4sOrgPlugin extends AutoPlugin {
object autoImport

override def trigger = allRequirements

override def requires = TypelevelPlugin && TypelevelScalafixPlugin && ExplicitDepsPlugin
Expand Down Expand Up @@ -74,12 +70,7 @@ object Http4sOrgPlugin extends AutoPlugin {

lazy val explicitDepsSettings: Seq[Setting[_]] =
Seq(
unusedCompileDependenciesTest := {
if (tlSkipIrrelevantScalas.value && (unusedCompileDependenciesTest / skip).value)
()
else unusedCompileDependenciesTest.value
},
skipIfIrrelevant(unusedCompileDependenciesTest)
unusedCompileDependenciesFilter -= moduleFilter("org.typelevel", "scalac-compat-annotation")
)

lazy val scalafixSettings: Seq[Setting[_]] =
Expand Down
84 changes: 36 additions & 48 deletions core/src/main/scala/org/http4s/sbt/Http4sOrgSitePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,32 +16,32 @@

package org.http4s.sbt

import laika.ast.LengthUnit._
import cats.data.NonEmptyList
import laika.ast.Path.Root
import laika.ast._
import laika.helium.Helium
import laika.ast.*
import laika.helium.config.Favicon
import laika.helium.config.HeliumIcon
import laika.helium.config.IconLink
import laika.helium.config.ImageLink
import laika.helium.config.TextLink
import laika.helium.config.ThemeNavigationSection
import laika.sbt.LaikaPlugin
import laika.theme.config.Color
import org.typelevel.sbt.TypelevelGitHubPlugin
import org.typelevel.sbt.TypelevelSitePlugin
import sbt.Keys._
import sbt._
import org.typelevel.sbt.site.TypelevelSiteSettings
import sbt.*

object Http4sOrgSitePlugin extends AutoPlugin {

override def requires = TypelevelSitePlugin && LaikaPlugin

import TypelevelGitHubPlugin.autoImport._
import TypelevelSitePlugin.autoImport._
import LaikaPlugin.autoImport._

override def projectSettings: Seq[Setting[_]] = Seq(
tlSiteRelatedProjects := {
Seq(
private val relatedProjects: Def.Initialize[ThemeNavigationSection] = Def.setting {
val mappings = NonEmptyList
.of(
"http4s" -> url("https://http4s.org/"),
// Backends
"blaze" -> url("https://github.com/http4s/blaze"),
Expand Down Expand Up @@ -70,28 +70,25 @@ object Http4sOrgSitePlugin extends AutoPlugin {
"sbt-http4s-org" -> url("https://http4s.github.io/sbt-http4s-org/"),
// Third party
"feral" -> url("https://github.com/typelevel/feral/")
).filterNot { case (repo, _) =>
)
.filterNot { case (repo, _) =>
tlGitHubRepo.value.contains(repo) // omit ourselves!
}
},
laikaTheme ~= { _.extend(site.Http4sHeliumExtensions) },
tlSiteHeliumConfig := {
Helium.defaults.all
.metadata(
title = tlGitHubRepo.value,
authors = developers.value.map(_.name),
language = Some("en"),
version = Some(version.value.toString)
)
.site
.layout(
contentWidth = px(860),
navigationWidth = px(275),
topBarHeight = px(35),
defaultBlockSpacing = px(10),
defaultLineHeight = 1.5,
anchorPlacement = laika.helium.config.AnchorPlacement.Right
)
.map { case (name, url) =>
TextLink.external(url.toString, name)
}
ThemeNavigationSection(
"Related Projects",
NonEmptyList.fromListUnsafe(mappings)
)
}

val chatLink: IconLink = IconLink.external("https://discord.gg/XF3CXcMzqD", HeliumIcon.chat)

override def projectSettings: Seq[Setting[_]] = Seq(
tlSiteHelium := {
tlSiteHelium.value
.extendWith(site.Http4sHeliumExtensions)
.site
.themeColors(
primary = Color.hex("5B7980"),
Expand All @@ -105,32 +102,23 @@ object Http4sOrgSitePlugin extends AutoPlugin {
)
.site
.favIcons(
Favicon.internal(Root / "images" / "http4s-favicon.svg", "32x32").copy(sizes = None),
Favicon.internal(Root / "images" / "http4s-favicon.svg"),
Favicon.internal(Root / "images" / "http4s-favicon.png", "32x32")
)
.site
.darkMode
.disabled
.site
.footer(TypelevelSiteSettings.defaultFooter.value: _*)
.site
.mainNavigation(appendLinks = Seq(relatedProjects.value))
.site
.topNavigationBar(
homeLink = ImageLink
.external(
"https://http4s.org",
Image.internal(Root / "images" / "http4s-logo-text-dark.svg")
),
navLinks = tlSiteApiUrl.value.toList.map { url =>
IconLink.external(
url.toString,
HeliumIcon.api,
options = Styles("svg-link")
)
} ++ Seq(
IconLink.external(
scmInfo.value.fold("https://github.com/http4s")(_.browseUrl.toString),
HeliumIcon.github,
options = Styles("svg-link")),
IconLink.external("https://discord.gg/XF3CXcMzqD", HeliumIcon.chat)
)
homeLink = ImageLink.external(
"https://http4s.org",
Image.internal(Root / "images" / "http4s-logo-text-dark.svg")
),
navLinks = Seq(chatLink) // api + github links inherited from sbt-typelevel
)
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package org.http4s.sbt.site

import cats.effect.Async
import cats.effect.Resource
import cats.effect.kernel.Sync
import laika.ast.Path
import laika.io.model.InputTree
import laika.theme.Theme
Expand All @@ -26,35 +26,23 @@ import laika.theme.ThemeProvider

object Http4sHeliumExtensions extends ThemeProvider {

override def build[F[_]](implicit F: Sync[F]): Resource[F, Theme[F]] =
ThemeBuilder[F]("Typelevel Helium Extensions")
.addInputs(
InputTree[F]
.addStream(
F.blocking(getClass.getResourceAsStream("site/styles.css")),
Path.Root / "site" / "styles.css"
)
.addStream(
F.blocking(getClass.getResourceAsStream("images/http4s-favicon.png")),
Path.Root / "images" / "http4s-favicon.png"
)
.addStream(
F.blocking(getClass.getResourceAsStream("images/http4s-favicon.svg")),
Path.Root / "images" / "http4s-favicon.svg"
)
.addStream(
F.blocking(getClass.getResourceAsStream("images/http4s-logo.svg")),
Path.Root / "images" / "http4s-logo.svg"
)
.addStream(
F.blocking(getClass.getResourceAsStream("images/http4s-logo-text-light.svg")),
Path.Root / "images" / "http4s-logo-text-light.svg"
)
.addStream(
F.blocking(getClass.getResourceAsStream("images/http4s-logo-text-dark.svg")),
Path.Root / "images" / "http4s-logo-text-dark.svg"
)
)
private val imageFileNames = Seq(
"http4s-favicon.png",
"http4s-favicon.svg",
"http4s-logo.svg",
"http4s-logo-text-light.svg",
"http4s-logo-text-dark.svg"
)

override def build[F[_]](implicit F: Async[F]): Resource[F, Theme[F]] = {

val inputs = imageFileNames.foldLeft(InputTree[F]) { case (inputTree, fileName) =>
inputTree.addClassResource[this.type](s"images/$fileName", Path.Root / "images" / fileName)
}

ThemeBuilder[F]("http4s Images")
.addInputs(inputs)
.build
}

}

0 comments on commit 4b94a3a

Please sign in to comment.