Skip to content

Commit bccf00d

Browse files
committed
Add separate styles for api and static site
1 parent 3d1d299 commit bccf00d

File tree

4 files changed

+57
-41
lines changed

4 files changed

+57
-41
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: 53 additions & 37 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 =
@@ -169,38 +180,43 @@ trait Resources(using ctx: DocContext) extends Locations, Writer:
169180
}"""")
170181

171182

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

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

0 commit comments

Comments
 (0)