Skip to content
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
2 changes: 1 addition & 1 deletion docs/blog/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ <h1>{{ page.title }}</h1>
{% for post in site.posts %}
<li>
<h2>
<a href="{{ site.baseurl }}{{ post.url }}">{{ post.title }}</a>
<a href="{{ post.url }}">{{ post.title }}</a>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was site.baseurl empty string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we do not expose such setting

</h2>
<div class="byline">
<time class="date">
Expand Down
7 changes: 6 additions & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1244,7 +1244,12 @@ object Build {
// TODO add versions etc.
def srcManaged(v: String, s: String) = s"out/bootstrap/stdlib-bootstrapped/scala-$v/src_managed/main/$s-library-src"
def scalaSrcLink(v: String, s: String) = s"-source-links:$s=github://scala/scala/v$v#src/library"
def dottySrcLink(v: String, s: String) = s"-source-links:$s=github://lampepfl/dotty/$v#library/src"
def dottySrcLink(v: String, s: String) =
sys.env.get("GITHUB_SHA") match {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this environment variables driven logic?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that we want to link to the source code that has been actually used for this PR, not the 3.0.0 sources. Before we tried to link to e.g. experimental.scala that that not exists in 3.0.0

case Some(sha) =>
s"-source-links:$s=github://${sys.env("GITHUB_REPOSITORY")}/$sha#library/src"
case None => s"-source-links:$s=github://lampepfl/dotty/$v#library/src"
}

val revision = Seq("-revision", ref, "-project-version", projectVersion)
val cmd = Seq(
Expand Down
17 changes: 10 additions & 7 deletions scaladoc/src/dotty/tools/scaladoc/site/StaticSiteContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,16 @@ class StaticSiteContext(
if link.startsWith("/") then root.toPath.resolve(link.drop(1))
else template.file.toPath.getParent().resolve(link).normalize()

baseFile.getFileName.toString.split("\\.").headOption.toSeq.flatMap { baseFileName =>
Seq(
Some(baseFile.resolveSibling(baseFileName + ".html")),
Some(baseFile.resolveSibling(baseFileName + ".md")),
Option.when(baseFileName == "index")(baseFile.getParent)
).flatten.filter(Files.exists(_)).map(driFor)
}
val fileName = baseFile.getFileName.toString
val baseFileName = if fileName.endsWith(".md")
then fileName.stripSuffix(".md")
else fileName.stripSuffix(".html")

Seq(
Some(baseFile.resolveSibling(baseFileName + ".html")),
Some(baseFile.resolveSibling(baseFileName + ".md")),
Option.when(baseFileName == "index")(baseFile.getParent)
).flatten.filter(Files.exists(_)).map(driFor)
}.toOption.filter(_.nonEmpty)
pathsDri.getOrElse(memberLinkResolver(link).toList)

Expand Down
14 changes: 14 additions & 0 deletions scaladoc/test-documentations/static-links/docs/Adoc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: Adoc
---
# Header in Adoc

[A link to](dir/html.md)
[A link to](dir/name...with..dots..md)
[A link to](dir/name.with.md.and.html.md)
[A link to](dir/nested.md)
[A link to](dir/nested.svg)



And a text!
5 changes: 5 additions & 0 deletions scaladoc/test-documentations/static-links/docs/dir/html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: html named file
---

And a text!
6 changes: 6 additions & 0 deletions scaladoc/test-documentations/static-links/docs/dir/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: A directory
---
# {{ page.title }}

And a text!
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Strange name multipke dots in nane
---

And a text!
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: name.with.md.and.html
---

And a text!
6 changes: 6 additions & 0 deletions scaladoc/test-documentations/static-links/docs/dir/nested.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
title: Nested in a directory
---
# {{ page.title }}

And a text!
54 changes: 54 additions & 0 deletions scaladoc/test-documentations/static-links/docs/dir/nested.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions scaladoc/test-documentations/static-links/docs/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# {{ page.title }} in header

And a text!
Loading