Skip to content

Commit aa9d526

Browse files
authored
Merge pull request #12819 from romanowski/scaladoc/fix-sourcelinks
Search for name in range of lines and add flexible sourcelinks
2 parents b7aae46 + 5938e7d commit aa9d526

File tree

15 files changed

+180
-14
lines changed

15 files changed

+180
-14
lines changed

docs/blog/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h1>{{ page.title }}</h1>
99
{% for post in site.posts %}
1010
<li>
1111
<h2>
12-
<a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a>
12+
<a href="{{ post.url }}">{{ post.title }}</a>
1313
</h2>
1414
<div class="byline">
1515
<time class="date">

project/Build.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1244,7 +1244,12 @@ object Build {
12441244
// TODO add versions etc.
12451245
def srcManaged(v: String, s: String) = s"out/bootstrap/stdlib-bootstrapped/scala-$v/src_managed/main/$s-library-src"
12461246
def scalaSrcLink(v: String, s: String) = s"-source-links:$s=github://scala/scala/v$v#src/library"
1247-
def dottySrcLink(v: String, s: String) = s"-source-links:$s=github://lampepfl/dotty/$v#library/src"
1247+
def dottySrcLink(v: String, s: String) =
1248+
sys.env.get("GITHUB_SHA") match {
1249+
case Some(sha) =>
1250+
s"-source-links:$s=github://${sys.env("GITHUB_REPOSITORY")}/$sha#library/src"
1251+
case None => s"-source-links:$s=github://lampepfl/dotty/$v#library/src"
1252+
}
12481253

12491254
val revision = Seq("-revision", ref, "-project-version", projectVersion)
12501255
val cmd = Seq(

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,16 @@ class StaticSiteContext(
148148
if link.startsWith("/") then root.toPath.resolve(link.drop(1))
149149
else template.file.toPath.getParent().resolve(link).normalize()
150150

151-
baseFile.getFileName.toString.split("\\.").headOption.toSeq.flatMap { baseFileName =>
152-
Seq(
153-
Some(baseFile.resolveSibling(baseFileName + ".html")),
154-
Some(baseFile.resolveSibling(baseFileName + ".md")),
155-
Option.when(baseFileName == "index")(baseFile.getParent)
156-
).flatten.filter(Files.exists(_)).map(driFor)
157-
}
151+
val fileName = baseFile.getFileName.toString
152+
val baseFileName = if fileName.endsWith(".md")
153+
then fileName.stripSuffix(".md")
154+
else fileName.stripSuffix(".html")
155+
156+
Seq(
157+
Some(baseFile.resolveSibling(baseFileName + ".html")),
158+
Some(baseFile.resolveSibling(baseFileName + ".md")),
159+
Option.when(baseFileName == "index")(baseFile.getParent)
160+
).flatten.filter(Files.exists(_)).map(driFor)
158161
}.toOption.filter(_.nonEmpty)
159162
pathsDri.getOrElse(memberLinkResolver(link).toList)
160163

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
title: Adoc
3+
---
4+
# Header in Adoc
5+
6+
[A link to](dir/html.md)
7+
[A link to](dir/name...with..dots..md)
8+
[A link to](dir/name.with.md.and.html.md)
9+
[A link to](dir/nested.md)
10+
[A link to](dir/nested.svg)
11+
12+
13+
14+
And a text!
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: html named file
3+
---
4+
5+
And a text!
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: A directory
3+
---
4+
# {{ page.title }}
5+
6+
And a text!
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: Strange name multipke dots in nane
3+
---
4+
5+
And a text!
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
title: name.with.md.and.html
3+
---
4+
5+
And a text!
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
title: Nested in a directory
3+
---
4+
# {{ page.title }}
5+
6+
And a text!
Lines changed: 54 additions & 0 deletions
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# {{ page.title }} in header
2+
3+
And a text!

0 commit comments

Comments
 (0)