Fix of the new javadoc search functionality (#26604)
Search target for classes would contain a module path part which was undefined. Disabled with --no-module-directories
This commit is contained in:
parent
03897dd6e0
commit
1a90f22fb4
1 changed files with 64 additions and 47 deletions
|
|
@ -5,7 +5,7 @@
|
||||||
package akka
|
package akka
|
||||||
|
|
||||||
import sbt._
|
import sbt._
|
||||||
import sbtunidoc.BaseUnidocPlugin.autoImport.{unidoc, unidocProjectFilter, unidocAllSources}
|
import sbtunidoc.BaseUnidocPlugin.autoImport.{ unidoc, unidocAllSources, unidocProjectFilter }
|
||||||
import sbtunidoc.JavaUnidocPlugin.autoImport.JavaUnidoc
|
import sbtunidoc.JavaUnidocPlugin.autoImport.JavaUnidoc
|
||||||
import sbtunidoc.ScalaUnidocPlugin.autoImport.ScalaUnidoc
|
import sbtunidoc.ScalaUnidocPlugin.autoImport.ScalaUnidoc
|
||||||
import sbtunidoc.GenJavadocPlugin.autoImport._
|
import sbtunidoc.GenJavadocPlugin.autoImport._
|
||||||
|
|
@ -28,18 +28,19 @@ object Scaladoc extends AutoPlugin {
|
||||||
val validateDiagrams = settingKey[Boolean]("Validate generated scaladoc diagrams")
|
val validateDiagrams = settingKey[Boolean]("Validate generated scaladoc diagrams")
|
||||||
|
|
||||||
override lazy val projectSettings = {
|
override lazy val projectSettings = {
|
||||||
inTask(doc)(Seq(
|
inTask(doc)(
|
||||||
scalacOptions in Compile ++= scaladocOptions(version.value, (baseDirectory in ThisBuild).value),
|
Seq(
|
||||||
// -release caused build failures when generating javadoc:
|
scalacOptions in Compile ++= scaladocOptions(version.value, (baseDirectory in ThisBuild).value),
|
||||||
scalacOptions in Compile --= Seq("-release", "8"),
|
// -release caused build failures when generating javadoc:
|
||||||
autoAPIMappings := CliOptions.scaladocAutoAPI.get)) ++
|
scalacOptions in Compile --= Seq("-release", "8"),
|
||||||
Seq(validateDiagrams in Compile := true) ++
|
autoAPIMappings := CliOptions.scaladocAutoAPI.get)) ++
|
||||||
CliOptions.scaladocDiagramsEnabled.ifTrue(doc in Compile := {
|
Seq(validateDiagrams in Compile := true) ++
|
||||||
val docs = (doc in Compile).value
|
CliOptions.scaladocDiagramsEnabled.ifTrue(doc in Compile := {
|
||||||
if ((validateDiagrams in Compile).value)
|
val docs = (doc in Compile).value
|
||||||
scaladocVerifier(docs)
|
if ((validateDiagrams in Compile).value)
|
||||||
docs
|
scaladocVerifier(docs)
|
||||||
})
|
docs
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
def scaladocOptions(ver: String, base: File): List[String] = {
|
def scaladocOptions(ver: String, base: File): List[String] = {
|
||||||
|
|
@ -56,17 +57,21 @@ object Scaladoc extends AutoPlugin {
|
||||||
val curr = dirs.head
|
val curr = dirs.head
|
||||||
val (newDirs, files) = curr.listFiles.partition(_.isDirectory)
|
val (newDirs, files) = curr.listFiles.partition(_.isDirectory)
|
||||||
val rest = dirs.tail ++ newDirs
|
val rest = dirs.tail ++ newDirs
|
||||||
val hasDiagram = files exists { f =>
|
val hasDiagram = files.exists { f =>
|
||||||
val name = f.getName
|
val name = f.getName
|
||||||
if (name.endsWith(".html") && !name.startsWith("index-") &&
|
if (name.endsWith(".html") && !name.startsWith("index-") &&
|
||||||
!name.equals("index.html") && !name.equals("package.html")) {
|
!name.equals("index.html") && !name.equals("package.html")) {
|
||||||
val source = scala.io.Source.fromFile(f)(scala.io.Codec.UTF8)
|
val source = scala.io.Source.fromFile(f)(scala.io.Codec.UTF8)
|
||||||
val hd = try source.getLines().exists(lines =>
|
val hd = try source
|
||||||
lines.contains("<div class=\"toggleContainer block diagram-container\" id=\"inheritance-diagram-container\">") ||
|
.getLines()
|
||||||
lines.contains("<svg id=\"graph")
|
.exists(
|
||||||
)
|
lines =>
|
||||||
|
lines.contains(
|
||||||
|
"<div class=\"toggleContainer block diagram-container\" id=\"inheritance-diagram-container\">") ||
|
||||||
|
lines.contains("<svg id=\"graph"))
|
||||||
catch {
|
catch {
|
||||||
case e: Exception => throw new IllegalStateException("Scaladoc verification failed for file '" + f + "'", e)
|
case e: Exception =>
|
||||||
|
throw new IllegalStateException("Scaladoc verification failed for file '" + f + "'", e)
|
||||||
} finally source.close()
|
} finally source.close()
|
||||||
hd
|
hd
|
||||||
} else false
|
} else false
|
||||||
|
|
@ -91,8 +96,7 @@ object ScaladocNoVerificationOfDiagrams extends AutoPlugin {
|
||||||
override def trigger = noTrigger
|
override def trigger = noTrigger
|
||||||
override def requires = Scaladoc
|
override def requires = Scaladoc
|
||||||
|
|
||||||
override lazy val projectSettings = Seq(
|
override lazy val projectSettings = Seq(Scaladoc.validateDiagrams in Compile := false)
|
||||||
Scaladoc.validateDiagrams in Compile := false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -111,26 +115,38 @@ object UnidocRoot extends AutoPlugin {
|
||||||
|
|
||||||
override def trigger = noTrigger
|
override def trigger = noTrigger
|
||||||
override def requires =
|
override def requires =
|
||||||
UnidocRoot.CliOptions.genjavadocEnabled.ifTrue(sbtunidoc.ScalaUnidocPlugin && sbtunidoc.JavaUnidocPlugin && sbtunidoc.GenJavadocPlugin)
|
UnidocRoot.CliOptions.genjavadocEnabled
|
||||||
|
.ifTrue(sbtunidoc.ScalaUnidocPlugin && sbtunidoc.JavaUnidocPlugin && sbtunidoc.GenJavadocPlugin)
|
||||||
.getOrElse(sbtunidoc.ScalaUnidocPlugin)
|
.getOrElse(sbtunidoc.ScalaUnidocPlugin)
|
||||||
|
|
||||||
val akkaSettings = UnidocRoot.CliOptions.genjavadocEnabled.ifTrue(
|
val akkaSettings = UnidocRoot.CliOptions.genjavadocEnabled
|
||||||
Seq(javacOptions in (JavaUnidoc, unidoc) := Seq("-Xdoclint:none", "--frames", "--ignore-source-errors"))).getOrElse(Nil)
|
.ifTrue(
|
||||||
|
Seq(
|
||||||
|
javacOptions in (JavaUnidoc, unidoc) := Seq(
|
||||||
|
"-Xdoclint:none",
|
||||||
|
"--frames",
|
||||||
|
"--ignore-source-errors",
|
||||||
|
"--no-module-directories")))
|
||||||
|
.getOrElse(Nil)
|
||||||
|
|
||||||
override lazy val projectSettings = {
|
override lazy val projectSettings = {
|
||||||
def unidocRootProjectFilter(ignoreProjects: Seq[ProjectReference]): ProjectFilter =
|
def unidocRootProjectFilter(ignoreProjects: Seq[ProjectReference]): ProjectFilter =
|
||||||
ignoreProjects.foldLeft(inAnyProject) { _ -- inProjects(_) }
|
ignoreProjects.foldLeft(inAnyProject) { _ -- inProjects(_) }
|
||||||
|
|
||||||
inTask(unidoc)(Seq(
|
inTask(unidoc)(
|
||||||
unidocProjectFilter in ScalaUnidoc := unidocRootProjectFilter(unidocRootIgnoreProjects.value),
|
Seq(
|
||||||
unidocProjectFilter in JavaUnidoc := unidocRootProjectFilter(unidocRootIgnoreProjects.value),
|
unidocProjectFilter in ScalaUnidoc := unidocRootProjectFilter(unidocRootIgnoreProjects.value),
|
||||||
apiMappings in ScalaUnidoc := (apiMappings in (Compile, doc)).value) ++
|
unidocProjectFilter in JavaUnidoc := unidocRootProjectFilter(unidocRootIgnoreProjects.value),
|
||||||
UnidocRoot.CliOptions.genjavadocEnabled.ifTrue(Seq(
|
apiMappings in ScalaUnidoc := (apiMappings in (Compile, doc)).value) ++
|
||||||
// akka.stream.scaladsl.GraphDSL.Implicits.ReversePortsOps contains code that
|
UnidocRoot.CliOptions.genjavadocEnabled
|
||||||
// genjavadoc turns into (probably incorrect) Java code that in turn confuses the javadoc tool.
|
.ifTrue(
|
||||||
unidocAllSources in JavaUnidoc ~= { v => v.map(_.filterNot(_.getAbsolutePath.endsWith("scaladsl/GraphDSL.java"))) },
|
Seq(
|
||||||
)).getOrElse(Nil)
|
// akka.stream.scaladsl.GraphDSL.Implicits.ReversePortsOps contains code that
|
||||||
)
|
// genjavadoc turns into (probably incorrect) Java code that in turn confuses the javadoc tool.
|
||||||
|
unidocAllSources in JavaUnidoc ~= { v =>
|
||||||
|
v.map(_.filterNot(_.getAbsolutePath.endsWith("scaladsl/GraphDSL.java")))
|
||||||
|
}))
|
||||||
|
.getOrElse(Nil))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -140,17 +156,18 @@ object UnidocRoot extends AutoPlugin {
|
||||||
object BootstrapGenjavadoc extends AutoPlugin {
|
object BootstrapGenjavadoc extends AutoPlugin {
|
||||||
|
|
||||||
override def trigger = allRequirements
|
override def trigger = allRequirements
|
||||||
override def requires = UnidocRoot.CliOptions.genjavadocEnabled.ifTrue {
|
override def requires =
|
||||||
val onJdk8 = System.getProperty("java.version").startsWith("1.")
|
UnidocRoot.CliOptions.genjavadocEnabled
|
||||||
require(!onJdk8, "Javadoc generation requires at least jdk 11")
|
.ifTrue {
|
||||||
sbtunidoc.GenJavadocPlugin
|
val onJdk8 = System.getProperty("java.version").startsWith("1.")
|
||||||
}
|
require(!onJdk8, "Javadoc generation requires at least jdk 11")
|
||||||
.getOrElse(plugins.JvmPlugin)
|
sbtunidoc.GenJavadocPlugin
|
||||||
|
}
|
||||||
|
.getOrElse(plugins.JvmPlugin)
|
||||||
|
|
||||||
override lazy val projectSettings = UnidocRoot.CliOptions.genjavadocEnabled.ifTrue(
|
override lazy val projectSettings = UnidocRoot.CliOptions.genjavadocEnabled
|
||||||
Seq(
|
.ifTrue(Seq(
|
||||||
unidocGenjavadocVersion := "0.12",
|
unidocGenjavadocVersion := "0.12",
|
||||||
scalacOptions in Compile ++= Seq("-P:genjavadoc:fabricateParams=true", "-P:genjavadoc:suppressSynthetic=false")
|
scalacOptions in Compile ++= Seq("-P:genjavadoc:fabricateParams=true", "-P:genjavadoc:suppressSynthetic=false")))
|
||||||
)
|
.getOrElse(Nil)
|
||||||
).getOrElse(Nil)
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue