Skip to content

Commit 8f78f33

Browse files
committed
Add -Ylegacy-api-layout to retain previous layout of API
Add option to build 'flat' scaladoc package using `generateScalaDocumentation [output] --justAPI`
1 parent 05f7310 commit 8f78f33

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

project/Build.scala

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1325,6 +1325,7 @@ object Build {
13251325
generateScalaDocumentation := Def.inputTaskDyn {
13261326
val extraArgs = spaceDelimited("[output]").parsed
13271327
val dest = file(extraArgs.headOption.getOrElse("scaladoc/output/scala3")).getAbsoluteFile
1328+
val justAPI = extraArgs.drop(1).headOption == Some("--justAPI")
13281329
val majorVersion = (LocalProject("scala3-library-bootstrapped") / scalaBinaryVersion).value
13291330

13301331
val dottyJars: Seq[java.io.File] = Seq(
@@ -1346,21 +1347,24 @@ object Build {
13461347

13471348
val dottyLibRoot = projectRoot.relativize(dottyManagesSources.toPath.normalize())
13481349

1350+
def generateDocTask =
1351+
generateDocumentation(
1352+
roots, "Scala 3", dest.getAbsolutePath, "master",
1353+
Seq(
1354+
"-comment-syntax", "wiki",
1355+
s"-source-links:docs=github://lampepfl/dotty/master#docs",
1356+
"-doc-root-content", docRootFile.toString,
1357+
"-Ydocument-synthetic-types"
1358+
) ++ (if (justAPI) Nil else Seq("-siteroot", "docs", "-Ylegacy-api-layout")))
1359+
13491360
if (dottyJars.isEmpty) Def.task { streams.value.log.error("Dotty lib wasn't found") }
1361+
else if (justAPI) generateDocTask
13501362
else Def.task{
13511363
IO.write(dest / "versions" / "latest-nightly-base", majorVersion)
13521364

13531365
// This file is used by GitHub Pages when the page is available in a custom domain
13541366
IO.write(dest / "CNAME", "dotty.epfl.ch")
1355-
}.dependsOn(generateDocumentation(
1356-
roots, "Scala 3", dest.getAbsolutePath, "master",
1357-
Seq(
1358-
"-comment-syntax", "wiki",
1359-
"-siteroot", "docs",
1360-
s"-source-links:docs=github://lampepfl/dotty/master#docs",
1361-
"-doc-root-content", docRootFile.toString,
1362-
"-Ydocument-synthetic-types"
1363-
)))
1367+
}.dependsOn(generateDocTask)
13641368
}.evaluated,
13651369

13661370
generateTestcasesDocumentation := Def.taskDyn {

scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ object Scaladoc:
5858
snippetCompilerDebug: Boolean = false,
5959
noLinkWarnings: Boolean = false,
6060
versionsDictionaryUrl: Option[String] = None,
61-
generateInkuire : Boolean = false
61+
generateInkuire : Boolean = false,
62+
legacyAPILayout : Boolean = false
6263
)
6364

6465
def run(args: Array[String], rootContext: CompilerContext): Reporter =
@@ -223,7 +224,8 @@ object Scaladoc:
223224
noLinkWarnings.get,
224225
snippetCompilerDebug.get,
225226
versionsDictionaryUrl.nonDefault,
226-
generateInkuire.get
227+
generateInkuire.get,
228+
legacyAPILayout.get,
227229
)
228230
(Some(docArgs), newContext)
229231
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,8 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings:
120120
val generateInkuire: Setting[Boolean] =
121121
BooleanSetting("-Ygenerate-inkuire", "Generates InkuireDB and enables Hoogle-like searches", false)
122122

123+
val legacyAPILayout: Setting[Boolean] =
124+
BooleanSetting("-Ylegacy-api-layout", "Keep all api member inside `api` directory", false)
125+
123126
def scaladocSpecificSettings: Set[Setting[_]] =
124127
Set(sourceLinks, syntax, revision, externalDocumentationMappings, socialLinks, skipById, skipByRegex, deprecatedSkipPackages, docRootContent, snippetCompiler, snippetCompilerDebug, generateInkuire)

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,18 @@ trait Locations(using ctx: DocContext):
3232
val path = dri match
3333
case `docsRootDRI` => List("docs", "index")
3434
case `apiPageDRI` =>
35-
if ctx.staticSiteContext.fold(false)(_.hasIndexFile) then List("api", "index") else List("index")
35+
if ctx.args.legacyAPILayout || ctx.staticSiteContext.fold(false)(_.hasIndexFile)
36+
then List("api", "index")
37+
else List("index")
3638
case dri if dri.isStaticFile =>
3739
Paths.get(dri.location).iterator.asScala.map(_.toString).toList
3840
case dri =>
3941
val loc = dri.location
40-
loc.split(Array('.')).toList match
42+
val fqn = loc.split(Array('.')).toList match
4143
case "<empty>" :: Nil => "_empty_" :: Nil
4244
case "<empty>" :: tail => "_empty_" :: tail
4345
case other => other
46+
if ctx.args.legacyAPILayout then "api" :: fqn else fqn
4447
cache.put(dri, path)
4548
path
4649
case cached => cached

0 commit comments

Comments
 (0)