Skip to content

Commit 8c43294

Browse files
committed
Fix building docs.scala-lang using scaladoc
1 parent 07290ba commit 8c43294

File tree

7 files changed

+36
-35
lines changed

7 files changed

+36
-35
lines changed

docs/docs/reference/.Rhistory

Whitespace-only changes.

docs/docs/reference/changed-features/.Rhistory

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
<script src="{{ site.baseurl }}/scripts/scaladoc-scalajs.js" type="text/javascript"></script>
3+
<link rel="stylesheet" href="{{ site.baseurl }}/resources/css/colors.css" type="text/css" />
4+
<link rel="stylesheet" href="{{ site.baseurl }}/resources/css/code-snippets.css" type="text/css" />
5+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css">

project/Build.scala

+21-9
Original file line numberDiff line numberDiff line change
@@ -1245,7 +1245,7 @@ object Build {
12451245
// Note: the two tasks below should be one, but a bug in Tasty prevents that
12461246
val generateScalaDocumentation = inputKey[Unit]("Generate documentation for dotty lib")
12471247
val generateTestcasesDocumentation = taskKey[Unit]("Generate documentation for testcases, usefull for debugging tests")
1248-
val copyTheScaladocJsOutput = inputKey[Unit]("Copy the output of the scaladoc js files")
1248+
val renderScaladocScalajsToFile = inputKey[Unit]("Copy the output of the scaladoc js files")
12491249

12501250
lazy val `scaladoc-testcases` = project.in(file("scaladoc-testcases")).
12511251
dependsOn(`scala3-compiler-bootstrapped`).
@@ -1312,15 +1312,17 @@ object Build {
13121312
).
13131313
settings(
13141314
Compile / resourceGenerators += Def.task {
1315-
val jsDestinationFile = (Compile / resourceManaged).value / "dotty_res" / "scripts" / "searchbar.js"
1315+
val jsDestinationFile = (Compile / resourceManaged).value / "dotty_res" / "scripts" / "scaladoc-scalajs.js"
13161316
sbt.IO.copyFile((`scaladoc-js` / Compile / fullOptJS).value.data, jsDestinationFile)
13171317
Seq(jsDestinationFile)
13181318
}.taskValue,
13191319
Compile / resourceGenerators += Def.task {
1320-
val cssDesitnationFile = (Compile / resourceManaged).value / "dotty_res" / "styles" / "scaladoc-searchbar.css"
1321-
val cssSourceFile = (`scaladoc-js` / Compile / resourceDirectory).value / "scaladoc-searchbar.css"
1322-
sbt.IO.copyFile(cssSourceFile, cssDesitnationFile)
1323-
Seq(cssDesitnationFile)
1320+
Seq("code-snippets.css", "searchbar.css", "social-links.css", "ux.css", "versions-dropdown.css").map { file =>
1321+
val cssDesitnationFile = (Compile / resourceManaged).value / "dotty_res" / "styles" / file
1322+
val cssSourceFile = (`scaladoc-js` / Compile / resourceDirectory).value / file
1323+
sbt.IO.copyFile(cssSourceFile, cssDesitnationFile)
1324+
cssDesitnationFile
1325+
}
13241326
}.taskValue,
13251327
libraryDependencies ++= Dependencies.flexmarkDeps ++ Seq(
13261328
"nl.big-o" % "liqp" % "0.6.7",
@@ -1402,11 +1404,21 @@ object Build {
14021404
)
14031405
}.value,
14041406

1405-
copyTheScaladocJsOutput := Def.inputTask {
1407+
renderScaladocScalajsToFile := Def.inputTask {
14061408
val extraArgs = spaceDelimited("<arg>").parsed
1407-
val dest = extraArgs.lift(0).getOrElse("output")
1408-
val jsDestinationFile: File = Paths.get(dest).toFile
1409+
val (destJS, destCSS, csses) = extraArgs match {
1410+
case js :: css :: tail => (js, css, tail)
1411+
case js :: Nil => (js, "", Nil)
1412+
case _ => throw new IllegalArgumentException("No js destination provided")
1413+
}
1414+
val jsDestinationFile: File = Paths.get(destJS).toFile
14091415
sbt.IO.copyFile((`scaladoc-js` / Compile / fullOptJS).value.data, jsDestinationFile)
1416+
csses.map { file =>
1417+
val cssDesitnationFile = Paths.get(destCSS).toFile / file
1418+
val cssSourceFile = (`scaladoc-js` / Compile / resourceDirectory).value / file
1419+
sbt.IO.copyFile(cssSourceFile, cssDesitnationFile)
1420+
cssDesitnationFile
1421+
}
14101422
}.evaluated,
14111423

14121424
Test / buildInfoKeys := Seq[BuildInfoKey](

project/scripts/genDocsScalaLang

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ git clone "https://github.com/scala/docs.scala-lang.git" $DOCS_SCALA_LANG_DIR
1818

1919
SBT="$SCRIPT_DIR/sbt"
2020
mkdir -pv $SITE_OUT_DIR
21-
env "scaladoc.projectFormat=md" "$SBT" "scaladoc/copyTheScaladocJsOutput $DOCS_SCALA_LANG_DIR/scripts/searchbar.js"
21+
env "scaladoc.projectFormat=md" "$SBT" "scaladoc/renderScaladocScalajsToFile $DOCS_SCALA_LANG_DIR/scripts/scaladoc-scalajs.js $DOCS_SCALA_LANG_DIR/resources/css code-snippets.css"
2222
"dist/target/pack/bin/scaladoc" "-d" "$SITE_OUT_DIR" "-format" "md" "-siteroot" "docs" "/dev/null"
2323

2424
if [ ! -d "$SITE_OUT_DIR" ]; then
@@ -27,5 +27,6 @@ if [ ! -d "$SITE_OUT_DIR" ]; then
2727
fi
2828

2929
cp -rf "$SITE_OUT_DIR/docs/reference"/* "$DOCS_SCALA_LANG_DIR/_scala3-reference"
30-
cp -f "$SITE_OUT_DIR/resources/my.css" "$DOCS_SCALA_LANG_DIR/scripts/my.css"
31-
cp -f "$SITE_OUT_DIR/resources/footer.html" "$DOCS_SCALA_LANG_DIR/_includes/footer.html"
30+
cp -f "$SITE_OUT_DIR/styles/colors.css" "$DOCS_SCALA_LANG_DIR/resources/css/colors.css"
31+
cp -f "$PWD/docs/docsScalaLangResources/scaladoc-assets.html" "$DOCS_SCALA_LANG_DIR/_includes/scaladoc-assets.html"
32+
echo "{% include scaladoc-assets.html %}" >> "$DOCS_SCALA_LANG_DIR/_layouts/inner-page-parent-dropdown.html"

scaladoc/src/dotty/tools/scaladoc/renderers/MarkdownRenderer.scala

-20
Original file line numberDiff line numberDiff line change
@@ -25,24 +25,4 @@ class MarkdownRenderer(rootPackage: Member, members: Map[DRI, Member])(using ctx
2525
renderContent(page)
2626

2727
private def renderResources(): Seq[String] =
28-
29-
// TODO REMOVE THIS CODE AND RESOURCES UNDER docs/resources
30-
// when we sort out the css classes
31-
def siteRoot = staticSite.get.root.toPath
32-
def pathToResource(p: String) = Resource.File(p, siteRoot.resolve(p))
33-
34-
def harvestResources(path: String) =
35-
val siteImgPath = siteRoot.resolve(path)
36-
if !Files.exists(siteImgPath) then Nil
37-
else
38-
val allPaths = Files.walk(siteImgPath, FileVisitOption.FOLLOW_LINKS)
39-
val files = allPaths.filter(Files.isRegularFile(_)).iterator().asScala
40-
files.map(p => siteRoot.relativize(p).toString).toList
41-
42-
val staticResources = staticSite.toSeq.flatMap { _ =>
43-
harvestResources("images") ++ harvestResources("resources")
44-
}
45-
staticResources.map(pathToResource).flatMap(renderResource)
46-
// END TODO REMOVE THIS CODE AND RESOURCES UNDER docs/resources
47-
4828
allResources(Nil).flatMap(renderResource)

scaladoc/src/dotty/tools/scaladoc/renderers/Resources.scala

+6-3
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,11 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
7575
"styles/dotty-icons.css",
7676
"styles/diagram.css",
7777
"styles/filter-bar.css",
78-
"styles/search-bar.css",
79-
"styles/scaladoc-searchbar.css",
78+
"styles/code-snippets.css",
79+
"styles/searchbar.css",
80+
"styles/social-links.css",
81+
"styles/ux.css",
82+
"styles/versions-dropdown.css",
8083
"hljs/highlight.pack.js",
8184
"hljs/LICENSE",
8285
"scripts/hljs-scala3.js",
@@ -88,7 +91,7 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
8891
"scripts/components/Input.js",
8992
"scripts/components/FilterGroup.js",
9093
"scripts/components/Filter.js",
91-
"scripts/searchbar.js"
94+
"scripts/scaladoc-scalajs.js"
9295
).map(dottyRes)
9396

9497
val urls = List(

0 commit comments

Comments
 (0)