Skip to content

Commit

Permalink
Add option to disable link hygiene.
Browse files Browse the repository at this point in the history
The analysis currently has several false positives so it may be
desirable to disable it.
  • Loading branch information
olafurpg committed Jan 1, 2019
1 parent f64b4b4 commit 45dcfd1
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mdoc/src/main/scala/mdoc/internal/cli/MainOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class MainOps(
}

def lint(): Unit = {
if (settings.out.isDirectory) {
if (settings.out.isDirectory && !settings.noLinkHygiene) {
val docs = DocumentLinks.fromGeneratedSite(settings, reporter)
LinkHygiene.lint(docs, reporter, settings.verbose)
}
Expand Down
2 changes: 2 additions & 0 deletions mdoc/src/main/scala/mdoc/internal/cli/Settings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ case class Settings(
)
@ExtraName("test")
check: Boolean = false,
@Description("Disable link hygiene analysis so that no warnings are reported for dead links.")
noLinkHygiene: Boolean = false,
@Description("Include additional diagnostics for debugging potential problems.")
verbose: Boolean = false,
@Description(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ abstract class BaseMarkdownSuite extends org.scalatest.FunSuite with DiffAsserti
print(colorOut)
val stdout = fansi.Str(colorOut).plainText
assert(!reporter.hasErrors, stdout)
assert(!reporter.hasWarnings, stdout)
assertNoDiffOrPrintExpected(obtained, expected)
}
}
Expand Down
25 changes: 25 additions & 0 deletions tests/unit/src/test/scala/tests/markdown/NoLinkWarningSuite.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package tests.markdown

import tests.cli.BaseCliSuite

class NoLinkWarningSuite extends BaseCliSuite {
val original =
"""/readme.md
|# Header
|
|[Head](#head)
""".stripMargin

checkCli(
"nowarn",
original,
original,
extraArgs = Array(
"--no-link-hygiene"
),
onStdout = { out =>
assert(!out.contains("warning"))
}
)

}

0 comments on commit 45dcfd1

Please sign in to comment.