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

4580e8
#!/bin/bash
4580e8
#
4580e8
# texinfo.sh -- This function initialize variables and functions
4580e8
# specific to texinfo backend.
4580e8
#
4580e8
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
4580e8
#
4580e8
# This program is free software; you can redistribute it and/or modify
4580e8
# it under the terms of the GNU General Public License as published by
4580e8
# the Free Software Foundation; either version 2 of the License, or (at
4580e8
# your option) any later version.
4580e8
#
4580e8
# This program is distributed in the hope that it will be useful, but
4580e8
# WITHOUT ANY WARRANTY; without even the implied warranty of
4580e8
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4580e8
# General Public License for more details.
4580e8
#
4580e8
# You should have received a copy of the GNU General Public License
4580e8
# along with this program; if not, write to the Free Software
4580e8
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
4580e8
#
4580e8
# ----------------------------------------------------------------------
4580e8
# $Id$
4580e8
# ----------------------------------------------------------------------
4580e8
4580e8
function texinfo {
4580e8
4580e8
    # Define manual backend directory. This is the place where all
4580e8
    # language specific documentation manuals, for the same backend
4580e8
    # documentation system, are stored in.
4580e8
    MANUAL_BACKEND="${MANUAL_BASEDIR}/$(cli_getRepoName ${FLAG_BACKEND} -d)"
4580e8
4580e8
    # Redefine manual base directory to refere the place where
4580e8
    # language-specific source files used by texinfo documentation
4580e8
    # backend are stored in.
4580e8
    MANUAL_BASEDIR="${MANUAL_BACKEND}/${MANUAL_LANG}"
4580e8
4580e8
    # Define base name for documentation manual files (without
4580e8
    # extension). This is the main file name used to build output
4580e8
    # related files (.info, .pdf, .xml, etc.).
4580e8
    MANUAL_BASEFILE="${MANUAL_BASEDIR}/${MANUAL_NAME}"
4580e8
4580e8
    # Define chapter name of directory where repository documentation
4580e8
    # entries will be stored in.
4580e8
    MANUAL_CHAPTER_NAME=$(cli_getRepoName "Directories" -d)
4580e8
4580e8
    # Define absolute path to chapter directory where repository
4580e8
    # documentation entries will be stored in.  At this point, we need
4580e8
    # to take a desition about documentation design, in order to
4580e8
    # answer the question: How do we assign chapters, sections and
4580e8
    # subsections automatically, based on the repository structure?
4580e8
    # and also, how such design could be adapted to changes in the
4580e8
    # repository structure?
4580e8
    #
4580e8
    # One solution would be: represent the repository's directory
4580e8
    # structure as sections inside a chapter named `Directories' or
4580e8
    # something similar. Subsections and subsubsections will not have
4580e8
    # their own files, they all will be written inside the same
4580e8
    # section file that represents the repository documentation entry.
79bb17
    MANUAL_CHAPTER_DIR=${MANUAL_BASEDIR}/${MANUAL_CHAPTER_NAME}
4580e8
4580e8
    # Define absolute path to backend template files.
4580e8
    MANUAL_TEMPLATE=${FUNCDIR}/${FUNCDIRNAM}/Templates/$(cli_getCurrentLocale)
4580e8
4580e8
    # Verify absolute path to backend template files. If the absolute
4580e8
    # path doesn't exist, use the English language templates.
4580e8
    if [[ ! -d $MANUAL_TEMPLATE ]];then
4580e8
        MANUAL_TEMPLATE=${FUNCDIR}/${FUNCDIRNAM}/Templates/en_US
4580e8
    fi
4580e8
4580e8
    # Create documentation structure, if it doesn't exist.
4580e8
    ${FLAG_BACKEND}_createStructure
4580e8
4580e8
    # Syncronize changes between repository and working copy. At this
4580e8
    # point, changes in the repository are merged in the working copy
4580e8
    # and changes in the working copy committed up to repository.
4580e8
    cli_syncroRepoChanges ${MANUAL_CHAPTER_DIR}
4580e8
4580e8
    # Execute backend functionalities. Notice that there are
4580e8
    # functionalities that need more than one action value in order to
4580e8
    # be executed (e.g.,  copying, and renaming), functionalities
4580e8
    # that need just one action value to be executed (e.g.,
4580e8
    # documentation reading and edition) and functionalities that
4580e8
    # don't need action value at all (e.g., searching, reading and
4580e8
    # updating output files). This way, the execution of backend
4580e8
    # functionalities is splitted here.
4580e8
    if [[ $ACTIONNAM =~ "${FLAG_BACKEND}_(copy|rename|delete)Entry" ]];then
4580e8
4580e8
        # Execute backend action names that may need to use more than
4580e8
        # one action value.
4580e8
        ${ACTIONNAM} $@
4580e8
4580e8
    elif [[ $ACTIONNAM =~ "${FLAG_BACKEND}_(search(Index|Node)|updateOutputFiles)" ]];then
4580e8
4580e8
        # Execute backend action names that might not need any action
4580e8
        # value as reference to do their work.
4580e8
        $ACTIONNAM $@
4580e8
4580e8
        # Backend action names that don't need to use any action value
4580e8
        # as reference to do their work are of one-pass only. They are
4580e8
        # executed and then the script execution is finished.
4580e8
        exit
4580e8
4580e8
    else
4580e8
4580e8
        # Execute backend action names that use one action value, only.
4580e8
        for ACTIONVAL in $@;do
4580e8
        
4580e8
            # Define documentation entry.
4580e8
            MANUAL_ENTRY=$(${FLAG_BACKEND}_getEntry $ACTIONVAL)
4580e8
4580e8
            # Execute backend action names that may need to use more
4580e8
            # than one action value.
4580e8
            $ACTIONNAM 
4580e8
4580e8
        done
4580e8
4580e8
    fi
4580e8
4580e8
    # Commit changes from working copy to central repository only.  At
4580e8
    # this point, changes in the repository are not merged in the
4580e8
    # working copy, but chages in the working copy do are committed up
4580e8
    # to repository.
4580e8
    cli_commitRepoChanges ${MANUAL_CHAPTER_DIR}
4580e8
4580e8
    # Rebuild output files to propagate recent changes.
4580e8
    ${FLAG_BACKEND}_updateOutputFiles
4580e8
4580e8
}