Blame Scripts/Bash/Functions/Help/Texinfo/texinfo.sh

878a2b
#!/bin/bash
878a2b
#
819c26
# texinfo.sh -- This function initializes Texinfo documentation format
819c26
# used by `centos-art.sh' script to produce and maintain documentation
819c26
# manuals written in Texinfo format, inside the working copy of The
819c26
# CentOS Artwork Repository.
878a2b
#
03486a
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
878a2b
#
878a2b
# This program is free software; you can redistribute it and/or modify
878a2b
# it under the terms of the GNU General Public License as published by
878a2b
# the Free Software Foundation; either version 2 of the License, or (at
878a2b
# your option) any later version.
878a2b
#
878a2b
# This program is distributed in the hope that it will be useful, but
878a2b
# WITHOUT ANY WARRANTY; without even the implied warranty of
878a2b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
878a2b
# General Public License for more details.
878a2b
#
878a2b
# You should have received a copy of the GNU General Public License
878a2b
# along with this program; if not, write to the Free Software
878a2b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
878a2b
#
878a2b
# ----------------------------------------------------------------------
878a2b
# $Id$
878a2b
# ----------------------------------------------------------------------
878a2b
    
878a2b
function texinfo {
878a2b
878a2b
    # Verify documentation entry to be sure it coincides with
878a2b
    # Texinfo's supported structuring (e.g., texinfo-4.8 doesn't
878a2b
    # support structuring through parts, but chapters and sections
878a2b
    # only).
878a2b
    if [[ $MANUAL_PART_NAME != '' ]];then
23b947
        cli_printMessage "`gettext "The documentation entry provided isn't supported."`" --as-error-line
878a2b
    fi
878a2b
f8764f
    # Verify documentation format based on file type.
f8764f
    if [[ -f ${MANUAL_BASEFILE}.${MANUAL_EXTENSION} ]];then
f8764f
        cli_checkFiles -i "text/x-texinfo" ${MANUAL_BASEFILE}.${MANUAL_EXTENSION}
f8764f
    fi
878a2b
878a2b
    # Define absolute path to template directory. This is the place
878a2b
    # where we store locale directories (e.g., en_US, es_ES, etc.)
878a2b
    # used to build manuals in texinfo format.
f8764f
    MANUAL_TEMPLATE=${MANUAL_TLDIR}/$(cli_getRepoName ${FLAG_FORMAT} -d)/Default
878a2b
878a2b
    # Define absolute path to language-specific template directory.
878a2b
    # This is the place where we store locale-specific files used to
878a2b
    # build manuals in texinfo format.
878a2b
    MANUAL_TEMPLATE_L10N=${MANUAL_TEMPLATE}/${MANUAL_L10N}
878a2b
f8764f
    # Verify absolute path to language-specific template directory.
878a2b
    # If it doesn't exist, use English language as default location to
f8764f
    # retrieve template files.
878a2b
    if [[ ! -d $MANUAL_TEMPLATE_L10N ]];then
878a2b
        MANUAL_TEMPLATE_L10N=${MANUAL_TEMPLATE}/en_US
878a2b
    fi
878a2b
878a2b
    # Initialize document structure for new manuals.
878a2b
    texinfo_createStructure
878a2b
878a2b
    # Define documentation entry default values. To build the
878a2b
    # documentation entry, we combine the manual's name, part, chapter
f8764f
    # and section information retrieved from the command-line.
878a2b
    if [[ $MANUAL_CHAPTER_NAME == '' ]];then
878a2b
878a2b
        # When chapter option is not provided, discard the section
878a2b
        # name and define documentation entry based on manual's main
878a2b
        # definition file.
878a2b
        MANUAL_ENTRY="${MANUAL_BASEFILE}.${MANUAL_EXTENSION}"
878a2b
878a2b
    elif [[ $MANUAL_CHAPTER_NAME != '' ]] && [[ $MANUAL_SECTION_NAME == '' ]];then
878a2b
f8764f
        # When chapter option is provided without a section name,
878a2b
        # verify chapter's directory inside the manual,
878a2b
        texinfo_createChapter
878a2b
878a2b
        # and define documentation entry based on chapter's main
878a2b
        # definition file.
878a2b
        MANUAL_ENTRY="${MANUAL_BASEDIR_L10N}/${MANUAL_CHAPTER_NAME}/chapter.${MANUAL_EXTENSION}"
878a2b
878a2b
    elif [[ $MANUAL_CHAPTER_NAME != '' ]] && [[ $MANUAL_SECTION_NAME != '' ]];then
878a2b
878a2b
        # When both the chapter option and non-option arguments are
878a2b
        # provided, define documentation entries based on manual,
878a2b
        # chapter and non-option arguments.
878a2b
        MANUAL_ENTRY="$(texinfo_getEntry "$MANUAL_SECTION_NAME")"
878a2b
878a2b
    else
878a2b
        cli_printMessage "`gettext "The parameters you provided are not supported."`" --as-error-line
878a2b
    fi
878a2b
878a2b
    # Execute action names. Notice that we've separated execution of
878a2b
    # action names in order to control and save differences among
878a2b
    # them.
878a2b
    if [[ $ACTIONNAM == "" ]];then
878a2b
878a2b
        # When no action name is provided to `centos-art.sh' script,
878a2b
        # read manual's info output in order to provide a way for
878a2b
        # people to get oriented about The CentOS Artwork Repository
878a2b
        # and its automation too. Be sure the manual and its info
878a2b
        # output file do exist. Later, once the reading is done,
878a2b
        # terminate the script execution.
878a2b
878a2b
        # Update manual's output files.
878a2b
        texinfo_updateOutputFiles
878a2b
            
878a2b
        # Read manual's Top node from its info output file.
98d80a
        info --node="Top" --file="${MANUAL_OUTPUT_BASEFILE}.info.bz2"
878a2b
a9af88
    elif [[ $ACTIONNAM =~ "^(copy|rename|delete)Entry$" ]];then
878a2b
878a2b
        # Both `--copy' and `--rename' actions interpret non-option
878a2b
        # arguments passed to `centos-art.sh' script in a special way.
878a2b
        # In this configuration, only two non-option arguments are
878a2b
        # processed in the first loop of their interpretation.
878a2b
        texinfo_${ACTIONNAM}
878a2b
878a2b
        # Rebuild output files to propagate recent changes, if any.
878a2b
        texinfo_updateOutputFiles
878a2b
878a2b
        # Break interpretation of non-option arguments to prevent the
878a2b
        # second and further non-option arguments from being
878a2b
        # considered as source location.
878a2b
        break
878a2b
878a2b
    else
878a2b
2206dc
        # Execute action names as part of normal help command's
2206dc
        # execution flow, without any extra modification.
878a2b
        texinfo_${ACTIONNAM}
878a2b
878a2b
    fi
878a2b
878a2b
}