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

522184
#!/bin/bash
522184
#
522184
# help.sh -- This function implements Texinfo documentation backend.
522184
# This is, the collection of frequent actions required to produce and
522184
# maintain The CentOS Artwork Repsoitory user's guide in Texinfo
522184
# format.
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
522184
    # Define file name (without extension) for documentation manual.
a09bb0
    MANUAL_NAME=$(cli_getRepoName "$(basename $MANUAL_TLDIR)" -f)
522184
522184
    # Define file extension used by documentation manual source files.
522184
    MANUAL_EXTENSION='texinfo'
522184
e1df5c
    # Define manual base directory. This is where language-specific
e1df5c
    # documentation source files are stored in.
e1df5c
    MANUAL_BASEDIR="${MANUAL_BACKEND_DIR}/${MANUAL_LANG}"
522184
522184
    # Define base name for documentation manual files (without
522184
    # extension). This is the main file name used to build output
522184
    # related files (.info, .pdf, .xml, etc.).
522184
    MANUAL_BASEFILE="${MANUAL_BASEDIR}/${MANUAL_NAME}"
522184
7c07fa
    # Define default behaviour when no action has been provided to
7c07fa
    # `centos-art.sh' script command-line interface.
7c07fa
    if [[ $ACTIONNAM == '' ]];then
7c07fa
        /usr/bin/info --node="Top" --file=${MANUAL_BASEFILE}.info.bz2
7c07fa
        exit
7c07fa
    fi
7c07fa
522184
    # Define chapter name of directory where repository documentation
522184
    # entries will be stored in.
522184
    MANUAL_CHAPTER_NAME=$(cli_getRepoName "Directories" -d)
522184
522184
    # Define absolute path to chapter directory where repository
522184
    # documentation entries will be stored in.  At this point, we need
522184
    # to take a desition about documentation design, in order to
522184
    # answer the question: How do we assign chapters, sections and
522184
    # subsections automatically, based on the repository structure?
522184
    # and also, how such design could be adapted to changes in the
522184
    # repository structure?
522184
    #
522184
    # One solution would be: represent the repository's directory
522184
    # structure as sections inside a chapter named `Directories' or
522184
    # something similar. Subsections and subsubsections will not have
522184
    # their own files, they all will be written inside the same
522184
    # section file that represents the repository documentation entry.
522184
    MANUAL_CHAPTER_DIR=${MANUAL_BASEDIR}/${MANUAL_CHAPTER_NAME}
522184
522184
    # Define absolute path to backend template files.
e1df5c
    MANUAL_TEMPLATE=${FUNCDIR}/${FUNCDIRNAM}/Texinfo/Templates/${MANUAL_LANG}
522184
522184
    # Verify absolute path to backend template files. If the absolute
522184
    # path doesn't exist, use the English language templates.
522184
    if [[ ! -d $MANUAL_TEMPLATE ]];then
522184
        MANUAL_TEMPLATE=${FUNCDIR}/${FUNCDIRNAM}/Templates/en_US
522184
    fi
522184
522184
    # Create documentation structure, if it doesn't exist.
448d34
    ${MANUAL_BACKEND}_createStructure
522184
522184
    # Syncronize changes between repository and working copy. At this
522184
    # point, changes in the repository are merged in the working copy
522184
    # and changes in the working copy committed up to repository.
522184
    cli_syncroRepoChanges ${MANUAL_CHAPTER_DIR}
522184
522184
    # Execute backend functionalities. Notice that there are
522184
    # functionalities that need more than one action value in order to
522184
    # be executed (e.g.,  copying, and renaming), functionalities
522184
    # that need just one action value to be executed (e.g.,
522184
    # documentation reading and edition) and functionalities that
522184
    # don't need action value at all (e.g., searching, reading and
522184
    # updating output files). This way, the execution of backend
522184
    # functionalities is splitted here.
7c07fa
    if [[ $ACTIONNAM =~ "^(copy|rename|delete)Entry$" ]];then
522184
522184
        # Execute backend action names that may need to use more than
522184
        # one action value.
7b9c0f
        ${MANUAL_BACKEND}_${ACTIONNAM} $@
522184
7c07fa
    elif [[ $ACTIONNAM =~ "^(search(Index|Node)|updateOutputFiles)$" ]];then
522184
522184
        # Execute backend action names that might not need any action
522184
        # value as reference to do their work.
7b9c0f
        ${MANUAL_BACKEND}_$ACTIONNAM $@
522184
522184
        # Backend action names that don't need to use any action value
522184
        # as reference to do their work are of one-pass only. They are
522184
        # executed and then the script execution is finished.
522184
        exit
522184
522184
    else
522184
522184
        # Execute backend action names that use one action value, only.
7b9c0f
        for ACTIONVAL in $@;do
522184
        
522184
            # Define documentation entry.
448d34
            MANUAL_ENTRY=$(${MANUAL_BACKEND}_getEntry $ACTIONVAL)
522184
522184
            # Execute backend action names that may need to use more
522184
            # than one action value.
e1df5c
            ${MANUAL_BACKEND}_$ACTIONNAM
522184
522184
        done
522184
522184
    fi
522184
522184
    # Commit changes from working copy to central repository only.  At
522184
    # this point, changes in the repository are not merged in the
522184
    # working copy, but chages in the working copy do are committed up
522184
    # to repository.
522184
    cli_commitRepoChanges ${MANUAL_CHAPTER_DIR}
522184
522184
    # Rebuild output files to propagate recent changes.
448d34
    ${MANUAL_BACKEND}_updateOutputFiles
522184
522184
}