From 3145b66d1aa9431d38c36edc6c5d9d86ee32f3fb Mon Sep 17 00:00:00 2001 From: Lucas Leblanc <44496264+Dedelweiss@users.noreply.github.com> Date: Tue, 20 Jun 2023 14:54:34 +0200 Subject: [PATCH] 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 : Screenshot 2023-03-13 at 16 25 03 ## After : Screenshot 2023-03-13 at 16 28 02 Fixes #16694 [Cherry-picked be70d465386355f07c0a29b756865ce47fcb5974] --- project/ScaladocGeneration.scala | 4 ++++ scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala | 2 ++ scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala | 6 ++++++ .../src/dotty/tools/scaladoc/renderers/SiteRenderer.scala | 5 ++++- 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/project/ScaladocGeneration.scala b/project/ScaladocGeneration.scala index fd972311da1d..ade9b65d5445 100644 --- a/project/ScaladocGeneration.scala +++ b/project/ScaladocGeneration.scala @@ -97,6 +97,10 @@ object ScaladocGeneration { def key: String = "-no-link-warnings" } + case class NoLinkAssetWarnings(value: Boolean) extends Arg[Boolean] { + def key: String = "-no-link-asset-warnings" + } + case class VersionsDictionaryUrl(value: String) extends Arg[String] { def key: String = "-versions-dictionary-url" } diff --git a/scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala b/scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala index f8e2ca0c776e..0ff700da8cf2 100644 --- a/scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala +++ b/scaladoc/src/dotty/tools/scaladoc/Scaladoc.scala @@ -39,6 +39,7 @@ object Scaladoc: documentSyntheticTypes: Boolean = false, snippetCompiler: List[String] = Nil, noLinkWarnings: Boolean = false, + noLinkAssetWarnings: Boolean = false, versionsDictionaryUrl: Option[String] = None, generateInkuire : Boolean = false, apiSubdirectory : Boolean = false, @@ -221,6 +222,7 @@ object Scaladoc: YdocumentSyntheticTypes.get, snippetCompiler.get, noLinkWarnings.get, + noLinkAssetWarnings.get, versionsDictionaryUrl.nonDefault, generateInkuire.get, apiSubdirectory.get, diff --git a/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala b/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala index 96e7854b45cf..5f2faf6df4d5 100644 --- a/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala +++ b/scaladoc/src/dotty/tools/scaladoc/ScaladocSettings.scala @@ -87,6 +87,12 @@ class ScaladocSettings extends SettingGroup with AllScalaSettings: false ) + val noLinkAssetWarnings: Setting[Boolean] = BooleanSetting( + "-no-link-asset-warnings", + "Avoid warnings for incorrect links of assets like images, static pages, etc.", + false + ) + val versionsDictionaryUrl: Setting[String] = StringSetting( "-versions-dictionary-url", "versions dictionary url", diff --git a/scaladoc/src/dotty/tools/scaladoc/renderers/SiteRenderer.scala b/scaladoc/src/dotty/tools/scaladoc/renderers/SiteRenderer.scala index 1b82412cd724..9e464da893b3 100644 --- a/scaladoc/src/dotty/tools/scaladoc/renderers/SiteRenderer.scala +++ b/scaladoc/src/dotty/tools/scaladoc/renderers/SiteRenderer.scala @@ -63,7 +63,10 @@ trait SiteRenderer(using DocContext) extends Locations: .orElse(asStaticSite) .orElse(asAsset) .getOrElse { - report.warn(s"Unable to resolve link '$str'", content.template.templateFile.file) + if (!summon[DocContext].args.noLinkAssetWarnings){ + val msg = s"Unable to resolve link '$str'" + report.warn(msg, content.template.templateFile.file) + } str }