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

522184
#!/bin/bash
522184
#
22d055
# texinfo.sh -- This function initilializes Texinfo documentation
22d055
# backend used by `centos-art.sh' script to produce and maintain
22d055
# documentation manuals written in Texinfo format, inside the working
22d055
# copy of The CentOS Artwork Repository.
522184
#
2fe9b7
# Copyright (C) 2009, 2010, 2011 The CentOS Project
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
2fe9b7
# the Free Software Foundation; either version 2 of the License, or (at
2fe9b7
# 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
e0c375
    # Verify documentation entry to be sure it coincides with
e0c375
    # Texinfo's supported structuring (e.g., texinfo-4.8 doesn't
e0c375
    # support structuring through parts, but chapters and sections
e0c375
    # only).
e0c375
    if [[ $MANUAL_PART_NAME != '' ]];then
e0c375
        cli_printMessage "The documentation entry provided isn't supported." --as-error-line
e0c375
    fi
e0c375
e0c375
    # Define file extension used by source files inside manuals.
e0c375
    MANUAL_EXTENSION="${MANUAL_BACKEND}"
e0c375
848ff6
    # Initialize document structure for new manuals.
0ca0ad
    ${MANUAL_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,
0ca0ad
        ${MANUAL_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.
0ca0ad
        MANUAL_ENTRY="$(${MANUAL_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
499af4
        # Update manual's output files.
0ca0ad
        ${MANUAL_BACKEND}_updateOutputFiles
e7414c
            
22d055
        # Read manual's Top node from its info output file.
22d055
        info --node="Top" --file="${MANUAL_BASEFILE}.info.bz2"
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
499af4
        # processed in the first loop of their interpretation.
0ca0ad
        ${MANUAL_BACKEND}_${ACTIONNAM}
522184
22d055
        # Rebuild output files to propagate recent changes, if any.
22d055
        ${MANUAL_BACKEND}_updateOutputFiles
22d055
22d055
        # Break interpretation of non-option arguments to prevent the
499af4
        # second and further non-option arguments from being
22d055
        # considered as source 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).
0ca0ad
        ${MANUAL_BACKEND}_${ACTIONNAM}
e7414c
522184
    else
522184
e7414c
        # Execute action names that follow help's execution flow as it
e7414c
        # is, without any modification.
0ca0ad
        ${MANUAL_BACKEND}_${ACTIONNAM}
edaa9d
22d055
        # Rebuild output files to propagate recent changes, if any.
22d055
        ${MANUAL_BACKEND}_updateOutputFiles
22d055
edaa9d
    fi
522184
522184
}