Single line comments are added to an arbitrary tree as follows:
tree withComment("comments here", ...)
For example,
LIT(2) withComment("comments are useful",
"only if they provide more info than the code")
prints as
// comments are useful
// only if they provide more info than the code
2
Scaladoc style comments are written using withDoc as follows:
tree withDoc("comments" | doctag, ...)
where doctag is a doctag defined as DocTag.See(IntClass), DocTag.Author("Somebody"), etc.
For example,
(DEF("x") := LIT(0)) withDoc(
"does something",
DocTag.See(IntClass)
)
prints as
/**
* does something
* @see scala.Int
*/
def x = 0