mdoc
mdoc copied to clipboard
Support pre-processing code before compilation/evaluation
I'm trying to cross build documentation for a library built against multiple versions of http4s and I'd like to be able to write code for all http4s versions within the same code fence in the markdown doc, distinguishing version-specific lines with a comment like so:
```scala mdoc:http4s
import org.http4s.Uri
val uri = Uri(path = "/my-path") // v0.21
val uri = Uri(path = Uri.Path.unsafeFromString("/my-path")) // v1.0.0-M20
```
Ideally I could write an http4s
modifier to pre-process the code, keep the lines commented with the http4s version currently being built against, remove lines with a mismatched version, and then hand the result off to the standard scala mdoc
modifier to compile/evaluate the code.
I've tried using a PreModifier
for this but I haven't been able to get the last part (handing off to the standard modifier for compilation) to work. Any help would be much appreciated -- thanks in advance!
I'd also love some details on how to use a PreModifier
to make some source changes before the default modifier runs.