Rules / Types, classes & roles / basic

RakuAST::Doc::Paragraph Reference

Contains the information about a RakuDoc paragraph

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 new #

method new(*@atoms)

The new method must be called to create a new RakuAST::Doc::Paragraph object. It takes any number of positional arguments as the atoms of the logical paragraph, where an atom is either a string or a RakuAST::Doc::Markup object. Typically a RakuAST::Doc::Paragraph object is only created if a logical paragraph has at least one markup object.

method add-atom #

Add an atom: should be a string, or a RakuAST::Doc::Markup object.

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.

7 no-output

class RakuAST::Doc::Paragraph { }

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.

.put for $paragraphs.atoms;
# Text before ␤B<and>␤ after markup␤

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

put $paragraph;  # Text before B<and> after markup␤␤

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

# method .gist falls back to .raku
say $block;  # RakuAST::Doc::Paragraph.new(...

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

my $paragraph = RakuAST::Doc::Paragraph.new(
  "Text before ",
  RakuAST::Doc::Markup.new(:letter<B>, :atoms("and")),
  " after markup\n"
);

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

$paragraph.add-atom("baz\n");

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