Skip to content

Commit 2cb4280

Browse files
committed
Fix tests
1 parent 40d16d0 commit 2cb4280

File tree

9 files changed

+75
-68
lines changed

9 files changed

+75
-68
lines changed

docs/_layouts/blog-page.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: main
2+
layout: static-site-main
33
---
44
<main>
55
<header>

docs/_layouts/doc-page.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
---
2-
layout: main
2+
layout: static-site-main
33
---
44
<main>
55
<header>
66
<h1>{{ page.title }}</h1>
7+
{% if urls.editSource %}
78
<div class="byline">
89
<a href="{{ urls.editSource }}">
9-
<i class="far fa-edit"></i>
10-
Edit this page on GitHub
11-
</a>
10+
<i class="far fa-edit"></i>
11+
Edit this page on GitHub
12+
</a>
1213
</div>
14+
{% endif %}
1315
</header>
1416
{{ content }}
1517
<div class="content-contributors hidden">

docs/_layouts/main.html

Lines changed: 1 addition & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2,47 +2,7 @@
22
layout: base
33
---
44
<div id="content-wrapper">
5-
<div class="container">
6-
<div id="site-header">
7-
<div class="wrap">
8-
<nav class="navigation" role="menu">
9-
<ul class="navigation-menu">
10-
<li class="navigation-menu-item">
11-
<a href="/" class="active">Documentation</a>
12-
</li>
13-
<li class="navigation-menu-item">
14-
<a href="https://www.scala-lang.org/download/">Download</a>
15-
</li>
16-
<li class="navigation-menu-item">
17-
<a href="https://www.scala-lang.org/community/">Community</a>
18-
</li>
19-
<li class="navigation-menu-item">
20-
<a href="https://index.scala-lang.org">Libraries</a>
21-
</li>
22-
<li class="navigation-menu-item">
23-
<a href="https://www.scala-lang.org/contribute/">Contribute</a>
24-
</li>
25-
<li class="navigation-menu-item">
26-
<a href="https://www.scala-lang.org/blog/">Blog</a>
27-
</li>
28-
</ul>
29-
</nav>
30-
</div>
31-
</div>
32-
{{ content }}
33-
<nav class="arrows-wrapper" aria-label="Page navigation">
34-
{% if page.previous %}
35-
<a rel="prev" href="{{ page.previous }}" class="arrows previous" aria-keyshortcuts="Left">
36-
<i class="fa fa-angle-left"></i>
37-
</a>
38-
{% endif %}
39-
{% if page.next %}
40-
<a rel="next" href="{{ page.next }}" class="arrows next" aria-keyshortcuts="Right">
41-
<i class="fa fa-angle-right"></i>
42-
</a>
43-
{% endif %}
44-
</nav>
45-
</div>
5+
{{ content }}
466
</div>
477
<script>
488
((window.gitter = {}).chat = {}).options = {

docs/_layouts/static-site-main.html

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
---
2+
layout: main
3+
---
4+
<div class="container">
5+
<div id="site-header">
6+
<div class="wrap">
7+
<nav class="navigation" role="menu">
8+
<ul class="navigation-menu">
9+
<li class="navigation-menu-item">
10+
<a href="/" class="active">Documentation</a>
11+
</li>
12+
<li class="navigation-menu-item">
13+
<a href="https://www.scala-lang.org/download/">Download</a>
14+
</li>
15+
<li class="navigation-menu-item">
16+
<a href="https://www.scala-lang.org/community/">Community</a>
17+
</li>
18+
<li class="navigation-menu-item">
19+
<a href="https://index.scala-lang.org">Libraries</a>
20+
</li>
21+
<li class="navigation-menu-item">
22+
<a href="https://www.scala-lang.org/contribute/">Contribute</a>
23+
</li>
24+
<li class="navigation-menu-item">
25+
<a href="https://www.scala-lang.org/blog/">Blog</a>
26+
</li>
27+
</ul>
28+
</nav>
29+
</div>
30+
</div>
31+
{{ content }}
32+
<nav class="arrows-wrapper" aria-label="Page navigation">
33+
{% if page.previous %}
34+
<a rel="prev" href="{{ page.previous }}" class="arrows previous" aria-keyshortcuts="Left">
35+
<i class="fa fa-angle-left"></i>
36+
</a>
37+
{% endif %}
38+
{% if page.next %}
39+
<a rel="next" href="{{ page.next }}" class="arrows next" aria-keyshortcuts="Right">
40+
<i class="fa fa-angle-right"></i>
41+
</a>
42+
{% endif %}
43+
</nav>
44+
</div>

docs/blog/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
layout: main
2+
layout: static-site-main
33
title: Blog
44
---
55
<main class="container">

scaladoc-js/src/content-contributors/ContentContributors.scala

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,24 +54,23 @@ class ContentContributors:
5454
case author =>
5555
FullAuthor(author.login, author.html_url, author.avatar_url)
5656
}.distinct
57-
58-
val div = document.getElementById("documentation-contributors")
59-
60-
authors.foreach { case FullAuthor(name, url, img) =>
61-
val divN = document.createElement("div")
62-
val imgN = document.createElement("img").asInstanceOf[html.Image]
63-
imgN.src = img
64-
val autN = document.createElement("a").asInstanceOf[html.Anchor]
65-
autN.href = url
66-
autN.text = name
67-
divN.appendChild(imgN)
68-
divN.appendChild(autN)
69-
div.appendChild(divN)
57+
val maybeDiv = Option(document.getElementById("documentation-contributors"))
58+
maybeDiv.foreach { div =>
59+
authors.foreach { case FullAuthor(name, url, img) =>
60+
val divN = document.createElement("div")
61+
val imgN = document.createElement("img").asInstanceOf[html.Image]
62+
imgN.src = img
63+
val autN = document.createElement("a").asInstanceOf[html.Anchor]
64+
autN.href = url
65+
autN.text = name
66+
divN.appendChild(imgN)
67+
divN.appendChild(autN)
68+
div.appendChild(divN)
69+
}
70+
71+
if authors.nonEmpty then
72+
div.asInstanceOf[html.Div].parentElement.classList.toggle("hidden")
7073
}
71-
72-
if authors.nonEmpty then
73-
div.asInstanceOf[html.Div].parentElement.classList.toggle("hidden")
74-
7574
case Failure(_) =>
7675
println(s"Couldn't fetch contributors for ${Globals.githubContributorsUrl}")
7776
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ abstract class Renderer(rootPackage: Member, val members: Map[DRI, Member], prot
5656

5757
// Let's gather the list of maps for each template with its in-order neighbours
5858
val newSettings: Seq[Map[String, Object]] = allTemplates.sliding(size = 3, step = 1).map {
59+
case None :: None :: Nil =>
60+
Map.empty
5961
case prev :: mid :: next :: Nil =>
6062
def link(sibling: Option[LoadedTemplate]): Option[String] =
6163
def realPath(path: Path) = if Files.isDirectory(path) then Paths.get(path.toString, "index.html") else path
@@ -74,7 +76,7 @@ abstract class Renderer(rootPackage: Member, val members: Map[DRI, Member], prot
7476
updateSettings(template, aS)
7577
}.unzip
7678
val newLoadedTemplate = template.copy(
77-
templateFile = template.templateFile.copy(settings = template.templateFile.settings.updated("page", head ++ template.templateFile.settings("page").asInstanceOf[Map[String, Object]])),
79+
templateFile = template.templateFile.copy(settings = template.templateFile.settings.updated("page", head ++ template.templateFile.settings.getOrElse("page", Map.empty).asInstanceOf[Map[String, Object]])),
7880
children = newChildren.drop(1) // We drop trailing null from the first `scanLeft` output collection
7981
)
8082

scaladoc/src/dotty/tools/scaladoc/site/StaticSiteContext.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class StaticSiteContext(
7676
t +: t.children.flatMap(doFlatten)
7777
val mainFiles = templates.flatMap(doFlatten)
7878
mainFiles.flatMap { loadedTemplate =>
79-
loadedTemplate.templateFile.settings.apply("page").asInstanceOf[Map[String, Object]].get("redirectFrom").map { case redirectFrom: String =>
79+
loadedTemplate.templateFile.settings.getOrElse("page", Map.empty).asInstanceOf[Map[String, Object]].get("redirectFrom").map { case redirectFrom: String =>
8080
val fakeFile = new File(docsPath.toFile, redirectFrom)
8181
val redirectTo = fakeFile.toPath.getParent.relativize(loadedTemplate.file.toPath).toString.stripSuffix(".md") + ".html"
8282
LoadedTemplate(layouts("redirectFrom").copy(settings = layouts("redirectFrom").settings ++ Map("redirectTo" -> redirectTo)), List.empty, fakeFile)
@@ -103,7 +103,7 @@ class StaticSiteContext(
103103
val indexFiles = from.listFiles { file => file.getName == "index.md" || file.getName == "index.html" }
104104
indexes match
105105
case Nil => emptyTemplate(from, from.getName)
106-
case Seq(loadedTemplate) => loadedTemplate.templateFile
106+
case Seq(loadedTemplate) => loadedTemplate.templateFile.copy(file = from)
107107
case _ =>
108108
// TODO (https://github.com/lampepfl/scaladoc/issues/238): provide proper error handling
109109
val msg = s"ERROR: Multiple index pages for $from found in ${indexes.map(_.file)}"

scaladoc/test/dotty/tools/scaladoc/ReportingTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,4 @@ class ReportingTest:
8484
.foreach( word =>
8585
Assert.assertTrue(s"Error message: $msg should contains $word", msg.contains(word))
8686
)
87-
}
87+
}

0 commit comments

Comments
 (0)