Blame Scripts/Functions/Help/help.sh

4c79b5
#!/bin/bash
4c79b5
#
02d6e2
# help.sh -- This function standardizes the way documentation is
06d8c8
# produced and maintained inside the working copy of CentOS Artwork
02d6e2
# Repository.
4c79b5
#
3b0984
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7ac5a5
#
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
    
0211a4
function help {
2bd980
c145a8
    local ACTIONNAM=''
c145a8
    local ACTIONVAL=''
c145a8
1b527b
    # Initialize the search option. The search option (`--search')
1b527b
    # specifies the pattern used inside info files when an index
1b527b
    # search is perform.
1b527b
    FLAG_SEARCH=""
1b527b
3ae895
    # Define file name (without extension) for documentation manual.
420e77
    MANUAL_NAME=$(cli_getRepoName "repository" -f)
1f6dd8
9fa13b
    # Define file extension used by documentation manual source files.
9fa13b
    MANUAL_EXTENSION='texinfo'
9fa13b
0c5b48
    # Define language information used by manual.
0c5b48
    MANUAL_LANG=$(cli_getCurrentLocale)
420e77
23c4a7
    # Define manual base directory to refere the place where
23c4a7
    # language-specific source files used by texinfo documentation
23c4a7
    # backend are stored in.
23c4a7
    MANUAL_BASEDIR="${HOME}/trunk/Manuals/RepoReference/${MANUAL_LANG}"
23c4a7
23c4a7
    # Define base name for documentation manual files (without
23c4a7
    # extension). This is the main file name used to build output
23c4a7
    # related files (.info, .pdf, .xml, etc.).
23c4a7
    MANUAL_BASEFILE="${MANUAL_BASEDIR}/${MANUAL_NAME}"
23c4a7
23c4a7
    # Define chapter name of directory where repository documentation
23c4a7
    # entries will be stored in.
23c4a7
    MANUAL_CHAPTER_NAME=$(cli_getRepoName "Directories" -d)
23c4a7
23c4a7
    # Define absolute path to chapter directory where repository
23c4a7
    # documentation entries will be stored in.  At this point, we need
23c4a7
    # to take a desition about documentation design, in order to
23c4a7
    # answer the question: How do we assign chapters, sections and
23c4a7
    # subsections automatically, based on the repository structure?
23c4a7
    # and also, how such design could be adapted to changes in the
23c4a7
    # repository structure?
23c4a7
    #
23c4a7
    # One solution would be: represent the repository's directory
23c4a7
    # structure as sections inside a chapter named `Directories' or
23c4a7
    # something similar. Subsections and subsubsections will not have
23c4a7
    # their own files, they all will be written inside the same
23c4a7
    # section file that represents the repository documentation entry.
23c4a7
    MANUAL_CHAPTER_DIR=${MANUAL_BASEDIR}/${MANUAL_CHAPTER_NAME}
23c4a7
23c4a7
    # Define absolute path to backend template files.
23c4a7
    MANUAL_TEMPLATE=${FUNCDIR}/${FUNCDIRNAM}/Templates/$(cli_getCurrentLocale)
23c4a7
23c4a7
    # Verify absolute path to backend template files. If the absolute
23c4a7
    # path doesn't exist, use the English language templates.
23c4a7
    if [[ ! -d $MANUAL_TEMPLATE ]];then
23c4a7
        MANUAL_TEMPLATE=${FUNCDIR}/${FUNCDIRNAM}/Templates/en_US
23c4a7
    fi
23c4a7
23c4a7
    # Create documentation structure, if it doesn't exist.
23c4a7
    ${FUNCNAM}_createStructure
23c4a7
0c5b48
    # Interpret option arguments passed through the command-line.
0c5b48
    ${FUNCNAM}_getOptions
116f45
c145a8
    # Redefine positional parameters using ARGUMENTS. At this point,
c145a8
    # option arguments have been removed from ARGUMENTS variable and
c145a8
    # only non-option arguments remain in it. 
c145a8
    eval set -- "$ARGUMENTS"
0c5b48
23c4a7
    # Syncronize changes between repository and working copy. At this
23c4a7
    # point, changes in the repository are merged in the working copy
23c4a7
    # and changes in the working copy committed up to repository.
23c4a7
    cli_syncroRepoChanges ${MANUAL_CHAPTER_DIR}
23c4a7
23c4a7
    # Execute backend functionalities. Notice that there are
23c4a7
    # functionalities that need more than one action value in order to
23c4a7
    # be executed (e.g.,  copying, and renaming), functionalities
23c4a7
    # that need just one action value to be executed (e.g.,
23c4a7
    # documentation reading and edition) and functionalities that
23c4a7
    # don't need action value at all (e.g., searching, reading and
23c4a7
    # updating output files). This way, the execution of backend
23c4a7
    # functionalities is splitted here.
23c4a7
    if [[ $ACTIONNAM =~ "${FUNCNAM}_(copy|rename|delete)Entry" ]];then
23c4a7
23c4a7
        # Execute backend action names that may need to use more than
23c4a7
        # one action value.
23c4a7
        ${ACTIONNAM} $@
23c4a7
23c4a7
    elif [[ $ACTIONNAM =~ "${FUNCNAM}_(search(Index|Node)|updateOutputFiles)" ]];then
23c4a7
23c4a7
        # Execute backend action names that might not need any action
23c4a7
        # value as reference to do their work.
23c4a7
        $ACTIONNAM $@
23c4a7
23c4a7
        # Backend action names that don't need to use any action value
23c4a7
        # as reference to do their work are of one-pass only. They are
23c4a7
        # executed and then the script execution is finished.
23c4a7
        exit
23c4a7
e5750b
    else
23c4a7
23c4a7
        # Execute backend action names that use one action value, only.
23c4a7
        for ACTIONVAL in $@;do
23c4a7
        
23c4a7
            # Define documentation entry.
23c4a7
            MANUAL_ENTRY=$(${FUNCNAM}_getEntry $ACTIONVAL)
23c4a7
23c4a7
            # Execute backend action names that may need to use more
23c4a7
            # than one action value.
23c4a7
            $ACTIONNAM 
23c4a7
23c4a7
        done
23c4a7
e5750b
    fi
c145a8
23c4a7
    # Commit changes from working copy to central repository only.  At
23c4a7
    # this point, changes in the repository are not merged in the
23c4a7
    # working copy, but chages in the working copy do are committed up
23c4a7
    # to repository.
23c4a7
    cli_commitRepoChanges ${MANUAL_CHAPTER_DIR}
23c4a7
23c4a7
    # Rebuild output files to propagate recent changes.
23c4a7
    ${FUNCNAM}_updateOutputFiles
23c4a7
23c4a7
}