Skip to content

Commit

Permalink
Add mdocExtraArguments setting to enable base settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
olafurpg committed Jan 1, 2019
1 parent 45dcfd1 commit 02264cd
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mdoc-docs/src/main/scala/mdoc/docs/SbtModifier.scala
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ class SbtModifier extends StringModifier {
mdocIn,
mdocOut,
mdocVariables,
mdocExtraArguments,
mdocAutoDependency
)
val rows = keys.map { s =>
val tpe = s.key.manifest
.toString()
.replaceAllLiterally("java.lang.String", "String")
.replaceAllLiterally("scala.collection.immutable.", "")
.replaceAllLiterally("scala.collection.", "")
<tr>
<td><code>{s.key.toString}</code></td>
<td><code>{tpe}</code></td>
Expand Down
9 changes: 8 additions & 1 deletion mdoc-sbt/src/main/scala/mdoc/MdocPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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. " +
Expand All @@ -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("<arg>").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 ++= {
Expand Down
3 changes: 3 additions & 0 deletions mdoc/src/main/scala/mdoc/MainSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 02264cd

Please sign in to comment.