Skip to content

Commit 68765c2

Browse files
authored
Merge pull request #15131 from dotty-staging/scaladoc/edit-github-fix
Static site bugfixes found in stable documentation
2 parents badb4ea + df354dd commit 68765c2

File tree

9 files changed

+35
-36
lines changed

9 files changed

+35
-36
lines changed

.github/workflows/language-reference.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ jobs:
2121
uses: actions/checkout@v3
2222
with:
2323
path: 'dotty'
24-
ref: 'language-reference-stable'
2524
fetch-depth: 0
2625
ssh-key: ${{ secrets.DOCS_KEY }}
2726

project/Build.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1416,7 +1416,7 @@ object Build {
14161416
.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)
14171417
.remove[VersionsDictionaryUrl]
14181418
.add(SourceLinks(List(
1419-
dottySrcLink(referenceVersion, temp.getAbsolutePath + "=")
1419+
dottySrcLink("language-reference-stable", temp.getAbsolutePath + "=")
14201420
)))
14211421
.withTargets(List("___fake___.scala"))
14221422
}

project/scripts/docsLinksStability

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ EXPECTED_LINKS_FILE=$2 # The location of expected-links.txt is passed as a secon
99

1010
pushd $DOCS_DIR > /dev/null # Go to docs dir but remember previous location
1111
# We need to go to docs dir to make find return correct relative paths
12-
find . -type f -name "*.html" | sort | (popd > /dev/null; diff $EXPECTED_LINKS_FILE -;)
12+
find . -type f -name "*.html" | LC_ALL=C sort | (popd > /dev/null; diff $EXPECTED_LINKS_FILE -;)
1313
# We list every html file in documentation, then sort it and finally compare to the expected links list.
1414
# 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.
1515

project/scripts/expected-links/reference-expected-links.txt

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
./changed-features.html
12
./changed-features/compiler-plugins.html
2-
./changed-features/eta-expansion.html
33
./changed-features/eta-expansion-spec.html
4-
./changed-features.html
5-
./changed-features/implicit-conversions.html
4+
./changed-features/eta-expansion.html
65
./changed-features/implicit-conversions-spec.html
6+
./changed-features/implicit-conversions.html
77
./changed-features/implicit-resolution.html
88
./changed-features/imports.html
99
./changed-features/index.html
@@ -15,23 +15,23 @@
1515
./changed-features/overload-resolution.html
1616
./changed-features/pattern-bindings.html
1717
./changed-features/pattern-matching.html
18-
./changed-features/structural-types.html
1918
./changed-features/structural-types-spec.html
19+
./changed-features/structural-types.html
2020
./changed-features/type-checking.html
2121
./changed-features/type-inference.html
2222
./changed-features/vararg-splices.html
2323
./changed-features/wildcards.html
24+
./contextual.html
2425
./contextual/by-name-context-parameters.html
2526
./contextual/context-bounds.html
26-
./contextual/context-functions.html
2727
./contextual/context-functions-spec.html
28+
./contextual/context-functions.html
2829
./contextual/conversions.html
29-
./contextual/derivation.html
3030
./contextual/derivation-macro.html
31+
./contextual/derivation.html
3132
./contextual/extension-methods.html
3233
./contextual/given-imports.html
3334
./contextual/givens.html
34-
./contextual.html
3535
./contextual/index.html
3636
./contextual/multiversal-equality.html
3737
./contextual/relationship-implicits.html
@@ -40,14 +40,14 @@
4040
./contextual/using-clauses.html
4141
./docs/reference/other-new-features/named-typeargs.html
4242
./docsScalaLangResources/scaladoc-assets.html
43+
./dropped-features.html
4344
./dropped-features/auto-apply.html
44-
./dropped-features/class-shadowing.html
4545
./dropped-features/class-shadowing-spec.html
46+
./dropped-features/class-shadowing.html
4647
./dropped-features/delayed-init.html
4748
./dropped-features/do-while.html
4849
./dropped-features/early-initializers.html
4950
./dropped-features/existential-types.html
50-
./dropped-features.html
5151
./dropped-features/index.html
5252
./dropped-features/limit22.html
5353
./dropped-features/macros.html
@@ -57,8 +57,8 @@
5757
./dropped-features/symlits.html
5858
./dropped-features/this-qualifier.html
5959
./dropped-features/type-projection.html
60-
./dropped-features/weak-conformance.html
6160
./dropped-features/weak-conformance-spec.html
61+
./dropped-features/weak-conformance.html
6262
./dropped-features/wildcard-init.html
6363
./dropped-features/xml.html
6464
./enums/adts.html
@@ -67,54 +67,54 @@
6767
./enums/index.html
6868
./experimental/canthrow.html
6969
./experimental/cc.html
70-
./experimental/erased-defs.html
7170
./experimental/erased-defs-spec.html
71+
./experimental/erased-defs.html
7272
./experimental/explicit-nulls.html
7373
./experimental/index.html
7474
./experimental/main-annotation.html
75-
./experimental/named-typeargs.html
7675
./experimental/named-typeargs-spec.html
76+
./experimental/named-typeargs.html
7777
./experimental/numeric-literals.html
7878
./experimental/overview.html
7979
./features-classification.html
8080
./index.html
8181
./language-versions/binary-compatibility.html
8282
./language-versions/index.html
8383
./language-versions/source-compatibility.html
84-
./metaprogramming/compiletime-ops.html
8584
./metaprogramming.html
85+
./metaprogramming/compiletime-ops.html
8686
./metaprogramming/index.html
8787
./metaprogramming/inline.html
88-
./metaprogramming/macros.html
8988
./metaprogramming/macros-spec.html
89+
./metaprogramming/macros.html
9090
./metaprogramming/reflection.html
9191
./metaprogramming/staging.html
9292
./metaprogramming/tasty-inspect.html
93-
./new-types/dependent-function-types.html
9493
./new-types/dependent-function-types-spec.html
94+
./new-types/dependent-function-types.html
9595
./new-types/index.html
96-
./new-types/intersection-types.html
9796
./new-types/intersection-types-spec.html
97+
./new-types/intersection-types.html
9898
./new-types/match-types.html
9999
./new-types/polymorphic-function-types.html
100-
./new-types/type-lambdas.html
101100
./new-types/type-lambdas-spec.html
102-
./new-types/union-types.html
101+
./new-types/type-lambdas.html
103102
./new-types/union-types-spec.html
103+
./new-types/union-types.html
104+
./other-new-features.html
104105
./other-new-features/control-syntax.html
105106
./other-new-features/creator-applications.html
106107
./other-new-features/experimental-defs.html
107108
./other-new-features/export.html
108-
./other-new-features.html
109109
./other-new-features/indentation.html
110110
./other-new-features/index.html
111111
./other-new-features/kind-polymorphism.html
112112
./other-new-features/matchable.html
113113
./other-new-features/opaques-details.html
114114
./other-new-features/opaques.html
115115
./other-new-features/open-classes.html
116-
./other-new-features/parameter-untupling.html
117116
./other-new-features/parameter-untupling-spec.html
117+
./other-new-features/parameter-untupling.html
118118
./other-new-features/safe-initialization.html
119119
./other-new-features/targetName.html
120120
./other-new-features/threadUnsafe-annotation.html

project/scripts/regenerateExpectedLinks

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ EXPECTED_LINKS_FILE=$2 # The location of expected-links.txt is passed as a secon
99

1010
pushd $DOCS_DIR > /dev/null # Go to docs dir but remember previous location
1111
# We need to go to docs dir to make find return correct relative paths
12-
find . -type f -name "*.html" | (popd > /dev/null; sort > $2;)
12+
find . -type f -name "*.html" | (popd > /dev/null; LC_ALL=C sort > $2;)
1313
# We list every html file in documentation, then sort it and finally write it to the expected links list file.
1414
# Before writing we need to popd to return to the previous location because we don't have relative path to the expected links file.
1515

scaladoc/src/dotty/tools/scaladoc/DocContext.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,5 +105,5 @@ case class DocContext(args: Scaladoc.Args, compilerContext: CompilerContext):
105105
report.warning(
106106
s"""Following generated file paths might not be compatible with Jekyll:
107107
|${jekyllIncompatLinks.mkString("\n")}
108-
|If using GitHub Pages consider adding a \".nojekyll\" file.
109-
""".stripMargin)(using compilerContext)
108+
|If using GitHub Pages consider adding a \".nojekyll\" file.""".stripMargin
109+
)(using compilerContext)

scaladoc/src/dotty/tools/scaladoc/PathBased.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import java.nio.file.{Path, Paths}
44

55
case class PathBased[T](entries: List[PathBased.Entry[T]], projectRoot: Path):
66
def get(path: Path): Option[PathBased.Result[T]] =
7-
if path.isAbsolute && path.startsWith(projectRoot) then get(projectRoot.relativize(path))
8-
else entries.filter(_.path.forall(p => path.startsWith(p))).maxByOption(_.path.map(_.toString.length)).map(entry =>
9-
PathBased.Result(entry.path.fold(path)(_.relativize(path)), entry.elem)
10-
)
7+
val paths = Option.when(path.isAbsolute && path.startsWith(projectRoot))(projectRoot.relativize(path)).toSeq :+ path
8+
paths.iterator.to(LazyList).flatMap { path =>
9+
entries.filter(_.path.forall(p => path.startsWith(p))).maxByOption(_.path.map(_.toString.length)).map(entry =>
10+
PathBased.Result(entry.path.fold(path)(_.relativize(path)), entry.elem)
11+
)
12+
}.headOption
1113

1214
trait ArgParser[T]:
1315
def parse(s: String): Either[String, T]

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class HtmlRenderer(rootPackage: Member, members: Map[DRI, Member])(using ctx: Do
223223
footer(
224224
div(id := "generated-by")(
225225
span(cls := "footer-text")(raw("Generated by")),
226-
a(href := "https://github.com/lampepfl/dotty/tree/master/scaladoc")(
226+
a(href := "https://github.com/lampepfl/dotty/tree/main/scaladoc")(
227227
img(
228228
src := resolveRoot(link.dri, "images/scaladoc_logo.svg"),
229229
alt := "scaladoc",

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,10 @@ case class LoadedTemplate(
4242
val subpages = children.filterNot(_.hidden).map(_.lazyTemplateProperties(ctx))
4343
def getMap(key: String) = templateFile.settings.getOrElse(key, Map.empty).asInstanceOf[Map[String, Object]]
4444

45-
val sourceLinks = if !file.exists() then Nil else
46-
// TODO (https://github.com/lampepfl/scala3doc/issues/240): configure source root
47-
// toRealPath is used to turn symlinks into proper paths
48-
val actualPath = Paths.get("").toAbsolutePath.relativize(file.toPath.toRealPath())
45+
val sourceLinks = if !templateFile.file.exists() then Nil else
46+
val actualPath = templateFile.file.toPath
4947
ctx.sourceLinks.pathTo(actualPath).map("viewSource" -> _ ) ++
50-
ctx.sourceLinks.pathTo(actualPath, operation = "edit", optionalRevision = Some("master")).map("editSource" -> _)
48+
ctx.sourceLinks.pathTo(actualPath, operation = "edit").map("editSource" -> _)
5149

5250
val updatedSettings = templateFile.settings ++ ctx.projectWideProperties +
5351
("site" -> (getMap("site") + ("subpages" -> subpages))) + ("urls" -> sourceLinks.toMap) +

0 commit comments

Comments
 (0)