class RakuAST::Doc::Paragraph

Contains the information about a RakuDoc paragraph
class RakuAST::Doc::Paragraph { }

The RakuAST::Doc::Paragraph class contains the information about a logical paragraph in a RakuDoc block.

Object introspection

RakuAST::Doc::Paragraph objects are typically created when parsing Raku Programming Language code that has RakuDoc markers in it. So most developers will only need to know how to introspect the objects created.

method atoms

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

Returns the atoms of the paragraph. These are generally a mix of strings and RakuAST::Doc::Markup objects.

method Str

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

Returns the string for the paragraph, with any markup stringified.

method raku

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

Returns the string that is needed for the creation of the paragraph using RakuAST calls.

Object creation

One seldom creates RakuAST::Doc::Paragraph objects directly. This documentation is intended for those few people who'd like to devise their own way of programmatically building a RakuAST::Doc::Paragraph object.

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.

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

Object modification

method add-atom

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

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

The Camelia image is copyright 2009 by Larry Wall. "Raku" is a trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.