Skip to content

Commit 1f65377

Browse files
committed
Added docTask to append scalatest css to template.css.
1 parent a232199 commit 1f65377

File tree

2 files changed

+135
-1
lines changed

2 files changed

+135
-1
lines changed

build.sbt

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import java.io.PrintWriter
2+
import scala.io.Source
3+
14
name := "easymock-3.2"
25

36
organization := "org.scalatestplus"
@@ -103,6 +106,37 @@ credentials += Credentials(Path.userHome / ".ivy2" / ".credentials")
103106
// Temporary disable publishing of doc in dotty, can't get it to build.
104107
publishArtifact in (Compile, packageDoc) := !scalaBinaryVersion.value.startsWith("3.")
105108

109+
def docTask(docDir: File, resDir: File, projectName: String): File = {
110+
val docLibDir = docDir / "lib"
111+
val htmlSrcDir = resDir / "html"
112+
val cssFile = docLibDir / "template.css"
113+
val addlCssFile = htmlSrcDir / "addl.css"
114+
115+
val css = Source.fromFile(cssFile).mkString
116+
val addlCss = Source.fromFile(addlCssFile).mkString
117+
118+
if (!css.contains("pre.stHighlighted")) {
119+
val writer = new PrintWriter(cssFile)
120+
121+
try {
122+
writer.println(css)
123+
writer.println(addlCss)
124+
}
125+
finally { writer.close }
126+
}
127+
128+
if (projectName.contains("scalatest")) {
129+
(htmlSrcDir * "*.gif").get.foreach { gif =>
130+
IO.copyFile(gif, docLibDir / gif.name)
131+
}
132+
}
133+
docDir
134+
}
135+
136+
doc in Compile := docTask((doc in Compile).value,
137+
(sourceDirectory in Compile).value,
138+
name.value)
139+
106140
scalacOptions in (Compile, doc) := Seq("-doc-title", s"ScalaTest + EasyMock ${version.value}",
107141
"-sourcepath", baseDirectory.value.getAbsolutePath(),
108-
"-doc-source-url", s"https://github.com/scalatest/releases-source/blob/main/scalatestplus-easymock/${version.value}/€{FILE_PATH}.scala")
142+
"-doc-source-url", s"https://github.com/scalatest/releases-source/blob/main/scalatestplus-easymock/${version.value}€{FILE_PATH}.scala")

src/main/html/addl.css

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
2+
pre.stExamples {
3+
background-color: #1b3449;
4+
padding: 10px;
5+
color: white;
6+
}
7+
8+
pre.stREPL {
9+
background-color: #1b3449;
10+
padding: 10px;
11+
color: white;
12+
}
13+
14+
.stYellow {
15+
color: #cfc923;
16+
}
17+
18+
.stCyan {
19+
color: #00dddd;
20+
}
21+
22+
.stGreen {
23+
color: #00cc00;
24+
}
25+
26+
.stRed {
27+
color: #dd2233;
28+
}
29+
30+
pre.stHighlighted {
31+
font-family: "Lucida Console", Monaco, monospace;
32+
font-size: 95%;
33+
line-height: 110%;
34+
padding: 10px;
35+
background-color: #ecedec;
36+
color: black;
37+
text-align: left;
38+
}
39+
40+
pre.stGray {
41+
font-family: "Lucida Console", Monaco, monospace;
42+
font-size: 95%;
43+
line-height: 110%;
44+
padding: 10px;
45+
background-color: #ecedec;
46+
color: black;
47+
text-align: left;
48+
}
49+
50+
.stType {
51+
color: #418da7;
52+
}
53+
54+
.stLiteral {
55+
color: #2b875e;
56+
}
57+
58+
.stQuotedString {
59+
color: #2b875e;
60+
}
61+
62+
.stReserved {
63+
color: #00008b;
64+
}
65+
66+
.stBlockComment, .stLineComment {
67+
color: gray;
68+
font-style: italic;
69+
}
70+
71+
table.stTable {
72+
border-collapse: collapse;
73+
border: 1px solid black;
74+
}
75+
76+
th.stHeadingCell {
77+
background-color: #CCCCCC;
78+
border-width: 1px;
79+
padding: 3px;
80+
text-align: center;
81+
border: 1px solid black;
82+
}
83+
84+
td.stTableCell {
85+
border-width: 1px;
86+
padding: 3px;
87+
text-align: center;
88+
border: 1px solid black;
89+
}
90+
91+
td.usage {
92+
background-color: #EEEEEE;
93+
border-width: 1px;
94+
padding: 0.5em;
95+
border: 1px solid black;
96+
}
97+
98+
img.stScreenShot {
99+
border:1px solid #333;
100+
}

0 commit comments

Comments
 (0)