Skip to content

Commit

Permalink
Fix: -no-link-warnings does not work (#17028)
Browse files Browse the repository at this point in the history
## 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
  • Loading branch information
Dedelweiss authored Jun 20, 2023
1 parent b614d84 commit be70d46
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions project/ScaladocGeneration.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
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 @@ -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,
Expand Down Expand Up @@ -221,6 +222,7 @@ object Scaladoc:
YdocumentSyntheticTypes.get,
snippetCompiler.get,
noLinkWarnings.get,
noLinkAssetWarnings.get,
versionsDictionaryUrl.nonDefault,
generateInkuire.get,
apiSubdirectory.get,
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 @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit be70d46

Please sign in to comment.