Skip to content

Commit f9f8057

Browse files
committed
Add updateDoc settings
1 parent 6302504 commit f9f8057

File tree

3 files changed

+59
-29
lines changed

3 files changed

+59
-29
lines changed

build.sbt

+10-28
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
import com.sun.xml.internal.messaging.saaj.util.ByteInputStream
12
import microsites.CdnDirectives
23

4+
import scala.tools.nsc.interpreter.InputStream
5+
36
lazy val root = (project in file("."))
47
.dependsOn(macros)
58
.settings(
@@ -16,36 +19,15 @@ lazy val docs = project
1619
.enablePlugins(MicrositesPlugin)
1720
.settings(name := "afsalthaj")
1821
.settings(moduleName := "safe-string-interpolation-docs")
19-
.settings(docSettings)
22+
.settings(DocSupport.settings)
23+
.settings(Seq(
24+
fork in tut := true,
25+
git.remoteRepo := "https://github.com/afsalthaj/safe-string-interpolation.git",
26+
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.yml" | "*.md"
27+
))
2028
.settings(scalacOptions in Tut ~= (_.filterNot(Set("-Ywarn-unused-import", "-Ywarn-dead-code"))))
2129
.enablePlugins(GhpagesPlugin)
2230

23-
lazy val docSettings = Seq(
24-
micrositeName := "Typesafe Interpolation",
25-
micrositeDescription := "Typesafe Interpolation",
26-
micrositeHighlightTheme := "atom-one-light",
27-
micrositeGithubRepo := "safe-string-interpolation",
28-
micrositeHomepage := "https://afsalthaj.github.io/safe-string-interpolation",
29-
micrositeBaseUrl := "/safe-string-interpolation",
30-
micrositeGithubOwner := "afsalthaj",
31-
micrositeGithubRepo := "safe-string-interpolation",
32-
micrositeGitterChannelUrl := "safe-string-interpolation/community",
33-
micrositePushSiteWith := GHPagesPlugin,
34-
micrositePalette := Map(
35-
"brand-primary" -> "#5B5988",
36-
"brand-secondary" -> "#292E53",
37-
"brand-tertiary" -> "#222749",
38-
"gray-dark" -> "#49494B",
39-
"gray" -> "#7B7B7E",
40-
"gray-light" -> "#E5E5E6",
41-
"gray-lighter" -> "#F4F3F4",
42-
"white-color" -> "#FFFFFF"),
43-
autoAPIMappings := true,
44-
ghpagesNoJekyll := false,
45-
fork in tut := true,
46-
git.remoteRepo := "https://github.com/afsalthaj/safe-string-interpolation.git",
47-
includeFilter in makeSite := "*.html" | "*.css" | "*.png" | "*.jpg" | "*.gif" | "*.js" | "*.swf" | "*.yml" | "*.md"
48-
)
4931

5032
micrositeCDNDirectives := CdnDirectives(
5133
jsList = List(
@@ -59,7 +41,6 @@ micrositeCDNDirectives := CdnDirectives(
5941
)
6042
)
6143

62-
6344
micrositeGithubOwner := "afsalthaj"
6445

6546
lazy val macros = (project in file("macros"))
@@ -129,3 +110,4 @@ lazy val rootBuildSettings = Seq(
129110
pomIncludeRepository := { _ => false },
130111
publishMavenStyle := true
131112
)
113+

docs/src/main/tut/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Easy ! Use `safeStr"your log $a $b, $c"` instead of `s"your log $a $b, $c"` !
2727
Add this in your build.sbt
2828

2929
```scala
30-
libraryDependencies += "io.github.afsalthaj" %% "safe-string" % "1.2.8"
30+
libraryDependencies += "io.github.afsalthaj" %% "safe-string" % "1.2.8"
3131
```
3232

3333
Or, in ammonite;

project/DocSupport.scala

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import com.typesafe.sbt.GitPlugin.autoImport.git
2+
import com.typesafe.sbt.sbtghpages.GhpagesPlugin.autoImport.ghpagesNoJekyll
3+
import microsites.MicrositesPlugin.autoImport._
4+
import sbt.Keys.{autoAPIMappings, fork, includeFilter, version}
5+
import sbt.{File, IO, taskKey}
6+
7+
object DocSupport {
8+
lazy val updateDoc = taskKey[Unit]("update versions in doc")
9+
10+
val settings = Seq(
11+
12+
updateDoc := {
13+
val string = IO.read(new File("docs/src/main/tut/index.md").getAbsoluteFile)
14+
val version1 =
15+
"\"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"))
16+
val version2 =
17+
"`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"))
18+
19+
val content =
20+
string.replace(version1, s""""io.github.afsalthaj" %% "safe-string" % "${version.value}" """).replace(version2, s"`io.github.afsalthaj::safe-string:${version.value}`")
21+
22+
IO.write(new File("docs/src/main/tut/index.md").getAbsoluteFile, content = content, append = false)
23+
24+
publishMicrosite.value
25+
},
26+
micrositeName := "Typesafe Interpolation",
27+
micrositeDescription := "Typesafe Interpolation",
28+
micrositeHighlightTheme := "atom-one-light",
29+
micrositeGithubRepo := "safe-string-interpolation",
30+
micrositeHomepage := "https://afsalthaj.github.io/safe-string-interpolation",
31+
micrositeBaseUrl := "/safe-string-interpolation",
32+
micrositeGithubOwner := "afsalthaj",
33+
micrositeGithubRepo := "safe-string-interpolation",
34+
micrositeGitterChannelUrl := "safe-string-interpolation/community",
35+
micrositePushSiteWith := GHPagesPlugin,
36+
micrositePalette := Map(
37+
"brand-primary" -> "#5B5988",
38+
"brand-secondary" -> "#292E53",
39+
"brand-tertiary" -> "#222749",
40+
"gray-dark" -> "#49494B",
41+
"gray" -> "#7B7B7E",
42+
"gray-light" -> "#E5E5E6",
43+
"gray-lighter" -> "#F4F3F4",
44+
"white-color" -> "#FFFFFF"),
45+
autoAPIMappings := true,
46+
ghpagesNoJekyll := false,
47+
)
48+
}

0 commit comments

Comments
 (0)