Skip to content

Commit 8530e26

Browse files
committed
Add separate styles for api and static site
1 parent 594043f commit 8530e26

File tree

4 files changed

+56
-40
lines changed

4 files changed

+56
-40
lines changed

scaladoc/resources/dotty_res/styles/apistyles.css

Whitespace-only changes.

scaladoc/resources/dotty_res/styles/staticsitestyles.css

Whitespace-only changes.

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ class HtmlRenderer(rootPackage: Member, members: Map[DRI, Member])(using ctx: Do
5959
def mkHead(page: Page): AppliedTag =
6060
val resources = page.content match
6161
case t: ResolvedTemplate =>
62-
t.resolved.resources ++ (if t.hasFrame then memberResourcesPaths else Nil)
62+
t.resolved.resources ++ (if t.hasFrame then commonResourcesPaths ++ staticSiteOnlyResourcesPaths else Nil)
6363
case _ =>
64-
memberResourcesPaths
64+
commonResourcesPaths ++ apiOnlyResourcesPaths
6565

6666
val earlyResources = page.content match
67-
case t: ResolvedTemplate => if t.hasFrame then earlyMemberResourcePaths else Nil
68-
case _ => earlyMemberResourcePaths
67+
case t: ResolvedTemplate => if t.hasFrame then earlyCommonResourcePaths else Nil
68+
case _ => earlyCommonResourcePaths
6969

7070
head(
7171
meta(charset := "utf-8"),

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

Lines changed: 52 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,12 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
7575
).map(dottyRes)
7676

7777

78-
val earlyMemberResources: Seq[Resource] =
78+
val earlyCommonResources: Seq[Resource] =
7979
List(
8080
"scripts/theme.js"
8181
).map(dottyRes)
8282

83-
val memberResources: Seq[Resource] =
83+
val commonResources: Seq[Resource] = {
8484
val fromResources = List(
8585
"styles/nord-light.css",
8686
"styles/scalastyle.css",
@@ -116,13 +116,24 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
116116
"https://scastie.scala-lang.org/embedded.js"
117117
).map(Resource.URL.apply)
118118

119-
120119
fromResources ++ urls ++ projectLogo ++ Seq(scaladocVersionFile, dynamicJsData)
120+
}
121+
122+
val apiOnlyResources = List(
123+
"styles/apistyles.css"
124+
).map(dottyRes)
125+
126+
val staticSiteOnlyResources = List(
127+
"styles/staticsitestyles.css"
128+
).map(dottyRes)
121129

122130
val searchDataPath = "scripts/searchData.js"
123131
val scastieConfigurationPath = "scripts/scastieConfiguration.js"
124-
val memberResourcesPaths = Seq(searchDataPath) ++ Seq(scastieConfigurationPath) ++ memberResources.map(_.path)
125-
val earlyMemberResourcePaths = earlyMemberResources.map(_.path)
132+
val commonResourcesPaths = Seq(searchDataPath) ++ Seq(scastieConfigurationPath) ++ commonResources.map(_.path)
133+
val earlyCommonResourcePaths = earlyCommonResources.map(_.path)
134+
135+
val apiOnlyResourcesPaths: Seq[String] = apiOnlyResources.map(_.path)
136+
val staticSiteOnlyResourcesPaths: Seq[String] = staticSiteOnlyResources.map(_.path)
126137

127138
def searchData(pages: Seq[Page]) =
128139
def flattenToText(signature: Signature): String =
@@ -168,37 +179,42 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
168179
}"""")
169180

170181

171-
def allResources(pages: Seq[Page]): Seq[Resource] = earlyMemberResources ++ memberResources ++ Seq(
172-
dottyRes("favicon.ico"),
173-
dottyRes("fonts/dotty-icons.woff"),
174-
dottyRes("fonts/dotty-icons.ttf"),
175-
dottyRes("images/scaladoc_logo.svg"),
176-
dottyRes("images/scaladoc_logo_dark.svg"),
177-
dottyRes("images/class.svg"),
178-
dottyRes("images/class_comp.svg"),
179-
dottyRes("images/object.svg"),
180-
dottyRes("images/object_comp.svg"),
181-
dottyRes("images/trait.svg"),
182-
dottyRes("images/trait_comp.svg"),
183-
dottyRes("images/enum.svg"),
184-
dottyRes("images/enum_comp.svg"),
185-
dottyRes("images/given.svg"),
186-
dottyRes("images/method.svg"),
187-
dottyRes("images/type.svg"),
188-
dottyRes("images/val.svg"),
189-
dottyRes("images/package.svg"),
190-
dottyRes("images/static.svg"),
191-
dottyRes("images/github-icon-black.png"),
192-
dottyRes("images/github-icon-white.png"),
193-
dottyRes("images/discord-icon-black.png"),
194-
dottyRes("images/discord-icon-white.png"),
195-
dottyRes("images/twitter-icon-black.png"),
196-
dottyRes("images/twitter-icon-white.png"),
197-
dottyRes("images/gitter-icon-black.png"),
198-
dottyRes("images/gitter-icon-white.png"),
199-
searchData(pages),
200-
scastieConfiguration(),
201-
)
182+
def allResources(pages: Seq[Page]): Seq[Resource] =
183+
earlyCommonResources ++
184+
commonResources ++
185+
apiOnlyResources ++
186+
staticSiteOnlyResources ++
187+
Seq(
188+
dottyRes("favicon.ico"),
189+
dottyRes("fonts/dotty-icons.woff"),
190+
dottyRes("fonts/dotty-icons.ttf"),
191+
dottyRes("images/scaladoc_logo.svg"),
192+
dottyRes("images/scaladoc_logo_dark.svg"),
193+
dottyRes("images/class.svg"),
194+
dottyRes("images/class_comp.svg"),
195+
dottyRes("images/object.svg"),
196+
dottyRes("images/object_comp.svg"),
197+
dottyRes("images/trait.svg"),
198+
dottyRes("images/trait_comp.svg"),
199+
dottyRes("images/enum.svg"),
200+
dottyRes("images/enum_comp.svg"),
201+
dottyRes("images/given.svg"),
202+
dottyRes("images/method.svg"),
203+
dottyRes("images/type.svg"),
204+
dottyRes("images/val.svg"),
205+
dottyRes("images/package.svg"),
206+
dottyRes("images/static.svg"),
207+
dottyRes("images/github-icon-black.png"),
208+
dottyRes("images/github-icon-white.png"),
209+
dottyRes("images/discord-icon-black.png"),
210+
dottyRes("images/discord-icon-white.png"),
211+
dottyRes("images/twitter-icon-black.png"),
212+
dottyRes("images/twitter-icon-white.png"),
213+
dottyRes("images/gitter-icon-black.png"),
214+
dottyRes("images/gitter-icon-white.png"),
215+
searchData(pages),
216+
scastieConfiguration(),
217+
)
202218

203219
def renderResource(resource: Resource): Seq[String] =
204220
val normalizedPath = resource.path.replace('\\', '/')

0 commit comments

Comments
 (0)