Skip to content

Commit 3fc60e4

Browse files
authored
Merge pull request #12926 from BarkingBad/scaladoc/remove-bootstrap
Fix various small bugs in scaladoc
2 parents 359881d + d39736f commit 3fc60e4

File tree

8 files changed

+16
-17
lines changed

8 files changed

+16
-17
lines changed

docs/docs/usage/scaladoc/site-versioning.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ doc / scalacOptions ++= Seq("-versions-dictionary-url", "https://dotty.epfl.ch/v
3333

3434
Providing a JSON file via `-versions-dictionary-url` enables scaladoc to link between versions. It is also convenient to be able to change the revision label in the drop-down menu. Everything will change automatically.
3535

36-
![](../../../images/scaladoc/nightly.gif)
36+
![](images/scaladoc/nightly.gif)

scaladoc/resources/dotty_res/styles/scalastyle.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ th {
163163
#logo>span>img {
164164
max-height: 40px;
165165
max-width: 40px;
166-
padding: 16px 8px 8px 16px;
166+
margin: 16px 8px 8px 16px;
167167
cursor: pointer;
168168
}
169169

@@ -1011,4 +1011,4 @@ footer .socials {
10111011

10121012
.breadcrumbs a:first-child {
10131013
margin: 0 8px 0 0;
1014-
}
1014+
}

scaladoc/src/dotty/tools/scaladoc/SourceLinks.scala

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ def pathToString(p: Path) =
1212

1313
trait SourceLink:
1414
val path: Option[Path] = None
15-
def render(memberName: String, path: Path, operation: String, line: Option[Int]): String
15+
def render(memberName: String, path: Path, operation: String, line: Option[Int], optionalRevision: Option[String]): String
1616

1717
case class TemplateSourceLink(val urlTemplate: String) extends SourceLink:
1818
override val path: Option[Path] = None
19-
override def render(memberName: String, path: Path, operation: String, line: Option[Int]): String =
19+
override def render(memberName: String, path: Path, operation: String, line: Option[Int], optionalRevision: Option[String]): String =
2020
val pathString = "/" + pathToString(path)
2121
val mapping = Map(
2222
"\\{\\{ path \\}\\}".r -> pathString,
@@ -36,10 +36,11 @@ case class TemplateSourceLink(val urlTemplate: String) extends SourceLink:
3636

3737
case class WebBasedSourceLink(prefix: String, revision: String, subPath: String) extends SourceLink:
3838
override val path: Option[Path] = None
39-
override def render(memberName: String, path: Path, operation: String, line: Option[Int]): String =
39+
override def render(memberName: String, path: Path, operation: String, line: Option[Int], optionalRevision: Option[String] = None): String =
4040
val action = if operation == "view" then "blob" else operation
41+
val finalRevision = optionalRevision.getOrElse(revision)
4142
val linePart = line.fold("")(l => s"#L$l")
42-
s"$prefix/$action/$revision$subPath/${pathToString(path)}$linePart"
43+
s"$prefix/$action/$finalRevision$subPath/${pathToString(path)}$linePart"
4344

4445
class SourceLinkParser(revision: Option[String]) extends ArgParser[SourceLink]:
4546
val KnownProvider = raw"(\w+):\/\/([^\/#]+)\/([^\/#]+)(\/[^\/#]+)?(#.+)?".r
@@ -97,8 +98,8 @@ class SourceLinkParser(revision: Option[String]) extends ArgParser[SourceLink]:
9798
type Operation = "view" | "edit"
9899

99100
class SourceLinks(val sourceLinks: PathBased[SourceLink]):
100-
def pathTo(rawPath: Path, memberName: String = "", line: Option[Int] = None, operation: Operation = "view"): Option[String] =
101-
sourceLinks.get(rawPath).map(res => res.elem.render(memberName, res.path, operation, line))
101+
def pathTo(rawPath: Path, memberName: String = "", line: Option[Int] = None, operation: Operation = "view", optionalRevision: Option[String] = None): Option[String] =
102+
sourceLinks.get(rawPath).map(res => res.elem.render(memberName, res.path, operation, line, optionalRevision))
102103

103104
def pathTo(member: Member): Option[String] =
104105
member.sources.flatMap(s => pathTo(s.path, member.name, Option(s.lineNumber).map(_ + 1)))

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,14 @@ trait Locations(using ctx: DocContext):
2626
cache.get(dri) match
2727
case null =>
2828
val path = dri match
29-
case `docsDRI` => List("docs", "index")
30-
case `docsRootDRI` => List("index")
29+
case `docsRootDRI` => List("docs", "index")
3130
case `apiPageDRI` => List("api", "index")
3231
case dri if dri.isStaticFile =>
3332
Paths.get(dri.location).iterator.asScala.map(_.toString).toList
3433
case dri =>
3534
val loc = dri.location
3635
val fqn = loc.split(Array('.')).toList match
37-
case "<empty>" :: Nil => "_empty_" :: Nil
36+
case "<empty>" :: Nil => "_empty_" :: Nil
3837
case "<empty>" :: tail => "_empty_" :: tail
3938
case other => other
4039

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ trait Writer(using ctx: DocContext) extends Locations:
3333

3434
def copy(from: InputStream, to: String): String =
3535
Files.copy(from, dest(to))
36-
to
36+
to

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ case class LoadedTemplate(
4545
// toRealPath is used to turn symlinks into proper paths
4646
val actualPath = Paths.get("").toAbsolutePath.relativize(file.toPath.toRealPath())
4747
ctx.sourceLinks.pathTo(actualPath).map("viewSource" -> _ ) ++
48-
ctx.sourceLinks.pathTo(actualPath, operation = "edit").map("editSource" -> _ )
48+
ctx.sourceLinks.pathTo(actualPath, operation = "edit", optionalRevision = Some("master")).map("editSource" -> _ )
4949

5050
val updatedSettings = templateFile.settings ++ ctx.projectWideProperties +
5151
("site" -> (getMap("site") + ("posts" -> posts))) + ("urls" -> sourceLinks.toMap) +

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import com.vladsch.flexmark.ext.wikilink.WikiLinkExtension
1717

1818
import scala.collection.JavaConverters._
1919

20-
val docsRootDRI: DRI = DRI(location = "index.md")
21-
val docsDRI: DRI = DRI(location = "docs/index.md")
20+
val docsRootDRI: DRI = DRI(location = "docs", symbolUUID = staticFileSymbolUUID)
2221
val apiPageDRI: DRI = DRI(location = "api")
2322

2423
val defaultMarkdownOptions: DataHolder =

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,4 @@ case class TemplateFile(
106106
layoutTemplate match
107107
case None => ResolvedPage(code, resources ++ ctx.resources)
108108
case Some(layoutTemplate) =>
109-
layoutTemplate.resolveInner(ctx.nest(code, file, resources))
109+
layoutTemplate.resolveInner(ctx.nest(code, file, resources))

0 commit comments

Comments
 (0)