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

2c488f
#!/bin/bash
2c488f
#
993f6a
# texinfo_createStructure.sh -- This function creates the
2c488f
# documentation structure of a manual using the current language as
2c488f
# reference.
2c488f
#
3b0984
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
2c488f
#
2c488f
# This program is free software; you can redistribute it and/or modify
2c488f
# it under the terms of the GNU General Public License as published by
2c488f
# the Free Software Foundation; either version 2 of the License, or (at
2c488f
# your option) any later version.
2c488f
#
2c488f
# This program is distributed in the hope that it will be useful, but
2c488f
# WITHOUT ANY WARRANTY; without even the implied warranty of
2c488f
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
2c488f
# General Public License for more details.
2c488f
#
2c488f
# You should have received a copy of the GNU General Public License
2c488f
# along with this program; if not, write to the Free Software
2c488f
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2c488f
#
2c488f
# ----------------------------------------------------------------------
2c488f
# $Id$
2c488f
# ----------------------------------------------------------------------
2c488f
993f6a
function texinfo_createStructure {
2c488f
2c488f
    # Verify manual base directory. The manual base directory is where
2c488f
    # the whole documentation manual is stored in. If it already
2c488f
    # exist, assume it was correctly created in the past.
2c488f
    if [[ -d $MANUAL_BASEDIR ]];then
2c488f
        return
6150a1
    else
6150a1
        cli_printMessage "`gettext "The manual you provided doesn't exist in your working copy."`" --as-banner-line
6150a1
        cli_printMessage "`gettext "Do you want to create this manual now?"`" --as-yesornorequest-line
2c488f
    fi
2c488f
6150a1
    # Print separator line.
2c488f
    cli_printMessage "-" --as-separator-line
2c488f
6150a1
    # Initialize manual's information (e.g., title, subtitle, abstract).
6150a1
    local MANUAL_TITLE=''
6150a1
    local MANUAL_SUBTITLE=''
6150a1
    local MANUAL_ABSTRACT=''
6150a1
6150a1
    # Create manual's top-level directory. This is the place where all
6150a1
    # texinfo documentation manuals is stored in.
6150a1
    if [[ ! -d ${MANUAL_TLDIR} ]];then
6150a1
6150a1
        # Use subversion to create the top-level directory.
6150a1
        svn mkdir ${MANUAL_TLDIR} --quiet
6150a1
    
6150a1
    fi
6150a1
6150a1
    # Create manual's base directory. This is the place where
6150a1
    # language-specific documentation source files are stored in.
2c488f
    svn mkdir ${MANUAL_BASEDIR} --quiet
2c488f
6150a1
    # Retrive manual's information from standard input.
6150a1
    cli_printMessage "`gettext "Enter manual's title"`" --as-request-line
6150a1
    read MANUAL_TITLE
6150a1
    cli_printMessage "`gettext "Enter manual's subtitle"`" --as-request-line
6150a1
    read MANUAL_SUBTITLE
6150a1
    cli_printMessage "`gettext "Enter manual's abstract"`" --as-request-line
6150a1
    read MANUAL_ABSTRACT
6150a1
6150a1
    # Print action message.
6150a1
    cli_printMessage "-" --as-separator-line
6150a1
    cli_printMessage "`gettext "Creating manual's structure in texinfo format."`"
6150a1
6150a1
    # Verify manual's information. The title information must be
6150a1
    # non-empty value.
6150a1
    if [[ $MANUAL_TITLE == '' ]];then
6150a1
        cli_printMessage "`gettext "The manual's title cannot be empty."`" --as-error-line
6150a1
    fi
6150a1
420e77
    # Define file names required to build the manual.
420e77
    local FILE=''
6150a1
    local FILES=$(cli_getFilesList "${MANUAL_TEMPLATE_L10N}" \
420e77
        --maxdepth='1' \
6150a1
        --pattern="manual(-menu|-nodes|-index)?\.${MANUAL_EXTENSION}")
420e77
2c488f
    # Verify manual base file. The manual base file is where the
2c488f
    # documentation manual is defined in the backend format. Assuming
2c488f
    # no file exists (e.g., a new language-specific manual is being
420e77
    # created), use texinfo templates for it.
420e77
    for FILE in $FILES;do
420e77
        if [[ ! -f ${MANUAL_BASEDIR}/$(basename ${FILE}) ]];then
6150a1
6150a1
            # Be sure the file is inside the working copy and under
6150a1
            # version control. 
420e77
            cli_checkFiles ${FILE} -wn
6150a1
6150a1
            # Define target file.
6150a1
            local DST=${MANUAL_BASEDIR}/$(basename ${FILE} \
6150a1
                | sed -r "s!manual!${MANUAL_NAME}!")
6150a1
6150a1
            # Copy using subversion to register this action.
6150a1
            svn cp ${FILE} $DST --quiet
6150a1
            
6150a1
            # Expand common translation markers inside target file.
6150a1
            cli_replaceTMarkers $DST
6150a1
6150a1
            # Expand specific translation markers inside target file.
6150a1
            sed -r -i -e "s!=MANUAL_NAME=!${MANUAL_NAME}!g" \
6150a1
                -e "s!=MANUAL_TITLE=!${MANUAL_TITLE}!g" \
6150a1
                -e "s!=MANUAL_SUBTITLE=!${MANUAL_SUBTITLE}!g" \
6150a1
                -e "s!=MANUAL_ABSTRACT=!${MANUAL_ABSTRACT}!g" $DST
6150a1
2c488f
        fi
2c488f
    done
2c488f
2c488f
    # Update manual chapter related files.
448d34
    ${MANUAL_BACKEND}_createChapters
2c488f
2c488f
    # Update manual chapter related menu.
448d34
    ${MANUAL_BACKEND}_updateChaptersMenu
2c488f
2c488f
    # Update manual chapter related nodes (based on chapter related
2c488f
    # menu).
448d34
    ${MANUAL_BACKEND}_updateChaptersNodes
2c488f
2c488f
    # Commit changes from working copy to central repository only.  At
2c488f
    # this point, changes in the repository are not merged in the
2c488f
    # working copy, but chages in the working copy do are committed up
2c488f
    # to repository.
6150a1
    if [[ ! -d ${MANUAL_TLDIR} ]];then
6150a1
        cli_commitRepoChanges ${MANUAL_TLDIR}
6150a1
    fi
2c488f
2c488f
}