diff --git a/project/Build.scala b/project/Build.scala index adbedca984dd..6d5bef45aff4 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -319,10 +319,11 @@ object Build { private lazy val currentYear: String = java.util.Calendar.getInstance().get(java.util.Calendar.YEAR).toString - lazy val scalacOptionsDocSettings = Seq( - "-external-mappings:" + - ".*scala/.*::scaladoc3::https://dotty.epfl.ch/api/," + - ".*java/.*::javadoc::https://docs.oracle.com/javase/8/docs/api/", + def scalacOptionsDocSettings(includeExternalMappings: Boolean = true) = { + val extMap = Seq("-external-mappings:" + + (if (includeExternalMappings) ".*scala/.*::scaladoc3::https://dotty.epfl.ch/api/," else "") + + ".*java/.*::javadoc::https://docs.oracle.com/javase/8/docs/api/") + Seq( "-skip-by-regex:.+\\.internal($|\\..+)", "-skip-by-regex:.+\\.impl($|\\..+)", "-project-logo", "docs/logo.svg", @@ -340,7 +341,8 @@ object Build { "-project-footer", s"Copyright (c) 2002-$currentYear, LAMP/EPFL", "-author", "-groups" - ) + ) ++ extMap + } // Settings used when compiling dotty with a non-bootstrapped dotty lazy val commonBootstrappedSettings = commonDottySettings ++ NoBloopExport.settings ++ Seq( @@ -423,7 +425,7 @@ object Build { assert(docScalaInstance.loaderCompilerOnly == base.loaderCompilerOnly) docScalaInstance }, - Compile / doc / scalacOptions ++= scalacOptionsDocSettings + Compile / doc / scalacOptions ++= scalacOptionsDocSettings() ) lazy val commonBenchmarkSettings = Seq( @@ -1266,7 +1268,7 @@ object Build { libraryDependencies += ("org.scala-js" %%% "scalajs-dom" % "1.1.0").cross(CrossVersion.for3Use2_13) ) - def generateDocumentation(targets: Seq[String], name: String, outDir: String, ref: String, params: Seq[String] = Nil) = + def generateDocumentation(targets: Seq[String], name: String, outDir: String, ref: String, params: Seq[String] = Nil, includeExternalMappings: Boolean = true) = Def.taskDyn { val distLocation = (dist / pack).value val projectVersion = version.value @@ -1294,7 +1296,7 @@ object Build { dottySrcLink(referenceVersion, srcManaged(dottyNonBootstrappedVersion, "dotty") + "=", "#library/src"), dottySrcLink(referenceVersion), "-Ygenerate-inkuire", - ) ++ scalacOptionsDocSettings ++ revision ++ params ++ targets + ) ++ scalacOptionsDocSettings(includeExternalMappings) ++ revision ++ params ++ targets import _root_.scala.sys.process._ val escapedCmd = cmd.map(arg => if(arg.contains(" ")) s""""$arg"""" else arg) Def.task { @@ -1424,7 +1426,7 @@ object Build { "https://scala-lang.org/api/versions.json", "-Ydocument-synthetic-types", s"-snippet-compiler:${dottyLibRoot}/scala/quoted=compile,${dottyLibRoot}/scala/compiletime=compile" - ) ++ (if (justAPI) Nil else Seq("-siteroot", "docs-for-dotty-page", "-Yapi-subdirectory"))) + ) ++ (if (justAPI) Nil else Seq("-siteroot", "docs-for-dotty-page", "-Yapi-subdirectory")), includeExternalMappings = false) if (dottyJars.isEmpty) Def.task { streams.value.log.error("Dotty lib wasn't found") } else if (justAPI) generateDocTask diff --git a/scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala b/scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala index d64aa8d67874..0ff21cda60c1 100644 --- a/scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala +++ b/scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala @@ -70,19 +70,21 @@ trait ClassLikeSupport: case tree: ClassDef => tree case tt: TypeTree => unpackTreeToClassDef(tt.tpe.typeSymbol.tree) - def getSupertypesGraph(classDef: Tree, link: LinkToType): Seq[(LinkToType, LinkToType)] = - val smbl = classDef.symbol - val parents = unpackTreeToClassDef(classDef).parents - parents.flatMap { case tree => + def getSupertypesGraph(link: LinkToType, to: Seq[Tree]): Seq[(LinkToType, LinkToType)] = + to.flatMap { case tree => val symbol = if tree.symbol.isClassConstructor then tree.symbol.owner else tree.symbol val superLink = LinkToType(tree.asSignature, symbol.dri, bareClasslikeKind(symbol)) - Seq(link -> superLink) ++ getSupertypesGraph(tree, superLink) + val nextTo = unpackTreeToClassDef(tree).parents + if symbol.isHiddenByVisibility then getSupertypesGraph(link, nextTo) + else Seq(link -> superLink) ++ getSupertypesGraph(superLink, nextTo) } - val supertypes = getSupertypes(using qctx)(classDef).map { - case (symbol, tpe) => - LinkToType(tpe.asSignature, symbol.dri, bareClasslikeKind(symbol)) - } + val supertypes = getSupertypes(using qctx)(classDef) + .filterNot((s, t) => s.isHiddenByVisibility) + .map { + case (symbol, tpe) => + LinkToType(tpe.asSignature, symbol.dri, bareClasslikeKind(symbol)) + } val selfType = classDef.self.map { (valdef: ValDef) => val symbol = valdef.symbol val tpe = valdef.tpt.tpe @@ -91,7 +93,7 @@ trait ClassLikeSupport: val selfSignature: DSignature = typeForClass(classDef).asSignature val graph = HierarchyGraph.withEdges( - getSupertypesGraph(classDef, LinkToType(selfSignature, classDef.symbol.dri, bareClasslikeKind(classDef.symbol))) + getSupertypesGraph(LinkToType(selfSignature, classDef.symbol.dri, bareClasslikeKind(classDef.symbol)), unpackTreeToClassDef(classDef).parents) ) val baseMember = mkMember(classDef.symbol, kindForClasslike(classDef), selfSignature)( @@ -255,7 +257,7 @@ trait ClassLikeSupport: case t: TypeTree => t.tpe.typeSymbol case tree if tree.symbol.isClassConstructor => tree.symbol.owner case tree => tree.symbol - if parentSymbol != defn.ObjectClass && parentSymbol != defn.AnyClass + if parentSymbol != defn.ObjectClass && parentSymbol != defn.AnyClass && !parentSymbol.isHiddenByVisibility yield (parentTree, parentSymbol) def getConstructors: List[Symbol] = c.membersToDocument.collect { diff --git a/scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala b/scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala index 147b5c40d21b..d825b7ab6c31 100644 --- a/scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala +++ b/scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala @@ -61,8 +61,10 @@ trait TypesSupport: extension (on: SignaturePart) def l: List[SignaturePart] = List(on) private def tpe(using Quotes)(symbol: reflect.Symbol): SSignature = + import SymOps._ val suffix = if symbol.isValDef || symbol.flags.is(reflect.Flags.Module) then plain(".type").l else Nil - dotty.tools.scaladoc.Type(symbol.normalizedName, Some(symbol.dri)) :: suffix + val dri: Option[DRI] = Option(symbol).filterNot(_.isHiddenByVisibility).map(_.dri) + dotty.tools.scaladoc.Type(symbol.normalizedName, dri) :: suffix private def commas(lists: List[SSignature]) = lists match case List(single) => single