Skip to content

Commit

Permalink
site plugin - remove deprecated settings and classes
Browse files Browse the repository at this point in the history
  • Loading branch information
jenshalm committed Apr 5, 2024
1 parent 9014e54 commit 8dbff1c
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 129 deletions.
17 changes: 1 addition & 16 deletions site/src/main/scala/org/typelevel/sbt/TypelevelSitePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import laika.helium.Helium
import laika.sbt.LaikaPlugin
import laika.sbt.LaikaPlugin.autoImport._
import laika.sbt.Tasks
import laika.theme.ThemeProvider
import mdoc.MdocPlugin
import mdoc.MdocPlugin.autoImport._
import org.typelevel.sbt.TypelevelKernelPlugin._
Expand All @@ -37,15 +36,6 @@ object TypelevelSitePlugin extends AutoPlugin {

object autoImport {

@deprecated("Use tlSiteHelium", "0.5.0")
lazy val tlSiteHeliumConfig = settingKey[Helium]("The Typelevel Helium configuration")
@deprecated("Use tlSiteHelium", "0.5.0")
lazy val tlSiteHeliumExtensions =
settingKey[ThemeProvider]("The Typelevel Helium extensions")
@deprecated("Use .site.mainNavigation(appendLinks = ...) in tlSiteHelium", "0.5.0")
lazy val tlSiteRelatedProjects =
settingKey[Seq[(String, URL)]]("A list of related projects (default: empty)")

lazy val tlSiteHelium = settingKey[Helium]("The Helium theme configuration and extensions")
lazy val tlSiteIsTypelevelProject =
settingKey[Option[TypelevelProject]](
Expand Down Expand Up @@ -87,13 +77,11 @@ object TypelevelSitePlugin extends AutoPlugin {
tlSiteApiModule := None
)

@nowarn("cat=deprecation")
override def buildSettings = Seq(
tlSitePublishBranch := Some("main"),
tlSitePublishTags := tlSitePublishBranch.value.isEmpty,
tlSiteApiUrl := None,
tlSiteApiPackage := None,
tlSiteRelatedProjects := Nil,
tlSiteKeepFiles := true,
tlSiteJavaVersion := {
githubWorkflowJavaVersions
Expand All @@ -117,7 +105,6 @@ object TypelevelSitePlugin extends AutoPlugin {
}
)

@nowarn("cat=deprecation")
override def projectSettings = Seq(
tlSite := Def
.sequential(
Expand All @@ -143,10 +130,8 @@ object TypelevelSitePlugin extends AutoPlugin {
else
None
},
tlSiteHeliumConfig := TypelevelSiteSettings.defaults.value,
tlSiteHeliumExtensions := GenericSiteSettings.themeExtensions.value,
tlSiteHelium := {
if (tlSiteIsTypelevelProject.value.isDefined) tlSiteHeliumConfig.value
if (tlSiteIsTypelevelProject.value.isDefined) TypelevelSiteSettings.defaults.value
else GenericSiteSettings.defaults.value
},
tlSiteApiUrl := {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,28 @@

package org.typelevel.sbt.site

import cats.data.NonEmptyList
import cats.effect.Async
import cats.effect.Resource
import laika.ast.Path
import laika.config.SyntaxHighlighting
import laika.format.Markdown.GitHubFlavor
import laika.helium.Helium
import laika.helium.config.HeliumIcon
import laika.helium.config.IconLink
import laika.helium.config.TextLink
import laika.helium.config.ThemeNavigationSection
import laika.io.model.InputTree
import laika.parse.code.languages.ScalaSyntax
import laika.theme.Theme
import laika.theme.ThemeBuilder
import laika.theme.ThemeProvider
import org.typelevel.sbt.TypelevelGitHubPlugin.gitHubUserRepo
import org.typelevel.sbt.TypelevelKernelPlugin.autoImport.tlIsScala3
import org.typelevel.sbt.TypelevelSitePlugin.autoImport.tlSiteApiUrl
import org.typelevel.sbt.TypelevelSitePlugin.autoImport.tlSiteHeliumExtensions
import org.typelevel.sbt.TypelevelSitePlugin.autoImport.tlSiteRelatedProjects
import sbt.Def._
import sbt.Keys.developers
import sbt.Keys.scmInfo
import sbt.Keys.version

import scala.annotation.nowarn
import java.net.URL

object GenericSiteSettings {

Expand All @@ -45,32 +49,29 @@ object GenericSiteSettings {
scmInfo.value.map { info => IconLink.external(info.browseUrl.toString, HeliumIcon.github) }
}

@nowarn("cat=deprecation")
val themeExtensions: Initialize[ThemeProvider] = setting {
// TODO - inline when deprecated class gets removed
TypelevelHeliumExtensions(
tlIsScala3.value,
tlSiteApiUrl.value
)
}

@nowarn("cat=deprecation")
private val legacyRelatedProjects: Initialize[Option[ThemeNavigationSection]] = setting {
NonEmptyList.fromList(tlSiteRelatedProjects.value.toList).map { projects =>
val links = projects.map { case (name, url) => TextLink.external(url.toString, name) }
ThemeNavigationSection(
"Related Projects",
links.head,
links.tail*
)
new ThemeProvider {
def build[F[_]](implicit F: Async[F]): Resource[F, Theme[F]] =
ThemeBuilder[F]("sbt-typelevel-site Helium Extensions")
.addInputs(
tlSiteApiUrl.value.fold(InputTree[F]) { url =>
InputTree[F].addString(htmlForwarder(url), Path.Root / "api" / "index.html")
}
)
.addExtensions(
GitHubFlavor,
if (tlIsScala3.value)
SyntaxHighlighting.withSyntaxBinding("scala", ScalaSyntax.Scala3)
else SyntaxHighlighting
)
.build
}
}

@nowarn("cat=deprecation")
val defaults: Initialize[Helium] = setting {
Helium
.defaults
.extendWith(tlSiteHeliumExtensions.value)
.extendWith(themeExtensions.value)
.site
.metadata(
title = gitHubUserRepo.value.map(_._2),
Expand All @@ -79,11 +80,16 @@ object GenericSiteSettings {
version = Some(version.value)
)
.site
.mainNavigation(appendLinks = legacyRelatedProjects.value.toList)
.site
.topNavigationBar(
navLinks = apiLink.value.toList ++ githubLink.value.toList
)
}

private def htmlForwarder(to: URL) =
s"""|<!DOCTYPE html>
|<meta charset="utf-8">
|<meta http-equiv="refresh" content="0; URL=$to">
|<link rel="canonical" href="$to">
|""".stripMargin

}

This file was deleted.

0 comments on commit 8dbff1c

Please sign in to comment.