# -*-Shell-script-*-
#
# Copyright (C) 2015-2020 SUSE Software Solutions Germany GmbH
#
# Author:
# Frank Sundermeyer <fsundermeyer at opensuse dot org>
#
###########################################################################
#
#  PACKAGING online-docs
#
#  Subcommands: online-docs
#
###########################################################################
function online-docs {
    local CONV_COUNT SHORT_OPTS LONG_OPTS SUB_CMD
    SUB_CMD=$1
    shift

    CONV_COUNT=0

    SHORT_OPTS="h"
    LONG_OPTS="db5todb4,db5todb4nh,dbnoconv,export-dir:,formatter:,help,name:,noepub,nohtml,nopdf,noset,rootid:,optipng"

    parse_args "$SHORT_OPTS" "$LONG_OPTS" "$SUB_CMD" "$@"
    eval set -- "$P_REMAIN_ARGS"

    #------ Computing the values returned from the parser -----
    if [[ 1 -eq $P_HELP ]]; then
        help_scmd_head "$SUB_CMD" "${HELP_SUBCOMMAND[$SUB_CMD]}"
        help_db5todb4
        help_db5todb4nh
        help_dbnoconv
        help_export-dir
        help_formatter
        help_help
        help_name
        help_noepub
        help_nohtml
        help_nopdf
        help_noset
        help_rootid
        help_optipng
        echo
        exit 0
    fi

    # online-docs always builds a single HTML file
    if [[ 1 -ne $NOHTML ]]; then
        export HTMLSINGLE=1
    fi

    if [[ 1 -eq $DB5TODB4 && 1 -eq $DB5TODB4NH ]]; then
        exit_on_error "The options --db5todb4 and --db5todb4nh exclude each other"
    fi

    if [[ 4 -eq $DOCBOOK_VERSION ]]; then
       [[ 1 -eq $DB5TODB4 || 1 -eq $DB5TODB4NH ]] && ccecho "warn" "No DocBook 5 source: --db5todb4/--db5todb4nh is ignored"
    fi

    call_make "$SUB_CMD" "$@"
}
