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

522184
#!/bin/bash
522184
#
edaa9d
# texinfo.sh -- This function initilializes the Texinfo documentation
edaa9d
# backend used by centos-art.sh script to produce and maintain Texinfo
edaa9d
# documentation manuals inside the working copy of The CentOS Artwork
edaa9d
# Repository.
522184
#
522184
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
522184
#
522184
# This program is free software; you can redistribute it and/or modify
522184
# it under the terms of the GNU General Public License as published by
522184
# the Free Software Foundation; either version 2 of the License, or
522184
# (at your option) any later version.
522184
#
522184
# This program is distributed in the hope that it will be useful, but
522184
# WITHOUT ANY WARRANTY; without even the implied warranty of
522184
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
522184
# General Public License for more details.
522184
#
522184
# You should have received a copy of the GNU General Public License
522184
# along with this program; if not, write to the Free Software
522184
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
522184
#
522184
# ----------------------------------------------------------------------
522184
# $Id$
522184
# ----------------------------------------------------------------------
522184
    
522184
function texinfo {
522184
edaa9d
    # Define file extension used by source files inside manuals.
522184
    MANUAL_EXTENSION='texinfo'
522184
edaa9d
    # Define absolute path to chapter's directory. This is the place
edaa9d
    # where chapter-specific files are stored in.
5e989a
    MANUAL_CHAPTER_DIR=${MANUAL_BASEDIR_L10N}/$(cli_getRepoName \
edaa9d
        "${MANUAL_CHAPTER_NAME}" -d | tr -d ' ' | sed -r 's!/$!!')
edaa9d
edaa9d
    # Define absolute path to template directory. This is the place
edaa9d
    # where we store locale directories (e.g., en_US, es_ES, etc.)
edaa9d
    # used to build manuals in texinfo format.
6150a1
    MANUAL_TEMPLATE=${FUNCDIR}/${FUNCDIRNAM}/$(cli_getRepoName \
edaa9d
        ${FLAG_BACKEND} -d)/Templates
6150a1
edaa9d
    # Define absolute path to language-specific template directory.
edaa9d
    # This is the place where we store locale-specific files used to
edaa9d
    # build manuals in texinfo format.
6150a1
    MANUAL_TEMPLATE_L10N=${MANUAL_TEMPLATE}/${MANUAL_L10N}
522184
6150a1
    # Verify absolute path to language-speicific template directory.
6150a1
    # If it doesn't exist, use English language as default location to
6150a1
    # retrive template files.
6150a1
    if [[ ! -d $MANUAL_TEMPLATE_L10N ]];then
6150a1
        MANUAL_TEMPLATE_L10N=${MANUAL_TEMPLATE}/en_US
522184
    fi
522184
edaa9d
    # Initialize document structure of new manuals.
edaa9d
    ${FLAG_BACKEND}_createStructure
522184
e7414c
    # Define documentation entry default values. To build the
e7414c
    # documentation entry, we combine the manual's name, the chapter's
e7414c
    # name and the section name retrived from the command-line.
48d877
    if [[ $MANUAL_CHAPTER_NAME == '' ]];then
48d877
48d877
        # When chapter option is not provided, discard the section
48d877
        # name and define documentation entry based on manual's main
48d877
        # definition file.
48d877
        MANUAL_ENTRY="${MANUAL_BASEFILE}.${MANUAL_EXTENSION}"
48d877
48d877
    elif [[ $MANUAL_CHAPTER_NAME != '' ]] && [[ $MANUAL_SECTION_NAME == '' ]];then
48d877
48d877
        # When chapter option is provided whith out a section name,
48d877
        # verify chapter's directory inside the manual,
48d877
        ${FLAG_BACKEND}_createChapter
48d877
48d877
        # and define documentation entry based on chapter's main
48d877
        # definition file.
48d877
        MANUAL_ENTRY="${MANUAL_BASEDIR_L10N}/${MANUAL_CHAPTER_NAME}/chapter.${MANUAL_EXTENSION}"
48d877
48d877
    elif [[ $MANUAL_CHAPTER_NAME != '' ]] && [[ $MANUAL_SECTION_NAME != '' ]];then
48d877
48d877
        # When both the chapter option and non-option arguments are
48d877
        # provided, define documentation entries based on manual,
48d877
        # chapter and non-option arguments.
48d877
        MANUAL_ENTRY="$(${FLAG_BACKEND}_getEntry "$MANUAL_SECTION_NAME")"
48d877
48d877
    else
48d877
        cli_printMessage "`gettext "The parameters you provided are not supported."`" --as-error-line
48d877
    fi
48d877
e7414c
    # Execute action names. Notice that we've separated execution of
e7414c
    # action names in order to control and save differences among
e7414c
    # them.
e7414c
    if [[ $ACTIONNAM == "" ]];then
edaa9d
e7414c
        # When no action name is provided to `centos-art.sh' script,
e7414c
        # read manual's output in info format in order to provide a
e7414c
        # way for people to get oriented about The CentOS Artwork
e7414c
        # Repository and its automation tool, the centos-art.sh
e7414c
        # script. Be sure the manual's output file does exist and
e7414c
        # terminate the script execution once the reading is done.
edaa9d
e7414c
        # Update manual's info output format.
e7414c
        ${FLAG_BACKEND}_updateOutputFiles
e7414c
            
e7414c
        # Read Top node from manual's info output format.
e7414c
        info --node="Top" --file=${MANUAL_BASEFILE}.info.bz2
522184
edaa9d
        # Terminate script execution right here.
edaa9d
        exit
edaa9d
e7414c
    elif [[ $ACTIONNAM =~ "^(copy|rename)Entry$" ]];then
522184
e7414c
        # Both `--copy' and `--rename' actions interpret non-option
e7414c
        # arguments passed to `centos-art.sh' script in a special way.
e7414c
        # In this configuration, only two non-option arguments are
e7414c
        # used and interpreted from the first loop of their
e7414c
        # interpretation.
edaa9d
        ${FLAG_BACKEND}_${ACTIONNAM}
522184
e7414c
        # Break interpretation of non-option arguments, to prevent the
e7414c
        # second non-option argument from be considered a source
e7414c
        # location.
e7414c
        break
e7414c
e7414c
    elif [[ $ACTIONNAM =~ "^(search(Node|Index)|updateOutputFiles)$" ]];then
e7414c
e7414c
        # The two final actions of help functionality are precisely to
e7414c
        # update manual output files and commit all changes from
e7414c
        # working copy to central repository. In this situation, when
e7414c
        # the `--update' action name is provided to `centos-art.sh',
e7414c
        # don't duplicate the rendition of manual output files (e.g.,
e7414c
        # one as action name and another as help's normal execution
e7414c
        # flow) nor commit any change form working copy to central
e7414c
        # repository (e.g., output files are not under version
e7414c
        # control).
e7414c
        ${FLAG_BACKEND}_${ACTIONNAM}
e7414c
e7414c
        # Terminate script execution right here. Actions realized in
e7414c
        # this configuration doesn't need to update manual output
e7414c
        # files, nor commit changes from working copy up to central
e7414c
        # repository.
522184
        exit
522184
522184
    else
522184
e7414c
        # Execute action names that follow help's execution flow as it
e7414c
        # is, without any modification.
e7414c
        ${FLAG_BACKEND}_${ACTIONNAM}
edaa9d
edaa9d
    fi
522184
522184
}