Skip to content

Commit 1e3b3cc

Browse files
committed
Scaladoc enhancement.
1 parent 8cfc56d commit 1e3b3cc

File tree

2 files changed

+137
-1
lines changed

2 files changed

+137
-1
lines changed

build.sbt

Lines changed: 37 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 := "selenium-3.141"
25

36
organization := "org.scalatestplus"
@@ -128,4 +131,37 @@ scalacOptions ++= {
128131
// Temporary disable publishing of doc in dotty, can't get it to build.
129132
publishArtifact in (Compile, packageDoc) := !scalaBinaryVersion.value.startsWith("3.")
130133

131-
scalacOptions in (Compile, doc) := Seq("-doc-title", s"ScalaTest + Selenium ${version.value}")
134+
def docTask(docDir: File, resDir: File, projectName: String): File = {
135+
val docLibDir = docDir / "lib"
136+
val htmlSrcDir = resDir / "html"
137+
val cssFile = docLibDir / "template.css"
138+
val addlCssFile = htmlSrcDir / "addl.css"
139+
140+
val css = Source.fromFile(cssFile).mkString
141+
val addlCss = Source.fromFile(addlCssFile).mkString
142+
143+
if (!css.contains("pre.stHighlighted")) {
144+
val writer = new PrintWriter(cssFile)
145+
146+
try {
147+
writer.println(css)
148+
writer.println(addlCss)
149+
}
150+
finally { writer.close }
151+
}
152+
153+
if (projectName.contains("scalatest")) {
154+
(htmlSrcDir * "*.gif").get.foreach { gif =>
155+
IO.copyFile(gif, docLibDir / gif.name)
156+
}
157+
}
158+
docDir
159+
}
160+
161+
doc in Compile := docTask((doc in Compile).value,
162+
(sourceDirectory in Compile).value,
163+
name.value)
164+
165+
scalacOptions in (Compile, doc) := Seq("-doc-title", s"ScalaTest + Selenium ${version.value}",
166+
"-sourcepath", baseDirectory.value.getAbsolutePath(),
167+
"-doc-source-url", s"https://github.com/scalatest/releases-source/blob/main/scalatestplus-selenium/${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)