-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It seems that mdoc assumes a type name to be stringified into a single line but that is wrong for RefinedType. May be we should fix this line: https://github.com/scalameta/mdoc/blob/69fea55c23477fbb6aed94e39b54b31efa56cf24/cli/src/main/scala/mdoc/internal/markdown/ReplVariablePrinter.scala#L25
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
site.MultilineOutputModifier |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package site | ||
|
||
import mdoc.{PostModifier, PostModifierContext} | ||
|
||
class MultilineOutputModifier extends PostModifier { | ||
val name = "mline" | ||
|
||
def process(ctx: PostModifierContext): String = { | ||
val code = ctx.variables.map { v => | ||
val s = v.toString | ||
(s, linesAsComment(s)) | ||
}.foldLeft(ctx.outputCode) { case (code, (from, to)) => | ||
code.replace(from, to) | ||
} | ||
|
||
s"""```scala | ||
|${code} | ||
|``` | ||
|""".stripMargin | ||
} | ||
|
||
private def linesAsComment(lines: String): String = | ||
lines.split("\n").map(lineAsComment(_)).mkString("\n") | ||
|
||
private def lineAsComment(line: String): String = | ||
if (line.isEmpty()) | ||
line | ||
else if (line.startsWith("//")) | ||
line | ||
else | ||
"// " + line | ||
} |