diff --git a/.github/workflows/language-reference.yaml b/.github/workflows/language-reference.yaml index d99e05c70abc..6aeb174738a2 100644 --- a/.github/workflows/language-reference.yaml +++ b/.github/workflows/language-reference.yaml @@ -21,7 +21,6 @@ jobs: uses: actions/checkout@v3 with: path: 'dotty' - ref: 'language-reference-stable' fetch-depth: 0 ssh-key: ${{ secrets.DOCS_KEY }} diff --git a/project/Build.scala b/project/Build.scala index 16f45f50befb..c15a56fa7ec5 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1416,7 +1416,7 @@ object Build { .add(ProjectVersion("3.1.2")) // TODO: Change that later to the current version tag. (This must happen on first forward this branch to stable release tag) .remove[VersionsDictionaryUrl] .add(SourceLinks(List( - dottySrcLink(referenceVersion, temp.getAbsolutePath + "=") + dottySrcLink("language-reference-stable", temp.getAbsolutePath + "=") ))) .withTargets(List("___fake___.scala")) } diff --git a/project/scripts/docsLinksStability b/project/scripts/docsLinksStability index 911f1974febf..1d57bc0a58fa 100755 --- a/project/scripts/docsLinksStability +++ b/project/scripts/docsLinksStability @@ -9,7 +9,7 @@ EXPECTED_LINKS_FILE=$2 # The location of expected-links.txt is passed as a secon pushd $DOCS_DIR > /dev/null # Go to docs dir but remember previous location # We need to go to docs dir to make find return correct relative paths -find . -type f -name "*.html" | sort | (popd > /dev/null; diff $EXPECTED_LINKS_FILE -;) +find . -type f -name "*.html" | LC_ALL=C sort | (popd > /dev/null; diff $EXPECTED_LINKS_FILE -;) # We list every html file in documentation, then sort it and finally compare to the expected links list. # Before running diff we need to popd to return to the previous location because we don't have relative path to the expected links file. diff --git a/project/scripts/expected-links/reference-expected-links.txt b/project/scripts/expected-links/reference-expected-links.txt index 3e6c027e64be..2e4236586c07 100644 --- a/project/scripts/expected-links/reference-expected-links.txt +++ b/project/scripts/expected-links/reference-expected-links.txt @@ -1,9 +1,9 @@ +./changed-features.html ./changed-features/compiler-plugins.html -./changed-features/eta-expansion.html ./changed-features/eta-expansion-spec.html -./changed-features.html -./changed-features/implicit-conversions.html +./changed-features/eta-expansion.html ./changed-features/implicit-conversions-spec.html +./changed-features/implicit-conversions.html ./changed-features/implicit-resolution.html ./changed-features/imports.html ./changed-features/index.html @@ -15,23 +15,23 @@ ./changed-features/overload-resolution.html ./changed-features/pattern-bindings.html ./changed-features/pattern-matching.html -./changed-features/structural-types.html ./changed-features/structural-types-spec.html +./changed-features/structural-types.html ./changed-features/type-checking.html ./changed-features/type-inference.html ./changed-features/vararg-splices.html ./changed-features/wildcards.html +./contextual.html ./contextual/by-name-context-parameters.html ./contextual/context-bounds.html -./contextual/context-functions.html ./contextual/context-functions-spec.html +./contextual/context-functions.html ./contextual/conversions.html -./contextual/derivation.html ./contextual/derivation-macro.html +./contextual/derivation.html ./contextual/extension-methods.html ./contextual/given-imports.html ./contextual/givens.html -./contextual.html ./contextual/index.html ./contextual/multiversal-equality.html ./contextual/relationship-implicits.html @@ -40,14 +40,14 @@ ./contextual/using-clauses.html ./docs/reference/other-new-features/named-typeargs.html ./docsScalaLangResources/scaladoc-assets.html +./dropped-features.html ./dropped-features/auto-apply.html -./dropped-features/class-shadowing.html ./dropped-features/class-shadowing-spec.html +./dropped-features/class-shadowing.html ./dropped-features/delayed-init.html ./dropped-features/do-while.html ./dropped-features/early-initializers.html ./dropped-features/existential-types.html -./dropped-features.html ./dropped-features/index.html ./dropped-features/limit22.html ./dropped-features/macros.html @@ -57,8 +57,8 @@ ./dropped-features/symlits.html ./dropped-features/this-qualifier.html ./dropped-features/type-projection.html -./dropped-features/weak-conformance.html ./dropped-features/weak-conformance-spec.html +./dropped-features/weak-conformance.html ./dropped-features/wildcard-init.html ./dropped-features/xml.html ./enums/adts.html @@ -67,13 +67,13 @@ ./enums/index.html ./experimental/canthrow.html ./experimental/cc.html -./experimental/erased-defs.html ./experimental/erased-defs-spec.html +./experimental/erased-defs.html ./experimental/explicit-nulls.html ./experimental/index.html ./experimental/main-annotation.html -./experimental/named-typeargs.html ./experimental/named-typeargs-spec.html +./experimental/named-typeargs.html ./experimental/numeric-literals.html ./experimental/overview.html ./features-classification.html @@ -81,31 +81,31 @@ ./language-versions/binary-compatibility.html ./language-versions/index.html ./language-versions/source-compatibility.html -./metaprogramming/compiletime-ops.html ./metaprogramming.html +./metaprogramming/compiletime-ops.html ./metaprogramming/index.html ./metaprogramming/inline.html -./metaprogramming/macros.html ./metaprogramming/macros-spec.html +./metaprogramming/macros.html ./metaprogramming/reflection.html ./metaprogramming/staging.html ./metaprogramming/tasty-inspect.html -./new-types/dependent-function-types.html ./new-types/dependent-function-types-spec.html +./new-types/dependent-function-types.html ./new-types/index.html -./new-types/intersection-types.html ./new-types/intersection-types-spec.html +./new-types/intersection-types.html ./new-types/match-types.html ./new-types/polymorphic-function-types.html -./new-types/type-lambdas.html ./new-types/type-lambdas-spec.html -./new-types/union-types.html +./new-types/type-lambdas.html ./new-types/union-types-spec.html +./new-types/union-types.html +./other-new-features.html ./other-new-features/control-syntax.html ./other-new-features/creator-applications.html ./other-new-features/experimental-defs.html ./other-new-features/export.html -./other-new-features.html ./other-new-features/indentation.html ./other-new-features/index.html ./other-new-features/kind-polymorphism.html @@ -113,8 +113,8 @@ ./other-new-features/opaques-details.html ./other-new-features/opaques.html ./other-new-features/open-classes.html -./other-new-features/parameter-untupling.html ./other-new-features/parameter-untupling-spec.html +./other-new-features/parameter-untupling.html ./other-new-features/safe-initialization.html ./other-new-features/targetName.html ./other-new-features/threadUnsafe-annotation.html diff --git a/project/scripts/regenerateExpectedLinks b/project/scripts/regenerateExpectedLinks index 95369f826e54..6ef3cd6adeaf 100755 --- a/project/scripts/regenerateExpectedLinks +++ b/project/scripts/regenerateExpectedLinks @@ -9,7 +9,7 @@ EXPECTED_LINKS_FILE=$2 # The location of expected-links.txt is passed as a secon pushd $DOCS_DIR > /dev/null # Go to docs dir but remember previous location # We need to go to docs dir to make find return correct relative paths -find . -type f -name "*.html" | (popd > /dev/null; sort > $2;) +find . -type f -name "*.html" | (popd > /dev/null; LC_ALL=C sort > $2;) # We list every html file in documentation, then sort it and finally write it to the expected links list file. # Before writing we need to popd to return to the previous location because we don't have relative path to the expected links file. diff --git a/scaladoc/src/dotty/tools/scaladoc/DocContext.scala b/scaladoc/src/dotty/tools/scaladoc/DocContext.scala index 366b5b8c162c..cf43b31ce6ec 100644 --- a/scaladoc/src/dotty/tools/scaladoc/DocContext.scala +++ b/scaladoc/src/dotty/tools/scaladoc/DocContext.scala @@ -105,5 +105,5 @@ case class DocContext(args: Scaladoc.Args, compilerContext: CompilerContext): report.warning( s"""Following generated file paths might not be compatible with Jekyll: |${jekyllIncompatLinks.mkString("\n")} - |If using GitHub Pages consider adding a \".nojekyll\" file. - """.stripMargin)(using compilerContext) + |If using GitHub Pages consider adding a \".nojekyll\" file.""".stripMargin + )(using compilerContext) diff --git a/scaladoc/src/dotty/tools/scaladoc/PathBased.scala b/scaladoc/src/dotty/tools/scaladoc/PathBased.scala index ab73fc683846..5e24623b43d5 100644 --- a/scaladoc/src/dotty/tools/scaladoc/PathBased.scala +++ b/scaladoc/src/dotty/tools/scaladoc/PathBased.scala @@ -4,10 +4,12 @@ import java.nio.file.{Path, Paths} case class PathBased[T](entries: List[PathBased.Entry[T]], projectRoot: Path): def get(path: Path): Option[PathBased.Result[T]] = - if path.isAbsolute && path.startsWith(projectRoot) then get(projectRoot.relativize(path)) - else entries.filter(_.path.forall(p => path.startsWith(p))).maxByOption(_.path.map(_.toString.length)).map(entry => - PathBased.Result(entry.path.fold(path)(_.relativize(path)), entry.elem) - ) + val paths = Option.when(path.isAbsolute && path.startsWith(projectRoot))(projectRoot.relativize(path)).toSeq :+ path + paths.iterator.to(LazyList).flatMap { path => + entries.filter(_.path.forall(p => path.startsWith(p))).maxByOption(_.path.map(_.toString.length)).map(entry => + PathBased.Result(entry.path.fold(path)(_.relativize(path)), entry.elem) + ) + }.headOption trait ArgParser[T]: def parse(s: String): Either[String, T] diff --git a/scaladoc/src/dotty/tools/scaladoc/renderers/HtmlRenderer.scala b/scaladoc/src/dotty/tools/scaladoc/renderers/HtmlRenderer.scala index 3a5d47c8f46c..10e95046d220 100644 --- a/scaladoc/src/dotty/tools/scaladoc/renderers/HtmlRenderer.scala +++ b/scaladoc/src/dotty/tools/scaladoc/renderers/HtmlRenderer.scala @@ -223,7 +223,7 @@ class HtmlRenderer(rootPackage: Member, members: Map[DRI, Member])(using ctx: Do footer( div(id := "generated-by")( span(cls := "footer-text")(raw("Generated by")), - a(href := "https://github.com/lampepfl/dotty/tree/master/scaladoc")( + a(href := "https://github.com/lampepfl/dotty/tree/main/scaladoc")( img( src := resolveRoot(link.dri, "images/scaladoc_logo.svg"), alt := "scaladoc", diff --git a/scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala b/scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala index 659409f2ef67..fd5e50b2acba 100644 --- a/scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala +++ b/scaladoc/src/dotty/tools/scaladoc/site/LoadedTemplate.scala @@ -42,12 +42,10 @@ case class LoadedTemplate( val subpages = children.filterNot(_.hidden).map(_.lazyTemplateProperties(ctx)) def getMap(key: String) = templateFile.settings.getOrElse(key, Map.empty).asInstanceOf[Map[String, Object]] - val sourceLinks = if !file.exists() then Nil else - // TODO (https://github.com/lampepfl/scala3doc/issues/240): configure source root - // toRealPath is used to turn symlinks into proper paths - val actualPath = Paths.get("").toAbsolutePath.relativize(file.toPath.toRealPath()) + val sourceLinks = if !templateFile.file.exists() then Nil else + val actualPath = templateFile.file.toPath ctx.sourceLinks.pathTo(actualPath).map("viewSource" -> _ ) ++ - ctx.sourceLinks.pathTo(actualPath, operation = "edit", optionalRevision = Some("master")).map("editSource" -> _) + ctx.sourceLinks.pathTo(actualPath, operation = "edit").map("editSource" -> _) val updatedSettings = templateFile.settings ++ ctx.projectWideProperties + ("site" -> (getMap("site") + ("subpages" -> subpages))) + ("urls" -> sourceLinks.toMap) +