Skip to content

Commit

Permalink
Rename scala3doc to scaladoc in sbt plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
romanowski committed Feb 4, 2021
1 parent ac51595 commit f75e6fb
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/scaladoc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:
run: ./project/scripts/sbt scaladoc/generateTestcasesDocumentation

- name: Generate Scala 3 documentation
run: ./project/scripts/sbt scaladoc/generatescaladocumentation
run: ./project/scripts/sbt scaladoc/generateScalaDocumentation

- name: Generate documentation for example project using dotty-sbt
run: ./project/scripts/sbt "sbt-dotty/scripted sbt-dotty/scaladoc"
Expand Down
4 changes: 2 additions & 2 deletions community-build/src/scala/dotty/communitybuild/projects.scala
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ final case class SbtCommunityProject(

override val publishCommand = if sbtPublishCommand eq null then null else
val disableDocCommand =
if sbtDocCommand eq null then "" else "set every usescaladoc := false;"
if sbtDocCommand eq null then "" else "set every useScaladoc := false;"
s"$baseCommand$disableDocCommand$sbtPublishCommand"
override val docCommand =
if sbtDocCommand eq null then null else
val cmd = if sbtDocCommand.startsWith(";") then sbtDocCommand else s";$sbtDocCommand"
s"$baseCommand set every usescaladoc := true; set every doc/logLevel := Level.Warn $cmd "
s"$baseCommand set every useScaladoc := true; set every doc/logLevel := Level.Warn $cmd "

override val runCommandsArgs: List[String] =
// Run the sbt command with the compiler version and sbt plugin set in the build
Expand Down
22 changes: 11 additions & 11 deletions project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1227,12 +1227,12 @@ object Build {
val testDocumentationRoot = taskKey[String]("Root directory where tests documentation are stored")
val generateSelfDocumentation = taskKey[Unit]("Generate example documentation")
// Note: the two tasks below should be one, but a bug in Tasty prevents that
val generatescaladocumentation = inputKey[Unit]("Generate documentation for dotty lib")
val generateScalaDocumentation = inputKey[Unit]("Generate documentation for dotty lib")
val generateTestcasesDocumentation = taskKey[Unit]("Generate documentation for testcases, usefull for debugging tests")
lazy val `scaladoc` = project.in(file("scaladoc")).asscaladoc
lazy val `scaladoc-testcases` = project.in(file("scaladoc-testcases")).asscaladocTestcases
lazy val `scaladoc` = project.in(file("scaladoc")).asScaladoc
lazy val `scaladoc-testcases` = project.in(file("scaladoc-testcases")).asScaladocTestcases

lazy val `scaladoc-js` = project.in(file("scaladoc-js")).asscaladocJs
lazy val `scaladoc-js` = project.in(file("scaladoc-js")).asScaladocJs

// sbt plugin to use Dotty in your own build, see
// https://github.com/lampepfl/scala3-example-project for usage.
Expand Down Expand Up @@ -1531,7 +1531,7 @@ object Build {
settings(commonBenchmarkSettings).
enablePlugins(JmhPlugin)

def asscaladoc: Project = {
def asScaladoc: Project = {
def generateDocumentation(targets: String, name: String, outDir: String, ref: String, params: String = "") = Def.taskDyn {
val projectVersion = version.value
IO.createDirectory(file(outDir))
Expand Down Expand Up @@ -1570,7 +1570,7 @@ object Build {
Test / test := (Test / test).dependsOn(compile.in(Compile).in(`scaladoc-testcases`)).value,
testcasesOutputDir.in(Test) := joinProducts((`scaladoc-testcases`/Compile/products).value),
testcasesSourceRoot.in(Test) := (baseDirectory.in(`scaladoc-testcases`).value / "src").getAbsolutePath.toString,
Compile / mainClass := Some("dotty.dokka.Main"),
Compile / mainClass := Some("dotty.tools.scaladoc.Main"),
baseDirectory.in(run) := baseDirectory.in(ThisBuild).value,
generateSelfDocumentation := Def.taskDyn {
generateDocumentation(
Expand All @@ -1583,7 +1583,7 @@ object Build {
)
}.value,

generatescaladocumentation := Def.inputTaskDyn {
generateScalaDocumentation := Def.inputTaskDyn {
val dottydocExtraArgs = spaceDelimited("[output]").parsed
val dest = file(dottydocExtraArgs.headOption.getOrElse("scaladoc/output/scala3")).getAbsoluteFile
val majorVersion = (scalaBinaryVersion in LocalProject("scala3-library-bootstrapped")).value
Expand Down Expand Up @@ -1636,7 +1636,7 @@ object Build {
Build.testDocumentationRoot,
),
Compile / buildInfoKeys := Seq[BuildInfoKey](version),
Compile / buildInfoPackage := "dotty.dokka",
Compile / buildInfoPackage := "dotty.tools.scaladoc",
Compile / resourceGenerators += Def.task {
val jsDestinationFile = (Compile / resourceManaged).value / "dotty_res" / "scripts" / "searchbar.js"
sbt.IO.copyFile((fullOptJS in Compile in `scaladoc-js`).value.data, jsDestinationFile)
Expand All @@ -1651,17 +1651,17 @@ object Build {
}.apply(Set(cssSourceFile)).toSeq
}.taskValue,
testDocumentationRoot := (baseDirectory.value / "test-documentations").getAbsolutePath,
buildInfoPackage in Test := "dotty.dokka.test",
buildInfoPackage in Test := "dotty.tools.scaladoc.test",
BuildInfoPlugin.buildInfoScopedSettings(Test),
BuildInfoPlugin.buildInfoScopedSettings(Compile),
BuildInfoPlugin.buildInfoDefaultSettings,
)
}

def asscaladocTestcases: Project =
def asScaladocTestcases: Project =
project.dependsOn(`scala3-compiler-bootstrapped`).settings(commonBootstrappedSettings)

def asscaladocJs: Project =
def asScaladocJs: Project =
project.
enablePlugins(MyScalaJSPlugin).
dependsOn(`scala3-library-bootstrappedJS`).
Expand Down
2 changes: 1 addition & 1 deletion project/scripts/genDocs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ git checkout "$GIT_HEAD"
### Generate the current snapshot of the website ###
# this command will generate docs in $PWD/docs/_site
SBT="$SCRIPT_DIR/sbt"
"$SBT" "scaladoc/generatescaladocumentation docs/_site"
"$SBT" "scaladoc/generateScalaDocumentation docs/_site"

# make sure that the previous command actually succeeded
if [ ! -d "$SITE_OUT_DIR" ]; then
Expand Down
2 changes: 1 addition & 1 deletion sbt-dotty/sbt-test/sbt-dotty/scaladoc/build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ scalaVersion := sys.props("plugin.scalaVersion")
lazy val assertUsingscaladoc = taskKey[Unit]("")

assertUsingscaladoc := {
assert(usescaladoc.value)
assert(useScaladoc.value)
}
24 changes: 14 additions & 10 deletions sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ object DottyPlugin extends AutoPlugin {
val isDotty = settingKey[Boolean]("Is this project compiled with Dotty?")
val isDottyJS = settingKey[Boolean]("Is this project compiled with Dotty and Scala.js?")

val usescaladoc = settingKey[Boolean]("Use scaladoc as the documentation tool")
val useScaladoc = settingKey[Boolean]("Use scaladoc as the documentation tool")
val useScala3doc = useScaladoc
val tastyFiles = taskKey[Seq[File]]("List all testy files")

// NOTE:
Expand Down Expand Up @@ -370,18 +371,21 @@ object DottyPlugin extends AutoPlugin {
}.value,

// Configuration for the doctool
resolvers ++= (if(!usescaladoc.value) Nil else Seq(Resolver.jcenterRepo)),
usescaladoc := {
resolvers ++= (if(!useScaladoc.value) Nil else Seq(Resolver.jcenterRepo)),
useScaladoc := {
val v = scalaVersion.value
v.startsWith("3.0.0") && !v.startsWith("3.0.0-M1") && !v.startsWith("3.0.0-M2")
},
// We need to add doctool classes to the classpath so they can be called
scalaInstance in doc := Def.taskDyn {
if (isDotty.value)
if (usescaladoc.value)
dottyScalaInstanceTask("scaladoc")
else
dottyScalaInstanceTask(scala3Artefact(scalaVersion.value, "doc"))
if (useScaladoc.value) {
val v = scalaVersion.value
val shouldUseScala3doc =
v.startsWith("3.0.0-M1") || v.startsWith("3.0.0-M2") || v.startsWith("3.0.0-M3") || v.startsWith("3.0.0-RC1-bin-20210")
val name = if (shouldUseScala3doc) "scala3doc" else "scaladoc"
dottyScalaInstanceTask(name)
} else dottyScalaInstanceTask(scala3Artefact(scalaVersion.value, "doc"))
else
Def.valueStrict { (scalaInstance in doc).taskValue }
}.value,
Expand Down Expand Up @@ -455,7 +459,7 @@ object DottyPlugin extends AutoPlugin {
},
sources := Def.taskDyn[Seq[File]] {
val originalSources = sources.value
if (isDotty.value && usescaladoc.value && originalSources.nonEmpty)
if (isDotty.value && useScaladoc.value && originalSources.nonEmpty)
Def.task { tastyFiles.value }
else Def.task { originalSources }
}.value,
Expand Down Expand Up @@ -489,9 +493,9 @@ object DottyPlugin extends AutoPlugin {
dependencyRes.update(descriptor, updateConfig, warningConfig, log) match {
case Right(report) =>
report
case _ =>
case Left(warning) =>
throw new MessageOnlyException(
s"Couldn't retrieve `$moduleID`.")
s"Couldn't retrieve `$moduleID` : ${warning.resolveException.getMessage}.")
}
}

Expand Down
6 changes: 3 additions & 3 deletions scaladoc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Use the following commands to generate documentation for this project and for Do

```
sbt scaladoc/generateSelfDocumentation
sbt scaladoc/generatescaladocumentation
sbt scaladoc/generateScalaDocumentation
```

To actually view the documentation, the easiest way is to run the following in project root:
Expand Down Expand Up @@ -73,8 +73,8 @@ You can also find the result of building the same sites for latest `master` at:
### Testing

Most tests rely on comparing signatures (of classes, methods, objects etc.) extracted from the generated documentation
to signatures found in source files. Such tests are defined using [MultipleFileTest](test/dotty/tools/scala3doc/MultipleFileTest.scala) class
and its subtypes (such as [SingleFileTest](test/dotty/tools/scala3doc/SingleFileTest.scala))
to signatures found in source files. Such tests are defined using [MultipleFileTest](test/dotty/tools/scaladoc/MultipleFileTest.scala) class
and its subtypes (such as [SingleFileTest](test/dotty/tools/scaladoc/SingleFileTest.scala))

WARNING: As the classes mentioned above are likely to evolve, the description below might easily get out of date.
In case of any discrepancies rely on the source files instead.
Expand Down

0 comments on commit f75e6fb

Please sign in to comment.