Rules / Types, classes & roles / basic

RakuAST::Doc::Markup Reference

Contains the information about RakuDoc markup

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 #

The new method can be called to create a new RakuAST::Doc::Markup object. It only takes named arguments, with the :letter argument being mandatory. Note that all arguments except :letter are optional. So it is possible to create "empty" markup as well. The "type" of markup object. Generally expected to be an uppercase letter, but this is not enforced. The RakuDoc standard assigns

method set-atoms #

Set the atoms to the given Positional. Values are expected to be either a string, or a RakuAST::Doc::Markup object. If no values are specified, then the object will have no atoms.

method add-atom #

Add an atom to the atoms of the object. Values are expected to be either a string, or a RakuAST::Doc::Markup object.

method set-meta #

Set the meta-information to the given Positional. Values are expected to be either a string, or a RakuAST::Doc::Markup object. If no values are specified, then the object will have no meta-information.

method add-meta #

Add an item to the meta-information of the object. Values are expected to be either 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.

16 no-output

class RakuAST::Doc::Markup { }

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.

say "letter = $markup.letter()";  # B␤

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

say "opener = $markup.opener()";  # <␤

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

say "closer = $markup.closer()";  # >␤

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

.say for $markup.atoms;  # and␤

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

.say for $markup.meta;

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

put $markup;  # B<and>␤

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

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

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

method new(
  Str:D  :$letter!,      # markup identifier, e.g. "B"
  Str:D  :$opener = "<", # opener marker
  Str:D  :$closer = ">", # closer marker
     :@atoms,        # any atoms of this markup
     :@meta,         # any meta of this markup
)

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

B<and>

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

my $markup = RakuAST::Doc::Markup.new(
  :letter<B>,
  :atoms("and")
);

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

$markup.set-atoms;  # reset
$markup.set-atoms( ("and",) );

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

$markup.add-atom( ("foo",) );

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

$markup.set-meta;  # reset
$markup.set-meta( ("https://raku.org",) );

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

$markup.add-meta( ("bar",) );

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