From 02264cd97b2cf49f987e4e7e36bcae1970926f63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93lafur=20P=C3=A1ll=20Geirsson?= Date: Tue, 1 Jan 2019 19:28:47 +0100 Subject: [PATCH] Add mdocExtraArguments setting to enable base settings. --- mdoc-docs/src/main/scala/mdoc/docs/SbtModifier.scala | 2 ++ mdoc-sbt/src/main/scala/mdoc/MdocPlugin.scala | 9 ++++++++- mdoc/src/main/scala/mdoc/MainSettings.scala | 3 +++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/mdoc-docs/src/main/scala/mdoc/docs/SbtModifier.scala b/mdoc-docs/src/main/scala/mdoc/docs/SbtModifier.scala index 8c5dbfb0a..152ddc4c4 100644 --- a/mdoc-docs/src/main/scala/mdoc/docs/SbtModifier.scala +++ b/mdoc-docs/src/main/scala/mdoc/docs/SbtModifier.scala @@ -14,6 +14,7 @@ class SbtModifier extends StringModifier { mdocIn, mdocOut, mdocVariables, + mdocExtraArguments, mdocAutoDependency ) val rows = keys.map { s => @@ -21,6 +22,7 @@ class SbtModifier extends StringModifier { .toString() .replaceAllLiterally("java.lang.String", "String") .replaceAllLiterally("scala.collection.immutable.", "") + .replaceAllLiterally("scala.collection.", "") {s.key.toString} {tpe} diff --git a/mdoc-sbt/src/main/scala/mdoc/MdocPlugin.scala b/mdoc-sbt/src/main/scala/mdoc/MdocPlugin.scala index c08169b26..84649964a 100644 --- a/mdoc-sbt/src/main/scala/mdoc/MdocPlugin.scala +++ b/mdoc-sbt/src/main/scala/mdoc/MdocPlugin.scala @@ -36,6 +36,11 @@ object MdocPlugin extends AutoPlugin { "Output directory for mdoc generated markdown. " + "Defaults to the target/mdoc directory of this project." ) + val mdocExtraArguments = + settingKey[Seq[String]]( + "Additional command-line arguments to pass on every mdoc invocation. " + + "For example, add --no-link-hygiene to disable link hygiene." + ) val mdocAutoDependency = settingKey[Boolean]( "If false, do not add mdoc as a library dependency this project. " + @@ -49,10 +54,12 @@ object MdocPlugin extends AutoPlugin { mdocOut := target.in(Compile).value / "mdoc", mdocVariables := Map.empty, mdocAutoDependency := true, + mdocExtraArguments := Nil, mdoc := Def.inputTaskDyn { val parsed = sbt.complete.DefaultParsers.spaceDelimited("").parsed + val args = mdocExtraArguments.value ++ parsed Def.taskDyn { - runMain.in(Compile).toTask(s" mdoc.Main ${parsed.mkString(" ")}") + runMain.in(Compile).toTask(s" mdoc.Main ${args.mkString(" ")}") } }.evaluated, libraryDependencies ++= { diff --git a/mdoc/src/main/scala/mdoc/MainSettings.scala b/mdoc/src/main/scala/mdoc/MainSettings.scala index 14a6ebdae..2088e3e9e 100644 --- a/mdoc/src/main/scala/mdoc/MainSettings.scala +++ b/mdoc/src/main/scala/mdoc/MainSettings.scala @@ -71,6 +71,9 @@ final class MainSettings private ( def withCheck(check: Boolean): MainSettings = { copy(settings.copy(check = check)) } + def withNoLinkHygiene(noLinkHygiene: Boolean): MainSettings = { + copy(settings.copy(noLinkHygiene = noLinkHygiene)) + } def withReportRelativePaths(reportRelativePaths: Boolean): MainSettings = { copy(settings.copy(reportRelativePaths = reportRelativePaths)) }