Skip to content

Scaladoc: Add scaladoc binary test #12789

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 8 additions & 18 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1241,7 +1241,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, usingScript: Boolean = true) =
def generateDocumentation(targets: Seq[String], name: String, outDir: String, ref: String, params: Seq[String] = Nil) =
Def.taskDyn {
val distLocation = (dist / pack).value
val projectVersion = version.value
Expand All @@ -1265,20 +1265,10 @@ object Build {
s"-source-links:github://lampepfl/dotty/$referenceVersion",
) ++ scalacOptionsDocSettings ++ revision ++ params ++ targets
import _root_.scala.sys.process._
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line is no longer needed.

if (usingScript)
Def.task((s"$distLocation/bin/scaladoc" +: cmd).!)
else {
val escapedCmd = cmd.map(arg => if(arg.contains(" ")) s""""$arg"""" else arg)
Def.task {
try {
(Compile / run).toTask(escapedCmd.mkString(" ", " ", "")).value
0
} catch {
case _ : Throwable => 1
}
}
val escapedCmd = cmd.map(arg => if(arg.contains(" ")) s""""$arg"""" else arg)
Def.task {
(Compile / run).toTask(escapedCmd.mkString(" ", " ", "")).value
}

}

val SourceLinksIntegrationTest = config("sourceLinksIntegrationTest") extend Test
Expand Down Expand Up @@ -1325,7 +1315,7 @@ object Build {
generateSelfDocumentation := Def.taskDyn {
generateDocumentation(
(Compile / classDirectory).value.getAbsolutePath :: Nil,
"scaladoc", "scaladoc/output/self", VersionUtil.gitHash
"scaladoc", "scaladoc/output/self", VersionUtil.gitHash, Seq("-usejavacp")
)
}.value,
generateScalaDocumentation := Def.inputTaskDyn {
Expand Down Expand Up @@ -1366,16 +1356,16 @@ object Build {
s"-source-links:docs=github://lampepfl/dotty/master#docs",
"-doc-root-content", docRootFile.toString,
"-Ydocument-synthetic-types"
), usingScript = false
))
)))
}.evaluated,

generateTestcasesDocumentation := Def.taskDyn {
generateDocumentation(
(Test / Build.testcasesOutputDir).value,
"scaladoc testcases",
"scaladoc/output/testcases",
"master"
"master",
Seq("-usejavacp")
)
}.value,

Expand Down
22 changes: 22 additions & 0 deletions project/scripts/cmdTests
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,28 @@ echo "testing -Ythrough-tasty"
clear_out "$OUT"
"$SBT" ";scalac -Ythrough-tasty $SOURCE"

echo "testing scaladoc script"
clear_out "$OUT"
clear_out "$OUT1"
"$SBT" "scaladoc/generateTestcasesDocumentation" > "$tmp" 2>&1 || echo "generated testcases project with sbt"
dist/target/pack/bin/scaladoc \
-d "$OUT1" \
-project "scaladoc testcases" \
-source-links:out/bootstrap/stdlib-bootstrapped/scala-3.0.2-RC1-bin-SNAPSHOT-nonbootstrapped/src_managed/main/scala-library-src=github://scala/scala/v2.13.6#src/library \
-source-links:out/bootstrap/stdlib-bootstrapped/scala-3.0.2-RC1-bin-SNAPSHOT-nonbootstrapped/src_managed/main/dotty-library-src=github://lampepfl/dotty/3.0.0#library/src \
-source-links:github://lampepfl/dotty/3.0.0 \
"-external-mappings:.*scala.*::scaladoc3::http://dotty.epfl.ch/api/,.*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/" \
"-skip-by-regex:.+\.internal($|\..+)" \
"-skip-by-regex:.+\.impl($|\..+)" \
-project-logo docs/logo.svg \
-social-links:github::https://github.com/lampepfl/dotty,gitter::https://gitter.im/scala/scala,twitter::https://twitter.com/scala_lang \
"-skip-by-id:scala.runtime.stdLibPatches" \
"-skip-by-id:scala.runtime.MatchCase" \
-project-footer "Copyright (c) 2002-2021, LAMP/EPFL" \
-author -groups -revision master -project-version 3.0.2-RC1-bin-SNAPSHOT \
out/bootstrap/scaladoc-testcases/scala-3.0.2-RC1-bin-SNAPSHOT-nonbootstrapped/classes > "$tmp" 2>&1 || echo "generated testcases project with scripts"
diff -rq "$OUT1" "scaladoc/output/testcases"

## Disabled because of flakeyness, should be changed to not depend on sbt
# echo "running Vulpix meta test"
# tmp=$(mktemp)
Expand Down
8 changes: 4 additions & 4 deletions scaladoc-testcases/src/tests/snippetCompilerTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package tests
package snippetCompilerTests

/**
* ```scala sc:compile
* ```scala sc:fail
* //{
* import scala.collection.Seq
* //}
Expand Down Expand Up @@ -34,7 +34,7 @@ package snippetCompilerTests
* a
* ```
*
* ```scala sc:fail
* ```scala sc:compile
* def a = 2
* ```
*
Expand All @@ -48,7 +48,7 @@ class A {
}

/**
* ```scala sc:compile
* ```scala sc:fail
* val c: Int = 4.5
* ```
*/
Expand All @@ -58,7 +58,7 @@ trait Quotes {
val reflect: reflectModule = ???
trait reflectModule { self: reflect.type =>
/**
* ```scala sc:compile
* ```scala sc:fail
* 2 + List()
* ```
*
Expand Down
2 changes: 1 addition & 1 deletion scaladoc-testcases/src/tests/snippetTestcase1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class SnippetTestcase1:
/**
* SNIPPET(OUTERLINEOFFSET:8,OUTERCOLUMNOFFSET:6,INNERLINEOFFSET:3,INNERCOLUMNOFFSET:2)
* ERROR(LINE:8,COLUMN:8)
* ```scala sc:compile
* ```scala sc:fail
* 2 + List()
* ```
*
Expand Down
8 changes: 4 additions & 4 deletions scaladoc-testcases/src/tests/snippetTestcase2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ trait Quotes2[A] {
/**
* SNIPPET(OUTERLINEOFFSET:13,OUTERCOLUMNOFFSET:10,INNERLINEOFFSET:6,INNERCOLUMNOFFSET:6)
* ERROR(LINE:13,COLUMN:12)
* ```scala sc:compile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to change that script to fail?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because the snippets that I've fixed, had wrong flags and were throwing errors on documentation generation. It caused the process to exit with failure and break the script execution

* ```scala sc:fail
* 2 + List()
* ```
*
Expand All @@ -21,7 +21,7 @@ trait Quotes2[A] {
/**
* SNIPPET(OUTERLINEOFFSET:25,OUTERCOLUMNOFFSET:10,INNERLINEOFFSET:7,INNERCOLUMNOFFSET:6)
* ERROR(LINE:25,COLUMN:12)
* ```scala sc:compile
* ```scala sc:fail
* 2 + List()
* ```
*
Expand All @@ -35,7 +35,7 @@ trait Quotes2[A] {
/**
* SNIPPET(OUTERLINEOFFSET:39,OUTERCOLUMNOFFSET:10,INNERLINEOFFSET:5,INNERCOLUMNOFFSET:6)
* ERROR(LINE:39,COLUMN:12)
* ```scala sc:compile
* ```scala sc:fail
* 2 + List()
* ```
*
Expand All @@ -47,7 +47,7 @@ trait Quotes2[A] {
/**
* SNIPPET(OUTERLINEOFFSET:51,OUTERCOLUMNOFFSET:10,INNERLINEOFFSET:6,INNERCOLUMNOFFSET:6)
* ERROR(LINE:51,COLUMN:12)
* ```scala sc:compile
* ```scala sc:fail
* 2 + List()
* ```
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ object DotDiagramBuilder:

val vWithId = diagram.verteciesWithId
val sealedNodes = diagram.sealedNodes
val vertecies = vWithId.map { (vertex, id) =>
val vertecies = vWithId.toList.sortBy((_, id) => id).map { (vertex, id) =>
s"""node${id} [id=node${id}, label="${getHtmlLabel(vertex, renderer, sealedNodes)}", style="${getStyle(vertex.kind)}"];\n"""
}.mkString

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ trait ClassLikeSupport:
)

if signatureOnly then baseMember else baseMember.copy(
members = classDef.extractPatchedMembers,
members = classDef.extractPatchedMembers.sortBy(m => (m.name, m.kind.name)),
directParents = classDef.getParentsAsLinkToTypes,
parents = supertypes,
companion = classDef.getCompanion
Expand Down