Skip to content

Commit

Permalink
Fetch Inkuire at scaladoc build instead of documentation generation
Browse files Browse the repository at this point in the history
  • Loading branch information
pikinier20 committed Aug 12, 2021
1 parent 31292be commit 5fd6ce7
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
19 changes: 19 additions & 0 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,25 @@ object Build {
sbt.IO.copyFile(cssSourceFile, cssDesitnationFile)
Seq(cssDesitnationFile)
}.taskValue,
Compile / resourceGenerators += Def.task {
import _root_.scala.sys.process._
import _root_.scala.concurrent._
import ExecutionContext.Implicits.global
val inkuireLink = "https://github.com/VirtusLab/Inkuire/releases/download/1.0.0-M2/inkuire.js"
val inkuireDestinationFile = (Compile / resourceManaged).value / "dotty_res" / "scripts" / "inkuire.js"
sbt.IO.touch(inkuireDestinationFile)
val downloadProcess = (new java.net.URL(inkuireLink) #> inkuireDestinationFile).run()
val result: Future[Int] = Future(blocking(downloadProcess.exitValue()))
val res = try {
Await.result(result, duration.Duration(20, "sec"))
} catch {
case _: TimeoutException =>
downloadProcess.destroy()
throw new MessageOnlyException(s"Failed to fetch inkuire.js from $inkuireLink: Download timeout")
}
if(res != 0) throw new MessageOnlyException(s"Failed to fetch inkuire.js from $inkuireLink: Error code $res")
Seq(inkuireDestinationFile)
}.taskValue,
libraryDependencies ++= Dependencies.flexmarkDeps ++ Seq(
"nl.big-o" % "liqp" % "0.6.7",
"org.jsoup" % "jsoup" % "1.13.1", // Needed to process .html files for static site
Expand Down
6 changes: 2 additions & 4 deletions scaladoc/src/dotty/tools/scaladoc/renderers/Resources.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:

val onlyRenderedResources: Seq[Resource] =
List(
("https://github.com/VirtusLab/Inkuire/releases/download/1.0.0-M2/inkuire.js", "scripts/inkuire.js"),
).map { case (url, path) =>
Resource.URLToCopy(url, path)
} ++
"scripts/inkuire.js"
).map(dottyRes) ++
List(
"scripts/inkuire-worker.js"
).map(dottyRes)
Expand Down

0 comments on commit 5fd6ce7

Please sign in to comment.