From 2af116c46bcac4c8d5226c0b96a2b20a8461d908 Mon Sep 17 00:00:00 2001 From: Enno <458526+ennru@users.noreply.github.com> Date: Thu, 23 May 2019 08:44:17 +0200 Subject: [PATCH] Docs: more settings to improve the generated site (#579) * Docs: more settings to improve the generated site * Move settings to Common auto-plugin * No CrossVersion.binary --- build.sbt | 38 +++++-------------- .../_template/projectSpecificFooter.st | 4 ++ .../main/paradox/assets/js/warnOldVersion.js | 23 +++++++++++ project/Common.scala | 38 +++++++++++++++++++ project/Publish.scala | 18 --------- .../grpc/internal/GrpcResponseHelpers.scala | 2 +- 6 files changed, 75 insertions(+), 48 deletions(-) create mode 100644 docs/src/main/paradox/_template/projectSpecificFooter.st create mode 100644 docs/src/main/paradox/assets/js/warnOldVersion.js create mode 100644 project/Common.scala diff --git a/build.sbt b/build.sbt index 4111117be..6122f4586 100644 --- a/build.sbt +++ b/build.sbt @@ -5,20 +5,6 @@ import akka.grpc.build.ReflectiveCodeGen scalaVersion := scala212 -val commonSettings = Seq( - organization := "com.lightbend.akka.grpc", - scalacOptions ++= List( - "-unchecked", - "-deprecation", - "-language:_", - "-encoding", "UTF-8" - ), - javacOptions ++= List( - "-Xlint:unchecked", - "-Xlint:deprecation" - ) -) ++ akka.grpc.Formatting.formatSettings - val akkaGrpcRuntimeName = "akka-grpc-runtime" lazy val codegen = Project( @@ -27,7 +13,6 @@ lazy val codegen = Project( ) .enablePlugins(SbtTwirl, BuildInfoPlugin) .settings(Dependencies.codegen) - .settings(commonSettings) .settings(Seq( buildInfoKeys ++= BuildInfoKey.ofN(organization, name, version, scalaVersion, sbtVersion), buildInfoKeys += "runtimeArtifactName" -> akkaGrpcRuntimeName, @@ -51,7 +36,6 @@ lazy val runtime = Project( base = file("runtime") ) .settings(Dependencies.runtime) - .settings(commonSettings) /** This could be an independent project - or does upstream provide this already? didn't find it.. */ lazy val scalapbProtocPlugin = Project( @@ -60,7 +44,6 @@ lazy val scalapbProtocPlugin = Project( ) /** TODO we only really need to depend on scalapb */ .dependsOn(codegen) - .settings(commonSettings) .settings(Seq( artifact in (Compile, assembly) := { val art = (artifact in (Compile, assembly)).value @@ -77,7 +60,6 @@ lazy val mavenPlugin = Project( id = "akka-grpc-maven-plugin", base = file("maven-plugin") ) - .settings(commonSettings) .settings(Dependencies.mavenPlugin) .enablePlugins(akka.grpc.SbtMavenPlugin) .settings(Seq( @@ -90,7 +72,6 @@ lazy val sbtPlugin = Project( id = "sbt-akka-grpc", base = file("sbt-plugin") ) - .settings(commonSettings) .settings(Dependencies.sbtPlugin) .enablePlugins(SbtPlugin) .settings( @@ -117,7 +98,6 @@ lazy val interopTests = Project( base = file("interop-tests") ) .settings(Dependencies.interopTests) - .settings(commonSettings) .pluginTestingSettings .settings( ReflectiveCodeGen.generatedLanguages := Seq("Scala", "Java"), @@ -156,16 +136,18 @@ lazy val docs = Project( .dependsOn(pluginTesterScala) .dependsOn(pluginTesterJava) .enablePlugins(AkkaParadoxPlugin) - .enablePlugins(akka.grpc.NoPublish) .settings( + skip in publish := true, // Make sure code generation is ran before paradox: (Compile / paradox) := ((Compile / paradox) dependsOn (Compile / compile)).value, - paradoxGroups := Map( - "Language" -> Seq("Scala", "Java"), + Compile / paradoxGroups := Map( + "Language" -> Seq("Java", "Scala"), "Buildtool" -> Seq("sbt", "Gradle", "Maven"), ), - paradoxProperties ++= Map( + Compile / paradoxProperties ++= Map( "grpc.version" → Dependencies.Versions.grpc, + "project.url" -> "https://developer.lightbend.com/docs/akka-grpc/current/", + "canonical.base_url" -> "https://developer.lightbend.com/docs/akka-grpc/current/", "akka-http.version" → Dependencies.Versions.akkaHttp, "extref.akka-http.base_url" -> s"https://doc.akka.io/docs/akka-http/${Dependencies.Versions.akkaHttp}/%s", ), @@ -177,9 +159,8 @@ lazy val pluginTesterScala = Project( base = file("plugin-tester-scala") ) .settings(Dependencies.pluginTester) - .settings(commonSettings) - .enablePlugins(akka.grpc.NoPublish) .settings( + skip in publish := true, ReflectiveCodeGen.codeGeneratorSettings ++= Seq("flat_package", "server_power_apis") ) .pluginTestingSettings @@ -189,9 +170,8 @@ lazy val pluginTesterJava = Project( base = file("plugin-tester-java") ) .settings(Dependencies.pluginTester) - .settings(commonSettings) - .enablePlugins(akka.grpc.NoPublish) .settings( + skip in publish := true, ReflectiveCodeGen.generatedLanguages := Seq("Java"), ReflectiveCodeGen.codeGeneratorSettings ++= Seq("server_power_apis") ) @@ -213,7 +193,7 @@ lazy val root = Project( pluginTesterJava, docs, ) - .enablePlugins(akka.grpc.NoPublish) .settings( + skip in publish := true, unmanagedSources in (Compile, headerCreate) := (baseDirectory.value / "project").**("*.scala").get ) diff --git a/docs/src/main/paradox/_template/projectSpecificFooter.st b/docs/src/main/paradox/_template/projectSpecificFooter.st new file mode 100644 index 000000000..c4a9441f3 --- /dev/null +++ b/docs/src/main/paradox/_template/projectSpecificFooter.st @@ -0,0 +1,4 @@ + + diff --git a/docs/src/main/paradox/assets/js/warnOldVersion.js b/docs/src/main/paradox/assets/js/warnOldVersion.js new file mode 100644 index 000000000..39da3c3ce --- /dev/null +++ b/docs/src/main/paradox/assets/js/warnOldVersion.js @@ -0,0 +1,23 @@ +function initOldVersionWarnings($, thisVersion, projectUrl) { + if (projectUrl && projectUrl !== "") { + var schemeLessUrl = projectUrl; + if (projectUrl.startsWith("http://")) projectUrl = schemeLessUrl.substring(5); + else if (projectUrl.startsWith("https://")) projectUrl = schemeLessUrl.substring(6); + const url = schemeLessUrl + (schemeLessUrl.endsWith("\/") ? "" : "/") + "paradox.json"; + $.get(url, function (versionData) { + const currentVersion = versionData.version; + if (thisVersion !== currentVersion) { + showVersionWarning(thisVersion, currentVersion, projectUrl); + } + }); + } +} + +function showVersionWarning(thisVersion, currentVersion, projectUrl) { + $('#docs').prepend( + '
' + + '

This documentation regards version ' + thisVersion + ', ' + + 'however the current version is ' + currentVersion + '.

' + + '
' + ); +} \ No newline at end of file diff --git a/project/Common.scala b/project/Common.scala new file mode 100644 index 000000000..9591c3170 --- /dev/null +++ b/project/Common.scala @@ -0,0 +1,38 @@ +import sbt.Keys._ +import sbt._ +import sbt.plugins.JvmPlugin + +object Common extends AutoPlugin { + + override def trigger = allRequirements + + override def requires = JvmPlugin + + override def globalSettings = Seq( + organization := "com.lightbend.akka.grpc", + organizationName := "Lightbend Inc.", + organizationHomepage := Some(url("https://www.lightbend.com/")), + // apiURL := Some(url(s"https://doc.akka.io/api/akka-grpc/${version.value}")), + homepage := Some(url("https://akka.io/")), + scmInfo := Some(ScmInfo(url("https://github.com/akka/akka-grpc"), "git@github.com:akka/akka-grpc")), + developers += Developer("contributors", + "Contributors", + "https://gitter.im/akka/dev", + url("https://github.com/akka/akka-grpc/graphs/contributors")), + licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")), + description := "Akka gRPC - Support for building streaming gRPC servers and clients on top of Akka Streams." + ) + + override lazy val projectSettings = Seq( + scalacOptions ++= List( + "-unchecked", + "-deprecation", + "-language:_", + "-encoding", "UTF-8" + ), + javacOptions ++= List( + "-Xlint:unchecked", + "-Xlint:deprecation" + ) + ) ++ akka.grpc.Formatting.formatSettings +} diff --git a/project/Publish.scala b/project/Publish.scala index 04c39ef7c..5a4abc612 100644 --- a/project/Publish.scala +++ b/project/Publish.scala @@ -2,17 +2,6 @@ package akka.grpc import sbt._, Keys._ -/** - * For projects that are not to be published. - */ -object NoPublish extends AutoPlugin { - override def requires = plugins.JvmPlugin - - override def projectSettings = Seq( - skip in publish := true, - ) -} - object Publish extends AutoPlugin { import bintray.BintrayPlugin import bintray.BintrayPlugin.autoImport._ @@ -23,13 +12,6 @@ object Publish extends AutoPlugin { override def projectSettings = Seq( bintrayOrganization := Some("akka"), bintrayPackage := "akka-grpc", - homepage := Some(url("https://developer.lightbend.com/docs/akka-grpc/current/")), - scmInfo := Some(ScmInfo(url("https://github.com/akka/akka-grpc"), "git@github.com:akka/akka-grpc")), - licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")), - developers += Developer("contributors", - "Contributors", - "https://gitter.im/akka/dev", - url("https://github.com/akka/akka-grpc/graphs/contributors")), ) } diff --git a/runtime/src/main/scala/akka/grpc/internal/GrpcResponseHelpers.scala b/runtime/src/main/scala/akka/grpc/internal/GrpcResponseHelpers.scala index d8e8e3cba..075c214a5 100644 --- a/runtime/src/main/scala/akka/grpc/internal/GrpcResponseHelpers.scala +++ b/runtime/src/main/scala/akka/grpc/internal/GrpcResponseHelpers.scala @@ -66,7 +66,7 @@ object GrpcResponseHelpers { entity = HttpEntity.Chunked(Grpc.contentType, outChunks)) } - def status(status: Status): HttpResponse = + def status(status: Status): HttpResponse = HttpResponse(entity = HttpEntity.Chunked(Grpc.contentType, Source.single(trailer(status)))) def trailer(status: Status): LastChunk =