in lib/ES/Book.pm [177:248]
sub build {
#===================================
my ( $self, $rebuild, $conf_path ) = @_;
my $toc_extra = $self->{toc_extra} ? $conf_path->parent->file( $self->{toc_extra} ) : 0;
my $toc = ES::Toc->new( $self->title, $toc_extra );
my $dir = $self->dir;
$dir->mkpath;
my $title = $self->title;
my $pm = proc_man(
$Opts->{procs},
sub {
my ( $pid, $error, $branch ) = @_;
$self->source->mark_done( $title, $branch );
}
);
my $latest = !$self->{suppress_migration_warnings};
my $update_version_toc = 0;
my $rebuilding_current_branch = 0;
for my $branch ( @{ $self->branches } ) {
my $building = $self->_build_book( $branch, $pm, $rebuild, $latest );
$update_version_toc ||= $building;
$latest = 0;
my $version = $self->branch_title($branch);
$toc->add_entry(
{ title => "$title: $version",
url => "$version/index.html"
}
);
if ( $branch eq $self->current ) {
$rebuilding_current_branch = $building;
}
}
$pm->wait_all_children();
$self->_copy_branch_to_current if $rebuilding_current_branch;
$update_version_toc |= $self->_remove_old_versions;
if ( $self->is_multi_version ) {
if ( $update_version_toc ) {
# We could get away with only doing this if we added or removed
# any branches or changed the current branch, but we don't have
# that information right now.
$toc->write( $self->{raw_dir}, $dir, $self->{temp_dir} );
for ( @{ $self->branches } ) {
my $version = $self->branch_title($_);
$self->_update_title_and_version_drop_downs( $dir->subdir( $version ), $_ );
}
$self->_update_title_and_version_drop_downs( $dir->subdir( 'current' ) , $self->current );
for ( @{ $self->branches } ) {
my $version = $self->branch_title($_);
$self->_update_title_and_version_drop_downs( $self->{raw_dir}->subdir( $version ), $_ );
}
$self->_update_title_and_version_drop_downs( $self->{raw_dir}->subdir( 'current' ) , $self->current );
}
return {
title => "$title [" . $self->branch_title( $self->current ) . "\\]",
url => $self->prefix . '/current/index.html',
versions => $self->prefix . '/index.html',
section_title => $self->section_title()
};
}
if ( $update_version_toc ) {
write_html_redirect( $dir, "current/index.html" );
}
return {
title => $title,
url => $self->prefix . '/current/index.html'
};
}