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

edaa9d
#!/bin/bash
edaa9d
#
edaa9d
# texinfo_copyEntryChapter.sh -- This function standardizes chapter
edaa9d
# duplication inside manuals written in texinfo format.
edaa9d
#
2fe9b7
# Copyright (C) 2009, 2010, 2011 The CentOS Project
edaa9d
#
edaa9d
# This program is free software; you can redistribute it and/or modify
edaa9d
# it under the terms of the GNU General Public License as published by
edaa9d
# the Free Software Foundation; either version 2 of the License, or (at
edaa9d
# your option) any later version.
edaa9d
#
edaa9d
# This program is distributed in the hope that it will be useful, but
edaa9d
# WITHOUT ANY WARRANTY; without even the implied warranty of
edaa9d
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
edaa9d
# General Public License for more details.
edaa9d
#
edaa9d
# You should have received a copy of the GNU General Public License
edaa9d
# along with this program; if not, write to the Free Software
edaa9d
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
edaa9d
#
edaa9d
# ----------------------------------------------------------------------
edaa9d
# $Id$
edaa9d
# ----------------------------------------------------------------------
edaa9d
edaa9d
function texinfo_copyEntryChapter {
edaa9d
e7414c
    # Redefine documentation entry source's location.
e0c375
    MANUAL_ENTRY_SRC=${MANUAL_BASEDIR_L10N}/${MANUAL_CHAP[${MANUAL_DOCENTRY_ID}]}
edaa9d
e7414c
    # Redefine documentation entry target's location.
e0c375
    MANUAL_ENTRY_DST=${MANUAL_BASEDIR_L10N}/${MANUAL_CHAP[((${MANUAL_DOCENTRY_ID} + 1))]}
edaa9d
4f8368
    # Verify entry source and target locations.
0ca0ad
    ${MANUAL_BACKEND}_checkEntrySrcDst "${MANUAL_ENTRY_SRC}" "${MANUAL_ENTRY_DST}"
edaa9d
edaa9d
    # When we are copying chapters, document structure actualization
edaa9d
    # needs to be performed against the target chapter not the source
edaa9d
    # one used to create the duplication.  To achieve this goal,
e7414c
    # define both chapter's directory and chapter's name at this
edaa9d
    # point.
edaa9d
    local MANUAL_CHAPTER_DIR=$MANUAL_ENTRY_DST
e0c375
    local MANUAL_CHAPTER_NAME=${MANUAL_CHAP[((${MANUAL_DOCENTRY_ID} + 1))]}
edaa9d
edaa9d
    # When we are copying chapters, the chapter itself cannot be
edaa9d
    # copied as we regularly do with sections. Instead, the target
edaa9d
    # chapter must be created as a new chapter and then sections from
edaa9d
    # source chapter must be copied one by one to the recently created
edaa9d
    # chapter. At this point then, is when menu, nodes and cross
edaa9d
    # references for the new chapter are updated.
0ca0ad
    ${MANUAL_BACKEND}_createChapter
edaa9d
edaa9d
    # Create list of sections from source chapter that need to be
4f8368
    # copied to target chapter. Don't include chapter's main
4f8368
    # definition files.
edaa9d
    local MANUAL_ENTRIES=$(cli_getFilesList $MANUAL_ENTRY_SRC \
e7414c
        --pattern="${MANUAL_ENTRY_SRC}/.+\.${MANUAL_EXTENSION}" \
edaa9d
        | egrep -v '/chapter')
edaa9d
edaa9d
    # Copy sections from source chapter to target chapter.
edaa9d
    for MANUAL_ENTRY in $MANUAL_ENTRIES;do
edaa9d
        svn cp $MANUAL_ENTRY $MANUAL_ENTRY_DST --quiet
edaa9d
    done
edaa9d
e7414c
    # Update section menu, nodes and cross reference definitions
e7414c
    # inside target chapter where all section entries were copied to.
0ca0ad
    ${MANUAL_BACKEND}_updateStructureSection "${MANUAL_ENTRY_DST}/.+\.${MANUAL_EXTENSION}"
e7414c
e7414c
    # Update chapter menu and node definitions inside the manual
e7414c
    # structure.
0ca0ad
    ${MANUAL_BACKEND}_updateChapterMenu
0ca0ad
    ${MANUAL_BACKEND}_updateChapterNodes
edaa9d
edaa9d
}