Dotty Documentation


object transform
extends Object with Serializable

[-] Constructors

[-] Members

[+] trait DocMiniPhase
[+] abstract class DocMiniTransformations

The idea behind DocMiniTransformations is to fuse transformations to the doc AST, much like MiniPhase in dotty core - but in a much simpler implementation


Create a DocMiniPhase which overrides the relevant method:

override def transformDef(implicit ctx: Context) = {
 case x if shouldTransform(x) => x.copy(newValue = ...) :: Nil

On each node in the AST, the appropriate method in DocMiniPhase will be called in the order that they are supplied in DocMiniphaseTransformations.

There won't be a match-error as transformX is composed with an identity function.

The transformations in DocMiniTransformations will apply transformations to all nodes - this means that you do not need to transform children in transformPackage, because transformX will be called for the relevant children. If you want to add children to Package you need to do that in transformPackage, these additions will be persisted.

Deleting nodes in the AST

To delete a node in the AST, simply return an empty list from transforming method