Skip to content

Commit

Permalink
Fix links to unexisting types sites
Browse files Browse the repository at this point in the history
  • Loading branch information
pikinier20 committed Nov 10, 2021
1 parent 045c8bd commit 47d52fc
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
20 changes: 11 additions & 9 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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(
Expand Down Expand Up @@ -423,7 +425,7 @@ object Build {
assert(docScalaInstance.loaderCompilerOnly == base.loaderCompilerOnly)
docScalaInstance
},
Compile / doc / scalacOptions ++= scalacOptionsDocSettings
Compile / doc / scalacOptions ++= scalacOptionsDocSettings()
)

lazy val commonBenchmarkSettings = Seq(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
24 changes: 13 additions & 11 deletions scaladoc/src/dotty/tools/scaladoc/tasty/ClassLikeSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)(
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion scaladoc/src/dotty/tools/scaladoc/tasty/TypesSupport.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ trait TypesSupport:

private def tpe(using Quotes)(symbol: reflect.Symbol): SSignature =
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] = if symbol.isHiddenByVisibility then None else symbol.dri
dotty.tools.scaladoc.Type(symbol.normalizedName, dri) :: suffix

private def commas(lists: List[SSignature]) = lists match
case List(single) => single
Expand Down

0 comments on commit 47d52fc

Please sign in to comment.