Skip to content

Commit

Permalink
Add updateDoc settings
Browse files Browse the repository at this point in the history
  • Loading branch information
afsalthaj committed Dec 30, 2018
1 parent 6302504 commit f9f8057
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 29 deletions.
38 changes: 10 additions & 28 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import com.sun.xml.internal.messaging.saaj.util.ByteInputStream
import microsites.CdnDirectives

import scala.tools.nsc.interpreter.InputStream

lazy val root = (project in file("."))
.dependsOn(macros)
.settings(
Expand All @@ -16,36 +19,15 @@ lazy val docs = project
.enablePlugins(MicrositesPlugin)
.settings(name := "afsalthaj")
.settings(moduleName := "safe-string-interpolation-docs")
.settings(docSettings)
.settings(DocSupport.settings)
.settings(Seq(
fork in tut := true,
git.remoteRepo := "https://github.com/afsalthaj/safe-string-interpolation.git",
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.yml" | "*.md"
))
.settings(scalacOptions in Tut ~= (_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-dead-code"))))
.enablePlugins(GhpagesPlugin)

lazy val docSettings = Seq(
micrositeName := "Typesafe Interpolation",
micrositeDescription := "Typesafe Interpolation",
micrositeHighlightTheme := "atom-one-light",
micrositeGithubRepo := "safe-string-interpolation",
micrositeHomepage := "https://afsalthaj.github.io/safe-string-interpolation",
micrositeBaseUrl := "/safe-string-interpolation",
micrositeGithubOwner := "afsalthaj",
micrositeGithubRepo := "safe-string-interpolation",
micrositeGitterChannelUrl := "safe-string-interpolation/community",
micrositePushSiteWith := GHPagesPlugin,
micrositePalette := Map(
"brand-primary" -> "#5B5988",
"brand-secondary" -> "#292E53",
"brand-tertiary" -> "#222749",
"gray-dark" -> "#49494B",
"gray" -> "#7B7B7E",
"gray-light" -> "#E5E5E6",
"gray-lighter" -> "#F4F3F4",
"white-color" -> "#FFFFFF"),
autoAPIMappings := true,
ghpagesNoJekyll := false,
fork in tut := true,
git.remoteRepo := "https://github.com/afsalthaj/safe-string-interpolation.git",
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.yml" | "*.md"
)

micrositeCDNDirectives := CdnDirectives(
jsList = List(
Expand All @@ -59,7 +41,6 @@ micrositeCDNDirectives := CdnDirectives(
)
)


micrositeGithubOwner := "afsalthaj"

lazy val macros = (project in file("macros"))
Expand Down Expand Up @@ -129,3 +110,4 @@ lazy val rootBuildSettings = Seq(
pomIncludeRepository := { _ => false },
publishMavenStyle := true
)

2 changes: 1 addition & 1 deletion docs/src/main/tut/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Easy ! Use `safeStr"your log $a $b, $c"` instead of `s"your log $a $b, $c"` !
Add this in your build.sbt

```scala
libraryDependencies += "io.github.afsalthaj" %% "safe-string" % "1.2.8"
libraryDependencies += "io.github.afsalthaj" %% "safe-string" % "1.2.8"
```

Or, in ammonite;
Expand Down
48 changes: 48 additions & 0 deletions project/DocSupport.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import com.typesafe.sbt.GitPlugin.autoImport.git
import com.typesafe.sbt.sbtghpages.GhpagesPlugin.autoImport.ghpagesNoJekyll
import microsites.MicrositesPlugin.autoImport._
import sbt.Keys.{autoAPIMappings, fork, includeFilter, version}
import sbt.{File, IO, taskKey}

object DocSupport {
lazy val updateDoc = taskKey[Unit]("update versions in doc")

val settings = Seq(

updateDoc := {
val string = IO.read(new File("docs/src/main/tut/index.md").getAbsoluteFile)
val version1 =
"\"io.github.afsalthaj\" %% \"safe-string\".*".r.findFirstIn(string).getOrElse(throw new IllegalStateException("Cannot find pattern \"\\\"io.github.afsalthaj\\\" %% \\\"safe-string\\\".*\" in docs/src/main/tut/index.md"))
val version2 =
"`io.github.afsalthaj::safe-string.*".r.findFirstIn(string).getOrElse(throw new IllegalStateException("Cannot find the pattern io.github.afsalthaj::safe-string.* in docs/src/main/tut/index.md"))

val content =
string.replace(version1, s""""io.github.afsalthaj" %% "safe-string" % "${version.value}" """).replace(version2, s"`io.github.afsalthaj::safe-string:${version.value}`")

IO.write(new File("docs/src/main/tut/index.md").getAbsoluteFile, content = content, append = false)

publishMicrosite.value
},
micrositeName := "Typesafe Interpolation",
micrositeDescription := "Typesafe Interpolation",
micrositeHighlightTheme := "atom-one-light",
micrositeGithubRepo := "safe-string-interpolation",
micrositeHomepage := "https://afsalthaj.github.io/safe-string-interpolation",
micrositeBaseUrl := "/safe-string-interpolation",
micrositeGithubOwner := "afsalthaj",
micrositeGithubRepo := "safe-string-interpolation",
micrositeGitterChannelUrl := "safe-string-interpolation/community",
micrositePushSiteWith := GHPagesPlugin,
micrositePalette := Map(
"brand-primary" -> "#5B5988",
"brand-secondary" -> "#292E53",
"brand-tertiary" -> "#222749",
"gray-dark" -> "#49494B",
"gray" -> "#7B7B7E",
"gray-light" -> "#E5E5E6",
"gray-lighter" -> "#F4F3F4",
"white-color" -> "#FFFFFF"),
autoAPIMappings := true,
ghpagesNoJekyll := false,
)
}

0 comments on commit f9f8057

Please sign in to comment.