From 9a9e21a62bcbd8019c606a8c04279b3c5785d4eb Mon Sep 17 00:00:00 2001 From: Helena Edelson Date: Mon, 9 Sep 2019 05:25:33 -0700 Subject: [PATCH] Consolidate Paradox settings, add includes workaround #27656 (#27657) --- build.sbt | 54 +++---------------------------- project/Paradox.scala | 74 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 78 insertions(+), 50 deletions(-) create mode 100644 project/Paradox.scala diff --git a/build.sbt b/build.sbt index ecf88bd06e..71cf03da7e 100644 --- a/build.sbt +++ b/build.sbt @@ -1,4 +1,4 @@ -import akka.{ AutomaticModuleName, CopyrightHeaderForBuild, CrossJava, ParadoxSupport, ScalafixIgnoreFilePlugin } +import akka.{ AutomaticModuleName, CopyrightHeaderForBuild, Paradox, ParadoxSupport, ScalafixIgnoreFilePlugin } enablePlugins( UnidocRoot, @@ -203,51 +203,8 @@ lazy val docs = akkaModule("akka-docs") actorTypedTests % "compile->compile;test->test", streamTestkit % "compile->compile;test->test") .settings(Dependencies.docs) - .settings( - name in (Compile, paradox) := "Akka", - Compile / paradoxProperties ++= Map( - "canonical.base_url" -> "https://doc.akka.io/docs/akka/current", - "github.base_url" -> GitHub - .url(version.value), // for links like this: @github[#1](#1) or @github[83986f9](83986f9) - "extref.akka.http.base_url" -> "https://doc.akka.io/docs/akka-http/current/%s", - "extref.wikipedia.base_url" -> "https://en.wikipedia.org/wiki/%s", - "extref.github.base_url" -> (GitHub.url(version.value) + "/%s"), // for links to our sources - "extref.samples.base_url" -> "https://developer.lightbend.com/start/?group=akka&project=%s", - "extref.ecs.base_url" -> "https://example.lightbend.com/v1/download/%s", - "scaladoc.akka.base_url" -> "https://doc.akka.io/api/akka/2.5", - "scaladoc.akka.http.base_url" -> "https://doc.akka.io/api/akka-http/current", - "javadoc.akka.base_url" -> "https://doc.akka.io/japi/akka/2.5", - "javadoc.akka.http.base_url" -> "https://doc.akka.io/japi/akka-http/current", - "scala.version" -> scalaVersion.value, - "scala.binary_version" -> scalaBinaryVersion.value, - "akka.version" -> version.value, - "scalatest.version" -> Dependencies.scalaTestVersion.value, - "sigar_loader.version" -> "1.6.6-rev002", - "algolia.docsearch.api_key" -> "543bad5ad786495d9ccd445ed34ed082", - "algolia.docsearch.index_name" -> "akka_io", - "google.analytics.account" -> "UA-21117439-1", - "google.analytics.domain.name" -> "akka.io", - "signature.akka.base_dir" -> (baseDirectory in ThisBuild).value.getAbsolutePath, - "fiddle.code.base_dir" -> (sourceDirectory in Test).value.getAbsolutePath, - "fiddle.akka.base_dir" -> (baseDirectory in ThisBuild).value.getAbsolutePath, - "aeron_version" -> Dependencies.aeronVersion, - "netty_version" -> Dependencies.nettyVersion), - Compile / paradoxGroups := Map("Language" -> Seq("Scala", "Java")), - paradoxRoots := List( - // The real index: - "index.html", - // Page that recommends Alpakka: - "camel.html", - // TODO seems like an orphan? - "fault-tolerance-sample.html", - // FIXME https://github.com/lightbend/paradox/issues/350 - // Links in a snippet are interpreted relative to the page the snippet is included in, - // instead of relative to the place where the snippet is declared. - "includes.html" - ), - resolvers += Resolver.jcenterRepo, - apidocRootPackage := "akka", - deployRsyncArtifact := List((paradox in Compile).value -> s"www/docs/akka/${version.value}")) + .settings(Paradox.settings) + .settings(ParadoxSupport.paradoxWithCustomDirectives) .enablePlugins( AkkaParadoxPlugin, DeployRsync, @@ -255,7 +212,6 @@ lazy val docs = akkaModule("akka-docs") ParadoxBrowse, ScaladocNoVerificationOfDiagrams, StreamOperatorsIndexGenerator) - .settings(ParadoxSupport.paradoxWithCustomDirectives) .disablePlugins(MimaPlugin, WhiteSourcePlugin) .disablePlugins(ScalafixPlugin) @@ -496,9 +452,7 @@ lazy val streamTyped = akkaModule("akka-stream-typed") .enablePlugins(ScaladocNoVerificationOfDiagrams) lazy val actorTestkitTyped = akkaModule("akka-actor-testkit-typed") - .dependsOn(actorTyped, - slf4j, - testkit % "compile->compile;test->test") + .dependsOn(actorTyped, slf4j, testkit % "compile->compile;test->test") .settings(AutomaticModuleName.settings("akka.actor.testkit.typed")) .settings(Dependencies.actorTestkitTyped) diff --git a/project/Paradox.scala b/project/Paradox.scala new file mode 100644 index 0000000000..498b2e899d --- /dev/null +++ b/project/Paradox.scala @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2019 Lightbend Inc. + */ + +package akka + +import com.lightbend.paradox.sbt.ParadoxPlugin +import com.lightbend.paradox.sbt.ParadoxPlugin.autoImport._ +import com.lightbend.paradox.apidoc.ApidocPlugin +import sbt.Keys._ +import sbt._ + +object Paradox { + + val propertiesSettings = Seq( + Compile / paradoxProperties ++= Map( + "canonical.base_url" -> "https://doc.akka.io/docs/akka/current", + "github.base_url" -> GitHub + .url(version.value), // for links like this: @github[#1](#1) or @github[83986f9](83986f9) + "extref.akka.http.base_url" -> "https://doc.akka.io/docs/akka-http/current/%s", + "extref.wikipedia.base_url" -> "https://en.wikipedia.org/wiki/%s", + "extref.github.base_url" -> (GitHub.url(version.value) + "/%s"), // for links to our sources + "extref.samples.base_url" -> "https://developer.lightbend.com/start/?group=akka&project=%s", + "extref.ecs.base_url" -> "https://example.lightbend.com/v1/download/%s", + "scaladoc.akka.base_url" -> "https://doc.akka.io/api/akka/2.5", + "scaladoc.akka.http.base_url" -> "https://doc.akka.io/api/akka-http/current", + "javadoc.akka.base_url" -> "https://doc.akka.io/japi/akka/2.5", + "javadoc.akka.http.base_url" -> "https://doc.akka.io/japi/akka-http/current", + "scala.version" -> scalaVersion.value, + "scala.binary_version" -> scalaBinaryVersion.value, + "akka.version" -> version.value, + "scalatest.version" -> Dependencies.scalaTestVersion.value, + "sigar_loader.version" -> "1.6.6-rev002", + "algolia.docsearch.api_key" -> "543bad5ad786495d9ccd445ed34ed082", + "algolia.docsearch.index_name" -> "akka_io", + "google.analytics.account" -> "UA-21117439-1", + "google.analytics.domain.name" -> "akka.io", + "signature.akka.base_dir" -> (baseDirectory in ThisBuild).value.getAbsolutePath, + "fiddle.code.base_dir" -> (sourceDirectory in Test).value.getAbsolutePath, + "fiddle.akka.base_dir" -> (baseDirectory in ThisBuild).value.getAbsolutePath, + "aeron_version" -> Dependencies.aeronVersion, + "netty_version" -> Dependencies.nettyVersion)) + + val rootsSettings = Seq( + paradoxRoots := List( + "index.html", + // Page that recommends Alpakka: + "camel.html", + // TODO page not linked to + "fault-tolerance-sample.html")) + + // FIXME https://github.com/lightbend/paradox/issues/350 + // Exclusions from direct compilation for includes dirs/files not belonging in a TOC + val includesSettings = Seq( + (Compile / paradoxMarkdownToHtml / excludeFilter) := (Compile / paradoxMarkdownToHtml / excludeFilter).value || + ParadoxPlugin.InDirectoryFilter((Compile / paradox / sourceDirectory).value / "includes"), + // Links are interpreted relative to the page the snippet is included in, + // instead of relative to the place where the snippet is declared. + (Compile / paradoxMarkdownToHtml / excludeFilter) := (Compile / paradoxMarkdownToHtml / excludeFilter).value || + ParadoxPlugin.InDirectoryFilter((Compile / paradox / sourceDirectory).value / "includes.html")) + + val groupsSettings = Seq(Compile / paradoxGroups := Map("Language" -> Seq("Scala", "Java"))) + + val settings = + propertiesSettings ++ + rootsSettings ++ + includesSettings ++ + groupsSettings ++ + Seq( + name in (Compile, paradox) := "Akka", + ApidocPlugin.autoImport.apidocRootPackage := "akka", + DeployRsync.autoImport.deployRsyncArtifact := List( + (Compile / paradox).value -> s"www/docs/akka/${version.value}")) +}