File tree 7 files changed +66
-9
lines changed
test/dotty/tools/scaladoc/no-link-warnings
scaladoc-testcases/src/tests
7 files changed +66
-9
lines changed Original file line number Diff line number Diff line change
1
+ package tests
2
+ package noLinkWarnings
3
+
4
+ /**
5
+ * [[doesnt.exist ]]
6
+ *
7
+ */
8
+ class NoLinkWarnings
9
+
10
+
11
+ /**
12
+ * [[NoLinkWarnings ]]
13
+ */
14
+ class Exists
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ object Scaladoc:
52
52
documentSyntheticTypes : Boolean = false ,
53
53
snippetCompiler : List [String ] = Nil ,
54
54
snippetCompilerDebug : Boolean = false ,
55
+ noLinkWarnings : Boolean = false ,
55
56
versionsDictionaryUrl : Option [String ] = None
56
57
)
57
58
@@ -196,6 +197,7 @@ object Scaladoc:
196
197
docCanonicalBaseUrl.get,
197
198
YdocumentSyntheticTypes .get,
198
199
snippetCompiler.get,
200
+ noLinkWarnings.get,
199
201
snippetCompilerDebug.get,
200
202
versionsDictionaryUrl.nonDefault
201
203
)
Original file line number Diff line number Diff line change @@ -93,6 +93,12 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings:
93
93
" ./docs"
94
94
)
95
95
96
+ val noLinkWarnings : Setting [Boolean ] = BooleanSetting (
97
+ " -no-link-warnings" ,
98
+ " Avoid warnings for ambiguous and incorrect links in members look up. Doesn't affect warnings for incorrect links of assets etc." ,
99
+ false
100
+ )
101
+
96
102
val versionsDictionaryUrl : Setting [String ] = StringSetting (
97
103
" -versions-dictionary-url" ,
98
104
" versions dictionary url" ,
Original file line number Diff line number Diff line change @@ -109,12 +109,10 @@ abstract class MarkupConversion[T](val repr: Repr)(using dctx: DocContext) {
109
109
case None =>
110
110
val txt = s " No DRI found for query "
111
111
val msg = s " $txt: $queryStr"
112
- // TODO change to the commented-out version when we'll get rid of the warnings in stdlib
113
- // report.warning(
114
- // msg,
115
- // owner.pos.get.asInstanceOf[dotty.tools.dotc.util.SrcPos],
116
- // )
117
- report.inform(msg)
112
+
113
+ if (! summon[DocContext ].args.noLinkWarnings) then
114
+ report.warning(msg, owner.pos.get.asInstanceOf [dotty.tools.dotc.util.SrcPos ])
115
+
118
116
DocLink .UnresolvedDRI (queryStr, txt)
119
117
120
118
private val SchemeUri = """ [a-z]+:.*""" .r
Original file line number Diff line number Diff line change @@ -86,9 +86,9 @@ trait MemberLookup {
86
86
res
87
87
catch
88
88
case e : Exception =>
89
- // TODO (https://github.com/lampepfl/scala3doc/issues/238): proper reporting
90
- val msg = s " Unable to find a link for ${query} ${ownerOpt.fold(" " )(o => " in " + o.name)}"
91
- report.warn(msg, e)
89
+ if ( ! summon[ DocContext ].args.noLinkWarnings) then
90
+ val msg = s " Unable to find a link for ${query} ${ownerOpt.fold(" " )(o => " in " + o.name)}"
91
+ report.warn(msg, e)
92
92
None
93
93
94
94
private def hackMembersOf (using Quotes )(rsym : reflect.Symbol ) = {
Original file line number Diff line number Diff line change
1
+ package dotty .tools .scaladoc
2
+ package noLinkWarnings
3
+
4
+ import org .junit .Assert .assertEquals
5
+
6
+ class LinkWarningsTest extends ScaladocTest (" noLinkWarnings" ):
7
+
8
+ override def args = Scaladoc .Args (
9
+ name = " test" ,
10
+ tastyFiles = tastyFiles(name),
11
+ output = getTempDir().getRoot,
12
+ projectVersion = Some (" 1.0" )
13
+ )
14
+
15
+ override def runTest = afterRendering {
16
+ val diagnostics = summon[DocContext ].compilerContext.reportedDiagnostics
17
+ assertEquals(" There should be exactly one warning" , 1 , diagnostics.warningMsgs.size)
18
+ assertNoErrors(diagnostics)
19
+ }
Original file line number Diff line number Diff line change
1
+ package dotty .tools .scaladoc
2
+ package noLinkWarnings
3
+
4
+ class NoLinkWarningsTest extends ScaladocTest (" noLinkWarnings" ):
5
+
6
+ override def args = Scaladoc .Args (
7
+ name = " test" ,
8
+ tastyFiles = tastyFiles(name),
9
+ output = getTempDir().getRoot,
10
+ projectVersion = Some (" 1.0" ),
11
+ noLinkWarnings = true
12
+ )
13
+
14
+ override def runTest = afterRendering {
15
+ val diagnostics = summon[DocContext ].compilerContext.reportedDiagnostics
16
+ assertNoWarning(diagnostics)
17
+ assertNoErrors(diagnostics)
18
+ }
You can’t perform that action at this time.
0 commit comments