Skip to content

Commit

Permalink
Merge pull request scala#12936 from BarkingBad/scaladoc/no-links-warn…
Browse files Browse the repository at this point in the history
…ings

Add no links warning setting to scaladoc
  • Loading branch information
BarkingBad authored Jul 2, 2021
2 parents 947f8a4 + 99d64a7 commit 147e9ba
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 9 deletions.
14 changes: 14 additions & 0 deletions scaladoc-testcases/src/tests/noLinkWarnings.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package tests
package noLinkWarnings

/**
* [[doesnt.exist]]
*
*/
class NoLinkWarnings


/**
* [[NoLinkWarnings]]
*/
class Exists
2 changes: 2 additions & 0 deletions scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ object Scaladoc:
documentSyntheticTypes: Boolean = false,
snippetCompiler: List[String] = Nil,
snippetCompilerDebug: Boolean = false,
noLinkWarnings: Boolean = false,
versionsDictionaryUrl: Option[String] = None
)

Expand Down Expand Up @@ -196,6 +197,7 @@ object Scaladoc:
docCanonicalBaseUrl.get,
YdocumentSyntheticTypes.get,
snippetCompiler.get,
noLinkWarnings.get,
snippetCompilerDebug.get,
versionsDictionaryUrl.nonDefault
)
Expand Down
6 changes: 6 additions & 0 deletions scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings:
"./docs"
)

val noLinkWarnings: Setting[Boolean] = BooleanSetting(
"-no-link-warnings",
"Avoid warnings for ambiguous and incorrect links in members look up. Doesn't affect warnings for incorrect links of assets etc.",
false
)

val versionsDictionaryUrl: Setting[String] = StringSetting(
"-versions-dictionary-url",
"versions dictionary url",
Expand Down
10 changes: 4 additions & 6 deletions scaladoc/src/dotty/tools/scaladoc/tasty/comments/Comments.scala
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,10 @@ abstract class MarkupConversion[T](val repr: Repr)(using dctx: DocContext) {
case None =>
val txt = s"No DRI found for query"
val msg = s"$txt: $queryStr"
// TODO change to the commented-out version when we'll get rid of the warnings in stdlib
// report.warning(
// msg,
// owner.pos.get.asInstanceOf[dotty.tools.dotc.util.SrcPos],
// )
report.inform(msg)

if (!summon[DocContext].args.noLinkWarnings) then
report.warning(msg, owner.pos.get.asInstanceOf[dotty.tools.dotc.util.SrcPos])

DocLink.UnresolvedDRI(queryStr, txt)

private val SchemeUri = """[a-z]+:.*""".r
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ trait MemberLookup {
res
catch
case e: Exception =>
// TODO (https://github.com/lampepfl/scala3doc/issues/238): proper reporting
val msg = s"Unable to find a link for ${query} ${ownerOpt.fold("")(o => "in " + o.name)}"
report.warn(msg, e)
if (!summon[DocContext].args.noLinkWarnings) then
val msg = s"Unable to find a link for ${query} ${ownerOpt.fold("")(o => "in " + o.name)}"
report.warn(msg, e)
None

private def hackMembersOf(using Quotes)(rsym: reflect.Symbol) = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package dotty.tools.scaladoc
package noLinkWarnings

import org.junit.Assert.assertEquals

class LinkWarningsTest extends ScaladocTest("noLinkWarnings"):

override def args = Scaladoc.Args(
name = "test",
tastyFiles = tastyFiles(name),
output = getTempDir().getRoot,
projectVersion = Some("1.0")
)

override def runTest = afterRendering {
val diagnostics = summon[DocContext].compilerContext.reportedDiagnostics
assertEquals("There should be exactly one warning", 1, diagnostics.warningMsgs.size)
assertNoErrors(diagnostics)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package dotty.tools.scaladoc
package noLinkWarnings

class NoLinkWarningsTest extends ScaladocTest("noLinkWarnings"):

override def args = Scaladoc.Args(
name = "test",
tastyFiles = tastyFiles(name),
output = getTempDir().getRoot,
projectVersion = Some("1.0"),
noLinkWarnings = true
)

override def runTest = afterRendering {
val diagnostics = summon[DocContext].compilerContext.reportedDiagnostics
assertNoWarning(diagnostics)
assertNoErrors(diagnostics)
}

0 comments on commit 147e9ba

Please sign in to comment.