The RakuAST::Doc::DeclaratorTarget
role is done by objects that support leading and trailing documentation.
Support for RakuAST
functionality is available in language version 6.e+
and was added in Rakudo compiler release 2023.02. In earlier language versions it is only available when specifying:
use experimental :rakuast;
Object introspection§
Objects doing the RakuAST::Doc::DeclaratorTarget
role are typically created when parsing Raku Programming Language code for objects that allow leading (#|
) and trailing (#=
) documentation on them. So most developers will only need to know how to introspect the objects created.
method WHY§
with .WHY
Returns the RakuAST::Doc::Declarator
object containing the declarator documentation, if any.
Object creation§
Each object doing the RakuAST::Doc::DeclaratorTarget
role has its own why of creation. So there's nothing general that can be said about it here.
Object modification§
method set-WHY§
.set-WHY();
Set the RakuAST::Doc::Declarator
object to be associated.
method cut-WHY§
my := .cut-WHY;
Removes the RakuAST::Doc::Declarator
object, if any. Intended to be used when deparsing / stringification to prevent an infinite loop because the RakuAST::Doc::Declarator
object points to its target, and the other way around. Usually called on a clone of the original target.
method set-leading§
.set-leading; # reset.set-leading("foo", "bar");
Set the leading documentation. If no arguments are specified, reset to not having any leading documentation. Creates a RakuAST::Doc::Declarator
object and sets it in the .WHY
if there wasn't one already.
method add-leading§
.add-leading("additional");
Add a line to the leading documentation. Creates a RakuAST::Doc::Declarator
object and sets it in the .WHY
if there wasn't one already.
method set-trailing§
.set-trailing; # reset.set-trailing("foo", "bar");
Set the trailing documentation. If no arguments are specified, reset to not having any trailing documentation. Creates a RakuAST::Doc::Declarator
object and sets it in the .WHY
if there wasn't one already.
method add-trailing§
.add-trailing("additional");
Add a line to the trailing documentation. Creates a RakuAST::Doc::Declarator
object and sets it in the .WHY
if there wasn't one already.