Skip to content

Commit 77af246

Browse files
committed
Fix publishing nightly docs do BarkingBad fork.
1 parent 2b1bce3 commit 77af246

File tree

6 files changed

+35
-14
lines changed

6 files changed

+35
-14
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,7 @@ jobs:
514514
with:
515515
personal_token: ${{ DOCS_SCALALANG_BOT_TOKEN }}
516516
publish_dir: docsScalaLang
517-
external_repository: scala/docs.scala-lang
517+
external_repository: BarkingBad/docs.scala-lang
518518
publish_branch: dev
519519

520520
publish_release:

project/scripts/genDocsScalaLang

+15-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,22 @@ git clone "https://github.com/scala/docs.scala-lang.git" $DOCS_SCALA_LANG_DIR
1818

1919
SBT="$SCRIPT_DIR/sbt"
2020
mkdir -pv $SITE_OUT_DIR
21+
2122
env "scaladoc.projectFormat=md" "$SBT" "scaladoc/renderScaladocScalajsToFile $DOCS_SCALA_LANG_DIR/scripts/scaladoc-scalajs.js $DOCS_SCALA_LANG_DIR/resources/css code-snippets.css"
22-
"bin/scaladoc" "-d" "$SITE_OUT_DIR" "-format" "md" "-siteroot" "docs" "/dev/null"
23+
24+
DOTTY_NONBOOTSTRAPPED_VERSION_COMMAND="$SBT \"eval println(Build.dottyNonBootstrappedVersion)\""
25+
DOTTY_NONBOOTSTRAPPED_VERSION=$(eval $DOTTY_NONBOOTSTRAPPED_VERSION_COMMAND | tail -n 2 | head -n 1)
26+
27+
DOTTY_BOOTSTRAPPED_VERSION_COMMAND="$SBT \"eval println(Build.dottyVersion)\""
28+
DOTTY_BOOTSTRAPPED_VERSION=$(eval $DOTTY_BOOTSTRAPPED_VERSION_COMMAND | tail -n 2 | head -n 1)
29+
30+
GITHUB_REPOSITORY="lampepfl/dotty"
31+
GITHUB_SHA="3.0.0"
32+
33+
"bin/scaladoc" "-d" "$SITE_OUT_DIR" "-format" "md" "-siteroot" "docs" "/dev/null " \
34+
-source-links:out/bootstrap/stdlib-bootstrapped/scala-"${DOTTY_NONBOOTSTRAPPED_VERSION}"/src_managed/main/scala-library-src=github://scala/scala/v"${STDLIB_VERSION}"#src/library \
35+
-source-links:out/bootstrap/stdlib-bootstrapped/scala-"${DOTTY_NONBOOTSTRAPPED_VERSION}"/src_managed/main/dotty-library-src=github://"${GITHUB_REPOSITORY}"/"${GITHUB_SHA}"\#library/src \
36+
-source-links:github://"${GITHUB_REPOSITORY}"/"${GITHUB_SHA}" \
2337

2438
if [ ! -d "$SITE_OUT_DIR" ]; then
2539
echo "Output directory did not exist: $SITE_OUT_DIR" 1>&2

scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings:
128128

129129
val scastieConfiguration: Setting[String] =
130130
StringSetting("-scastie-configuration", "Scastie configuration", "Additional configuration passed to Scastie in code snippets", "")
131-
131+
132132
val projectFormat: Setting[String] =
133133
ChoiceSetting(
134134
"-format",

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ object FrontMatterRenderer:
1414

1515
val rows = renderProperties(properties) ++ renderProperties(properties("page").asInstanceOf[Map[String, Object]])
1616

17-
rows.mkString("---\n", "\n", "\n---") + "\n\n<!-- THIS FILE HAS BEEN GENERATED BY SCALADOC PREPROCESSOR. " +
18-
"NOTE THAT ANY CHANGES TO THIS FILE CAN BE OVERRIDEN IN THE FUTURE -->\n\n"
17+
rows.mkString("---\n", "\n", "\n---") + "\n\n<!-- THIS FILE HAS BEEN GENERATED BY SCALADOC PREPROCESSOR.\n" +
18+
" The whole process of generation the docs can be found under this README: https://github.com/lampepfl/dotty/blob/master/docs/README.md\n" +
19+
s" The source file can be found here ${properties.get("urls").flatMap(_.asInstanceOf[Map[String, Object]].get("editSource")).getOrElse("")}\n" +
20+
" NOTE THAT ANY CHANGES TO THIS FILE WILL BE OVERRIDEN BY PREPROCESSOR.\n" +
21+
"-->\n\n"
22+
1923

2024

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

+1-7
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,9 @@ case class LoadedTemplate(
4040
def resolveToHtml(ctx: StaticSiteContext): ResolvedPage =
4141
val posts = children.map(_.lazyTemplateProperties(ctx))
4242
def getMap(key: String) = templateFile.settings.getOrElse(key, Map.empty).asInstanceOf[Map[String, Object]]
43-
val sourceLinks = if !file.exists() then Nil else
44-
// TODO (https://github.com/lampepfl/scala3doc/issues/240): configure source root
45-
// toRealPath is used to turn symlinks into proper paths
46-
val actualPath = Paths.get("").toAbsolutePath.relativize(file.toPath.toRealPath())
47-
ctx.sourceLinks.pathTo(actualPath).map("viewSource" -> _ ) ++
48-
ctx.sourceLinks.pathTo(actualPath, operation = "edit", optionalRevision = Some("master")).map("editSource" -> _ )
4943

5044
val updatedSettings = templateFile.settings ++ ctx.projectWideProperties +
51-
("site" -> (getMap("site") + ("posts" -> posts))) + ("urls" -> sourceLinks.toMap) +
45+
("site" -> (getMap("site") + ("posts" -> posts))) +
5246
("page" -> (getMap("page") + ("title" -> templateFile.title.name)))
5347

5448
templateFile.resolveInner(RenderingContext(updatedSettings, ctx.layouts))(using ctx)

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

+11-2
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,15 @@ case class TemplateFile(
114114
val rendered = ssctx.args.projectFormat match
115115
case "html" => Template.parse(this.rawCode).`with`(tag).render(mutableProperties)
116116
case "md" => this.rawCode
117-
117+
118+
val sourceLinks = if !file.exists() then Nil else
119+
// TODO (https://github.com/lampepfl/scala3doc/issues/240): configure source root
120+
// toRealPath is used to turn symlinks into proper paths
121+
val actualPath = Paths.get("").toAbsolutePath.relativize(file.toPath.toRealPath())
122+
ssctx.sourceLinks.pathTo(actualPath).map("viewSource" -> _ ) ++
123+
// List("editSource" -> ssctx.sourceLinks.pathTo(actualPath))
124+
ssctx.sourceLinks.pathTo(actualPath, operation = "edit", optionalRevision = Some("master")).map("editSource" -> _ )
125+
118126
// We want to render markdown only if next template is html
119127
val code = if (isHtml || layoutTemplate.exists(!_.isHtml)) rendered else
120128
// Snippet compiler currently supports markdown only
@@ -125,7 +133,8 @@ case class TemplateFile(
125133
ssctx.args.projectFormat match
126134
case "html" => HtmlRenderer.builder(defaultMarkdownOptions).build().render(processed)
127135
case "md" =>
128-
FrontMatterRenderer.render(settings) +
136+
137+
FrontMatterRenderer.render(settings + ("urls" -> sourceLinks.toMap)) +
129138
Formatter.builder(defaultMarkdownOptions).build().render(processed)
130139

131140

0 commit comments

Comments
 (0)