Override type toString setting
geirolz opened this issue · comments
Hi, I wonder if it is possible to override the toString
behaviour of mdoc for some types.
I mean, I have multiple mdoc blocks in which I have some NodeSeq
or Elem
(form scala XML module) variables that prints the following:
val elem: Elem = <bar><foo></foo></bar>
// elem: Elem = Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
// Seq(
(I can't literally put the whole example, Intellij crash opening that .md
file)
It would be interesting to override/block the print for some types. So in the config, I can specify a list of types that I want to silence for example
Example
mdocSilencedTypes := Seq(
"scala.xml.Elem"
)
Will produce
val elem: Elem = <bar><foo></foo></bar>
I know there is the silent
keyword but it silence the whole block
Thank you for reporting! What happens if you try mdoc:to-string?
https://scalameta.org/mdoc/docs/modifiers.html#to-string
Scala XML is special enough that it could merit special handling in mdoc, I’m not opposed to defaulting toString on XML values.
@olafurpg thanks! With to-string
actually works fine
```scala mdoc:to-string
val elem: Elem = <bar><foo></foo></bar>
``\`
Produces
val elem: Elem = <bar><foo></foo></bar>
// elem: Elem = <bar><foo></foo></bar>
At this point, I agree that XML values deserve special handling.
We can close this. Thanks again