diff --git a/docs/docs/usage/scaladoc/site-versioning.md b/docs/docs/usage/scaladoc/site-versioning.md index 69a3f6687825..9cd1e3d9fc5f 100644 --- a/docs/docs/usage/scaladoc/site-versioning.md +++ b/docs/docs/usage/scaladoc/site-versioning.md @@ -33,4 +33,4 @@ doc / scalacOptions ++= Seq("-versions-dictionary-url", "https://dotty.epfl.ch/v 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. -![](../../../images/scaladoc/nightly.gif) +![](images/scaladoc/nightly.gif) diff --git a/scaladoc/resources/dotty_res/styles/scalastyle.css b/scaladoc/resources/dotty_res/styles/scalastyle.css index 90682b0faa0d..11bb67d7421e 100644 --- a/scaladoc/resources/dotty_res/styles/scalastyle.css +++ b/scaladoc/resources/dotty_res/styles/scalastyle.css @@ -163,7 +163,7 @@ th { #logo>span>img { max-height: 40px; max-width: 40px; - padding: 16px 8px 8px 16px; + margin: 16px 8px 8px 16px; cursor: pointer; } @@ -1011,4 +1011,4 @@ footer .socials { .breadcrumbs a:first-child { margin: 0 8px 0 0; -} \ No newline at end of file +} diff --git a/scaladoc/src/dotty/tools/scaladoc/SourceLinks.scala b/scaladoc/src/dotty/tools/scaladoc/SourceLinks.scala index 1496b6847316..120586200f58 100644 --- a/scaladoc/src/dotty/tools/scaladoc/SourceLinks.scala +++ b/scaladoc/src/dotty/tools/scaladoc/SourceLinks.scala @@ -12,11 +12,11 @@ def pathToString(p: Path) = trait SourceLink: val path: Option[Path] = None - def render(memberName: String, path: Path, operation: String, line: Option[Int]): String + def render(memberName: String, path: Path, operation: String, line: Option[Int], optionalRevision: Option[String]): String case class TemplateSourceLink(val urlTemplate: String) extends SourceLink: override val path: Option[Path] = None - override def render(memberName: String, path: Path, operation: String, line: Option[Int]): String = + override def render(memberName: String, path: Path, operation: String, line: Option[Int], optionalRevision: Option[String]): String = val pathString = "/" + pathToString(path) val mapping = Map( "\\{\\{ path \\}\\}".r -> pathString, @@ -36,10 +36,11 @@ case class TemplateSourceLink(val urlTemplate: String) extends SourceLink: case class WebBasedSourceLink(prefix: String, revision: String, subPath: String) extends SourceLink: override val path: Option[Path] = None - override def render(memberName: String, path: Path, operation: String, line: Option[Int]): String = + override def render(memberName: String, path: Path, operation: String, line: Option[Int], optionalRevision: Option[String] = None): String = val action = if operation == "view" then "blob" else operation + val finalRevision = optionalRevision.getOrElse(revision) val linePart = line.fold("")(l => s"#L$l") - s"$prefix/$action/$revision$subPath/${pathToString(path)}$linePart" + s"$prefix/$action/$finalRevision$subPath/${pathToString(path)}$linePart" class SourceLinkParser(revision: Option[String]) extends ArgParser[SourceLink]: val KnownProvider = raw"(\w+):\/\/([^\/#]+)\/([^\/#]+)(\/[^\/#]+)?(#.+)?".r @@ -97,8 +98,8 @@ class SourceLinkParser(revision: Option[String]) extends ArgParser[SourceLink]: type Operation = "view" | "edit" class SourceLinks(val sourceLinks: PathBased[SourceLink]): - def pathTo(rawPath: Path, memberName: String = "", line: Option[Int] = None, operation: Operation = "view"): Option[String] = - sourceLinks.get(rawPath).map(res => res.elem.render(memberName, res.path, operation, line)) + def pathTo(rawPath: Path, memberName: String = "", line: Option[Int] = None, operation: Operation = "view", optionalRevision: Option[String] = None): Option[String] = + sourceLinks.get(rawPath).map(res => res.elem.render(memberName, res.path, operation, line, optionalRevision)) def pathTo(member: Member): Option[String] = member.sources.flatMap(s => pathTo(s.path, member.name, Option(s.lineNumber).map(_ + 1))) diff --git a/scaladoc/src/dotty/tools/scaladoc/renderers/Locations.scala b/scaladoc/src/dotty/tools/scaladoc/renderers/Locations.scala index 04b8e0edb430..ba01279930fc 100644 --- a/scaladoc/src/dotty/tools/scaladoc/renderers/Locations.scala +++ b/scaladoc/src/dotty/tools/scaladoc/renderers/Locations.scala @@ -26,15 +26,14 @@ trait Locations(using ctx: DocContext): cache.get(dri) match case null => val path = dri match - case `docsDRI` => List("docs", "index") - case `docsRootDRI` => List("index") + case `docsRootDRI` => List("docs", "index") case `apiPageDRI` => List("api", "index") case dri if dri.isStaticFile => Paths.get(dri.location).iterator.asScala.map(_.toString).toList case dri => val loc = dri.location val fqn = loc.split(Array('.')).toList match - case "" :: Nil => "_empty_" :: Nil + case "" :: Nil => "_empty_" :: Nil case "" :: tail => "_empty_" :: tail case other => other diff --git a/scaladoc/src/dotty/tools/scaladoc/renderers/Writer.scala b/scaladoc/src/dotty/tools/scaladoc/renderers/Writer.scala index dad7aaa9e650..313cef340d41 100644 --- a/scaladoc/src/dotty/tools/scaladoc/renderers/Writer.scala +++ b/scaladoc/src/dotty/tools/scaladoc/renderers/Writer.scala @@ -33,4 +33,4 @@ trait Writer(using ctx: DocContext) extends Locations: def copy(from: InputStream, to: String): String = Files.copy(from, dest(to)) - to \ No newline at end of file + to diff --git a/scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala b/scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala index 590a016a25d3..30555868704a 100644 --- a/scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala +++ b/scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala @@ -45,7 +45,7 @@ case class LoadedTemplate( // toRealPath is used to turn symlinks into proper paths val actualPath = Paths.get("").toAbsolutePath.relativize(file.toPath.toRealPath()) ctx.sourceLinks.pathTo(actualPath).map("viewSource" -> _ ) ++ - ctx.sourceLinks.pathTo(actualPath, operation = "edit").map("editSource" -> _ ) + ctx.sourceLinks.pathTo(actualPath, operation = "edit", optionalRevision = Some("master")).map("editSource" -> _ ) val updatedSettings = templateFile.settings ++ ctx.projectWideProperties + ("site" -> (getMap("site") + ("posts" -> posts))) + ("urls" -> sourceLinks.toMap) + diff --git a/scaladoc/src/dotty/tools/scaladoc/site/common.scala b/scaladoc/src/dotty/tools/scaladoc/site/common.scala index 49c4621a90dc..ffa7001303db 100644 --- a/scaladoc/src/dotty/tools/scaladoc/site/common.scala +++ b/scaladoc/src/dotty/tools/scaladoc/site/common.scala @@ -17,8 +17,7 @@ import com.vladsch.flexmark.ext.wikilink.WikiLinkExtension import scala.collection.JavaConverters._ -val docsRootDRI: DRI = DRI(location = "index.md") -val docsDRI: DRI = DRI(location = "docs/index.md") +val docsRootDRI: DRI = DRI(location = "docs", symbolUUID = staticFileSymbolUUID) val apiPageDRI: DRI = DRI(location = "api") val defaultMarkdownOptions: DataHolder = diff --git a/scaladoc/src/dotty/tools/scaladoc/site/templates.scala b/scaladoc/src/dotty/tools/scaladoc/site/templates.scala index d832659ab4bd..f4ce939cf44f 100644 --- a/scaladoc/src/dotty/tools/scaladoc/site/templates.scala +++ b/scaladoc/src/dotty/tools/scaladoc/site/templates.scala @@ -106,4 +106,4 @@ case class TemplateFile( layoutTemplate match case None => ResolvedPage(code, resources ++ ctx.resources) case Some(layoutTemplate) => - layoutTemplate.resolveInner(ctx.nest(code, file, resources)) \ No newline at end of file + layoutTemplate.resolveInner(ctx.nest(code, file, resources))