Blame Scripts/Bash/Functions/Help/Texinfo/texinfo_deleteEntryChapter.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# texinfo_deleteEntryChapter.sh -- This function standardizes chapter
878a2b
# deletion inside the manual structure.
878a2b
#
03486a
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
878a2b
#
878a2b
# This program is free software; you can redistribute it and/or modify
878a2b
# it under the terms of the GNU General Public License as published by
878a2b
# the Free Software Foundation; either version 2 of the License, or (at
878a2b
# your option) any later version.
878a2b
#
878a2b
# This program is distributed in the hope that it will be useful, but
878a2b
# WITHOUT ANY WARRANTY; without even the implied warranty of
878a2b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
878a2b
# General Public License for more details.
878a2b
#
878a2b
# You should have received a copy of the GNU General Public License
878a2b
# along with this program; if not, write to the Free Software
878a2b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
878a2b
#
878a2b
# ----------------------------------------------------------------------
878a2b
# $Id$
878a2b
# ----------------------------------------------------------------------
878a2b
878a2b
function texinfo_deleteEntryChapter {
878a2b
878a2b
    # Print action message.
878a2b
    cli_printMessage "$MANUAL_CHAPTER_DIR" --as-deleting-line
878a2b
375adc
    # Verify existence of documentation entry before deleting it.
375adc
    # We cannot delete an entry which doesn't exist.
375adc
    cli_checkFiles "$MANUAL_CHAPTER_DIR" -d
878a2b
6155da
    # Define list of chapters that shouldn't be removed.
6155da
    local SPECIAL_CHAPTERS='/(Licenses|Index)$'
6155da
6155da
    # Verify list of chapters that shouldn't be removed against the
6155da
    # current chapter directory being removed.
6155da
    if [[ $MANUAL_CHAPTER_DIR =~ $SPECIAL_CHAPTERS ]];then
6155da
        cli_printMessage "`gettext "The chapter specified cannot be removed."`" --as-error-line
6155da
    fi
6155da
878a2b
    # Build list of section entries inside the chapter. This is
878a2b
    # required to delete cross references from other section entries
878a2b
    # that point to section entries inside the chapter that will be
878a2b
    # deleted. Take care don't include the chapter definition files.
878a2b
    local MANUAL_ENTRIES=$(cli_getFilesList $MANUAL_CHAPTER_DIR \
e3120a
        --pattern="^.+\.${MANUAL_EXTENSION}$" \
e3120a
        | egrep -v "(${MANUAL_NAME}|chapter)-(menu|nodes|index)")
878a2b
878a2b
    # Remove chapter directory using subversion to register the
878a2b
    # change.
375adc
    cli_runFnEnvironment svn --quiet --delete ${MANUAL_CHAPTER_DIR}
878a2b
878a2b
    # Update chapter menu and nodes inside manual structure.
878a2b
    texinfo_updateChapterMenu --delete-entry
878a2b
    texinfo_updateChapterNodes
878a2b
e3120a
    # Loop through section entries retrieved from chapter, before
878a2b
    # deleting it, in order to remove cross references pointing to
878a2b
    # those section entries. Since the chapter and all its sections
878a2b
    # have been removed, cross references pointing them will point to
878a2b
    # non-existent section entries. This way, all cross references
878a2b
    # pointing to non-existent section entries will be transformed in
e3120a
    # order for documenters to advertise the section entry state.
878a2b
    for MANUAL_ENTRY in $MANUAL_ENTRIES;do
878a2b
        texinfo_deleteCrossReferences ${MANUAL_ENTRY}
878a2b
    done
878a2b
878a2b
}