Rules / Types, classes & roles / basic

RakuAST::Doc::DeclaratorTarget Reference

Provide leading/trailing doc functionality

What it is #

Routines #

Signatures are reproduced from the documentation, including their declared return types. A routine listed here is part of the type's published interface; whether Raku++ implements it is a separate question, answered by the examples below.

method set-WHY #

Set the RakuAST::Doc::Declarator object to be associated.

method 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 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 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 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 a line to the trailing documentation. Creates a RakuAST::Doc::Declarator object and sets it in the .WHY if there wasn't one already.

Examples, run three ways #

Every example below comes from the official documentation, together with the output that documentation asserts. Each was then executed by Rakudo and by Raku++ when this page was built. Where the three agree, one result is shown; where they do not, all three are — because which of them is wrong is exactly the information worth having.

9 no-output

role RakuAST::Doc::DeclaratorTarget { }

Not executed: the documentation states no expected output for this example.

use experimental :rakuast;

Not executed: the documentation states no expected output for this example.

with $target.WHY {
say "leading: $_.leading()";
say "trailing: $_.trailing()";
}

Not executed: the documentation states no expected output for this example.

$target.set-WHY($declarator);

Not executed: the documentation states no expected output for this example.

my $WHY := $target.cut-WHY;

Not executed: the documentation states no expected output for this example.

$target.set-leading;  # reset
$target.set-leading("foo", "bar");

Not executed: the documentation states no expected output for this example.

$target.add-leading("additional");

Not executed: the documentation states no expected output for this example.

$target.set-trailing;  # reset
$target.set-trailing("foo", "bar");

Not executed: the documentation states no expected output for this example.

$target.add-trailing("additional");

Not executed: the documentation states no expected output for this example.