Skip to content

Commit be70d46

Browse files
authored
Fix: -no-link-warnings does not work (#17028)
## Goal There are two purposes to this PR, the first is to add warning suppression when the path to the file is inneficient and a warning suppression flag is set. The second one is to deprecate the current flag and introduce a new to avoid the ambiguity. One for dead links with the current meaning, and one with dead links in assets. The goal is to avoid the confusion with overloading of the naming. I wonder if I also change the name of the previous flag to be more precise in its use. ## Flags noLinkWarnings - Boolean "-no-link-warnings", "Avoid warnings for ambiguous and incorrect links in members look up. Doesn't affect warnings for incorrect links of assets etc." noLinkAssetWarnings - Boolean "-no-link-asset-warnings", "Avoid warnings for incorrect links of assets like images, static pages, etc.", false ## Before : <img width="700" alt="Screenshot 2023-03-13 at 16 25 03" src="https://user-images.githubusercontent.com/44496264/224748941-65f08ba5-0498-4a0c-82b4-38b3921fcddd.png"> ## After : <img width="700" alt="Screenshot 2023-03-13 at 16 28 02" src="https://user-images.githubusercontent.com/44496264/224748976-dcd1825b-e4e7-48b4-b093-cc4f86a78fb0.png"> Fixes #16694
1 parent b614d84 commit be70d46

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

project/ScaladocGeneration.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ object ScaladocGeneration {
9797
def key: String = "-no-link-warnings"
9898
}
9999

100+
case class NoLinkAssetWarnings(value: Boolean) extends Arg[Boolean] {
101+
def key: String = "-no-link-asset-warnings"
102+
}
103+
100104
case class VersionsDictionaryUrl(value: String) extends Arg[String] {
101105
def key: String = "-versions-dictionary-url"
102106
}

scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ object Scaladoc:
3939
documentSyntheticTypes: Boolean = false,
4040
snippetCompiler: List[String] = Nil,
4141
noLinkWarnings: Boolean = false,
42+
noLinkAssetWarnings: Boolean = false,
4243
versionsDictionaryUrl: Option[String] = None,
4344
generateInkuire : Boolean = false,
4445
apiSubdirectory : Boolean = false,
@@ -221,6 +222,7 @@ object Scaladoc:
221222
YdocumentSyntheticTypes.get,
222223
snippetCompiler.get,
223224
noLinkWarnings.get,
225+
noLinkAssetWarnings.get,
224226
versionsDictionaryUrl.nonDefault,
225227
generateInkuire.get,
226228
apiSubdirectory.get,

scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings:
8787
false
8888
)
8989

90+
val noLinkAssetWarnings: Setting[Boolean] = BooleanSetting(
91+
"-no-link-asset-warnings",
92+
"Avoid warnings for incorrect links of assets like images, static pages, etc.",
93+
false
94+
)
95+
9096
val versionsDictionaryUrl: Setting[String] = StringSetting(
9197
"-versions-dictionary-url",
9298
"versions dictionary url",

scaladoc/src/dotty/tools/scaladoc/renderers/SiteRenderer.scala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,10 @@ trait SiteRenderer(using DocContext) extends Locations:
6363
.orElse(asStaticSite)
6464
.orElse(asAsset)
6565
.getOrElse {
66-
report.warn(s"Unable to resolve link '$str'", content.template.templateFile.file)
66+
if (!summon[DocContext].args.noLinkAssetWarnings){
67+
val msg = s"Unable to resolve link '$str'"
68+
report.warn(msg, content.template.templateFile.file)
69+
}
6770
str
6871
}
6972

0 commit comments

Comments
 (0)