Skip to content
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

Add no links warning setting to scaladoc #12936

Merged
merged 2 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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 ONLY in members look up. Doesn't affect incorrect links of assets etc.",
BarkingBad marked this conversation as resolved.
Show resolved Hide resolved
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
Copy link
Contributor

Choose a reason for hiding this comment

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

Requisite "extraneous parens" reminder.

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 exaclyt 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)
}