Pod-Abstract

 view release on metacpan or  search on metacpan

lib/Pod/Abstract/BuildNode.pm  view on Meta::CPAN

will be populated under the returned nodes.

=cut

sub from_pod {
    my $class = shift;
    my $str = shift;

    my $root = Pod::Abstract->load_string($str);
    return undef unless $root;

    my @r = map { $_->detach; $_ } $root->children;
    return @r;
}

=head2 root

 my $root = node->root;

Generate a root node. A root node generates no output, and is used to
hold a document tree. Use this to make a new document.

=cut

sub root {
    my $class = shift;
    my $para = Pod::Abstract::Node->new(
        type => '[ROOT]',
        );
}

=head2 begin

 my $begin_block = node->begin($command);

Generates a begin/end block. Nodes nested inside the begin node will
appear between the begin/end.

Note that there is no corresponding C<end> method - the end command
belongs to it's corresponding begin.

=cut

sub begin {
    my $class = shift;
    my $cmd = shift;

    my $begin = Pod::Abstract::Node->new(
        type => 'begin',
        body => $cmd,
        close_element => Pod::Abstract::Node->new(
            type => 'end',
            body => $cmd,
        ),
        );
    return $begin;
}

=head2 for

 my $for = node->for('overlay from <class>');

Create a =for node. The argument is the literal body of the for node,
no parsing will be performed.

=cut

sub for {
    my $class = shift;
    my $str = shift;

    return Pod::Abstract::Node->new(
        type => 'for',
        body => $str,
        );
}

=head2 paragraph

 my $para = node->paragraph('Pod text');

Generates a Pod paragraph, possibly containing interior sequences. The
argument will be parsed as Pod, and will generate text and sequence
nodes inside the paragraph.

=cut

sub paragraph {
    my $class = shift;
    my $str = shift;

    my $para = Pod::Abstract::Node->new(
        type => ':paragraph',
        );
    my $parser = Pod::Abstract::Parser->new;
    my $pt = $parser->parse_text($str);

    if($pt) {
        $parser->load_pt($para,$pt);
    } else {
        return undef;
    }
}

=head2 verbatim

 my $v = node->verbatim($text);

Add the given text as a verbatim node to the document. All lines in
the fiven C<$text> will be indented by one space to ensure they are
treated as verbatim.

=cut

sub verbatim {
    my $class = shift;
    my $str = shift;

    my @strs = split "\n",$str;
    for(my $i = 0; $i < @strs; $i ++) {
        my $str_line = $strs[$i];



( run in 1.941 second using v1.01-cache-2.11-cpan-39bf76dae61 )