sub _guess_opts()

in build_docs.pl [149:180]


sub _guess_opts {
#===================================
    my $index = shift;

    $Opts->{edit_urls} = {};
    $Opts->{roots} = {};
    my $toplevel = _find_toplevel( $index->parent );
    my $remote = _pick_best_remote( $toplevel );
    my $branch = _guess_branch( $toplevel );
    my $repo_name = _guess_repo_name( $remote );
    # We couldn't find the top level so lets make a wild guess.
    $toplevel = $index->parent unless $toplevel;
    printf "Guessed toplevel=[%s] remote=[%s] branch=[%s] repo=[%s]\n", $toplevel, $remote, $branch, $repo_name;

    $Opts->{branch} = $branch;
    $Opts->{roots}{ $repo_name } = $toplevel;
    $Opts->{edit_urls}{ $toplevel } = ES::Repo::edit_url_for_url_and_branch(
        $remote || 'unknown', $branch
    );
    for my $resource ( @{ $Opts->{resource} } ) {
        $toplevel = _find_toplevel( $resource );
        $remote = _pick_best_remote( $toplevel );
        $branch = _guess_branch( $toplevel );
        $repo_name = _guess_repo_name( $remote );
        # We couldn't find the top level so lets make a wild guess.
        $toplevel = $resource unless $toplevel;
        $Opts->{roots}{ $repo_name } = $toplevel;
        $Opts->{edit_urls}{ $toplevel } = ES::Repo::edit_url_for_url_and_branch(
            $remote || 'unknown', $branch
        );
    }
}