Skip to content

Scaladoc: Stop attaching inkuire scripts to html #13242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion scaladoc/src/dotty/tools/scaladoc/Inkuire.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ object Inkuire {
}

def generateInkuireConfig(externalMappings: Seq[String]): String = {
val paths = ("../inkuire-db.json" +: externalMappings.map(_ + "../inkuire-db.json")).map(jsonString)
val paths =
List("../inkuire-db.json").map(jsonString)
// TODO: #13243
// ++ externalMappings.map(_ + "../inkuire-db.json")).map(jsonString)
jsonObject(("inkuirePaths", jsonList(paths))).toString
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class HtmlRenderer(rootPackage: Member, val members: Map[DRI, Member])(using ctx

val siteResourcesPaths = allPages.toSet.flatMap(specificResources) ++ staticResources

val resources = siteResourcesPaths.toSeq.map(pathToResource) ++ allResources(allPages)
val resources = siteResourcesPaths.toSeq.map(pathToResource) ++ allResources(allPages) ++ onlyRenderedResources
resources.flatMap(renderResource)

def render(): Unit =
Expand Down
20 changes: 12 additions & 8 deletions scaladoc/src/dotty/tools/scaladoc/renderers/Resources.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
case "js" => script(`type` := "text/javascript", src := resolveLink(dri, res), if (deferJs) Seq(defer := "true") else Nil)
case _ => raw("")

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)
} ++
List(
"scripts/inkuire-worker.js"
).map(dottyRes)

val earlyMemberResources: Seq[Resource] =
List(
"scripts/theme.js"
Expand All @@ -78,8 +88,7 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
"scripts/components/Input.js",
"scripts/components/FilterGroup.js",
"scripts/components/Filter.js",
"scripts/searchbar.js",
"scripts/inkuire-worker.js"
"scripts/searchbar.js"
).map(dottyRes)

val urls = List(
Expand All @@ -90,13 +99,8 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
"https://cdnjs.cloudflare.com/ajax/libs/dagre-d3/0.6.1/dagre-d3.min.js",
).map(Resource.URL.apply)

val urlToPathMappings = 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)
}

fromResources ++ urls ++ urlToPathMappings ++ projectLogo ++ Seq(scaladocVersionFile, dynamicJsData)
fromResources ++ urls ++ projectLogo ++ Seq(scaladocVersionFile, dynamicJsData)

val searchDataPath = "scripts/searchData.js"
val memberResourcesPaths = Seq(searchDataPath) ++ memberResources.map(_.path)
Expand Down