sub _build_book()

in lib/ES/Book.pm [262:347]


sub _build_book {
#===================================
    my ( $self, $branch, $pm, $rebuild, $latest ) = @_;

    my $version       = $self->branch_title($branch);
    my $raw_version_dir = $self->{raw_dir}->subdir( $version );
    my $version_dir    = $self->dir->subdir($version);
    my $source        = $self->source;
    my $index         = $self->index;
    my $section_title = $self->section_title($version);
    my $subject       = $self->subject;
    my $lang          = $self->lang;

    return 0 unless $rebuild ||
        $source->has_changed( $self->title, $branch );

    my ( $checkout, $edit_urls, $first_path, $alternatives, $roots ) =
        $source->prepare($self->title, $branch);

    $pm->start($branch) and return 1;
    printf(" - %40.40s: Building %s...\n", $self->title, $version);
    eval {
        if ( $self->single ) {
            build_single(
                $first_path->file($index),
                $raw_version_dir,
                $version_dir,
                version       => $version,
                lang          => $lang,
                edit_urls     => $edit_urls,
                private       => $self->private( $branch ),
                noindex       => $self->noindex( $branch ),
                multi         => $self->is_multi_version,
                page_header   => $self->_page_header($branch),
                section_title => $section_title,
                subject       => $subject,
                toc           => $self->toc,
                resource      => [$checkout],
                latest        => $latest,
                respect_edit_url_overrides => $self->{respect_edit_url_overrides},
                alternatives  => $alternatives,
                branch => $branch,
                roots => $roots,
                relativize => 1,
            );
        }
        else {
            build_chunked(
                $first_path->file($index),
                $raw_version_dir,
                $version_dir,
                version       => $version,
                lang          => $lang,
                edit_urls     => $edit_urls,
                private       => $self->private( $branch ),
                noindex       => $self->noindex( $branch ),
                chunk         => $self->chunk,
                multi         => $self->is_multi_version,
                page_header   => $self->_page_header($branch),
                section_title => $section_title,
                subject       => $subject,
                resource      => [$checkout],
                latest        => $latest,
                respect_edit_url_overrides => $self->{respect_edit_url_overrides},
                alternatives  => $alternatives,
                branch => $branch,
                roots => $roots,
                relativize => 1,
            );
        }
        $checkout->rmtree;
        printf(" - %40.40s: Finished %s\n", $self->title, $version);

        1;
    } && $pm->finish;
    # NOTE: This method is about a screen up with $pm->start so it doesn't
    # return *anything* here. It just dies if there was a failure so we can
    # pick that up in the parent process.

    my $error = $@;
    die "\nERROR building "
        . $self->title
        . " version $version\n\n"
        . $source->dump_recent_commits( $self->title, $branch )
        . $error . "\n";
}