From 8dbff1c659e84e84e912bf9ad863deb7305e1d19 Mon Sep 17 00:00:00 2001 From: Jens Halm <3116929+jenshalm@users.noreply.github.com> Date: Fri, 5 Apr 2024 18:19:20 +0100 Subject: [PATCH] site plugin - remove deprecated settings and classes --- .../typelevel/sbt/TypelevelSitePlugin.scala | 17 +--- .../sbt/site/GenericSiteSettings.scala | 60 +++++++------ .../sbt/site/TypelevelHeliumExtensions.scala | 86 ------------------- 3 files changed, 34 insertions(+), 129 deletions(-) delete mode 100644 site/src/main/scala/org/typelevel/sbt/site/TypelevelHeliumExtensions.scala diff --git a/site/src/main/scala/org/typelevel/sbt/TypelevelSitePlugin.scala b/site/src/main/scala/org/typelevel/sbt/TypelevelSitePlugin.scala index 9c99f4d2..2f611a5e 100644 --- a/site/src/main/scala/org/typelevel/sbt/TypelevelSitePlugin.scala +++ b/site/src/main/scala/org/typelevel/sbt/TypelevelSitePlugin.scala @@ -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._ @@ -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]]( @@ -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 @@ -117,7 +105,6 @@ object TypelevelSitePlugin extends AutoPlugin { } ) - @nowarn("cat=deprecation") override def projectSettings = Seq( tlSite := Def .sequential( @@ -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 := { diff --git a/site/src/main/scala/org/typelevel/sbt/site/GenericSiteSettings.scala b/site/src/main/scala/org/typelevel/sbt/site/GenericSiteSettings.scala index 127809c9..ba09ab6e 100644 --- a/site/src/main/scala/org/typelevel/sbt/site/GenericSiteSettings.scala +++ b/site/src/main/scala/org/typelevel/sbt/site/GenericSiteSettings.scala @@ -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 { @@ -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), @@ -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"""| + | + | + | + |""".stripMargin + } diff --git a/site/src/main/scala/org/typelevel/sbt/site/TypelevelHeliumExtensions.scala b/site/src/main/scala/org/typelevel/sbt/site/TypelevelHeliumExtensions.scala deleted file mode 100644 index 31afd3ce..00000000 --- a/site/src/main/scala/org/typelevel/sbt/site/TypelevelHeliumExtensions.scala +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2022 Typelevel - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.typelevel.sbt.site - -import cats.effect.Async -import cats.effect.kernel.Resource -import laika.ast.Path -import laika.config.SyntaxHighlighting -import laika.format.Markdown.GitHubFlavor -import laika.io.model.InputTree -import laika.parse.code.languages.ScalaSyntax -import laika.theme.Theme -import laika.theme.ThemeBuilder -import laika.theme.ThemeProvider - -import java.net.URL - -@deprecated("Use GenericSiteSettings.extensions", "0.5.0") -object TypelevelHeliumExtensions { - - @deprecated("Use overload with scala3 and apiURL parameter", "0.4.7") - def apply(license: Option[(String, URL)], related: Seq[(String, URL)]): ThemeProvider = - apply(license, related, false) - - @deprecated("Use overload with scala3 and apiURL parameter", "0.4.13") - def apply( - license: Option[(String, URL)], - related: Seq[(String, URL)], - scala3: Boolean): ThemeProvider = - apply(license, related, false, None) - - @deprecated("Use overload with scala3 and apiURL parameter", "0.5.0") - def apply( - license: Option[(String, URL)], - related: Seq[(String, URL)], - scala3: Boolean, - apiUrl: Option[URL] - ): ThemeProvider = apply(scala3, apiUrl) - - /** - * @param scala3 - * whether to use Scala 3 syntax highlighting - * @param apiUrl - * url to API docs - */ - def apply( - scala3: Boolean, - apiUrl: Option[URL] - ): ThemeProvider = new ThemeProvider { - def build[F[_]](implicit F: Async[F]): Resource[F, Theme[F]] = - ThemeBuilder[F]("sbt-typelevel-site Helium Extensions") - .addInputs( - apiUrl.fold(InputTree[F]) { url => - InputTree[F].addString(htmlForwarder(url), Path.Root / "api" / "index.html") - } - ) - .addExtensions( - GitHubFlavor, - if (scala3) SyntaxHighlighting.withSyntaxBinding("scala", ScalaSyntax.Scala3) - else SyntaxHighlighting - ) - .build - } - - private def htmlForwarder(to: URL) = - s"""| - | - | - | - |""".stripMargin - -}