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

edaa9d
#!/bin/bash
edaa9d
#
edaa9d
# texinfo_updateStructureSection.sh -- This function looks for all
edaa9d
# documentation entry (section) files inside manual's base directory and
edaa9d
# updates menu, nodes and cross references for them.
edaa9d
#
edaa9d
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
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_updateStructureSection {
edaa9d
edaa9d
    local PATTERN=''
edaa9d
    local MANUAL_ENTRY=''
edaa9d
    local MANUAL_ENTRIES=''
edaa9d
edaa9d
    # Define find's regular expression pattern.
edaa9d
    if [[ $1 != '' ]];then
edaa9d
        PATTERN="$1"
edaa9d
    else
edaa9d
        PATTERN=".+\.${MANUAL_EXTENSION}"
edaa9d
    fi
edaa9d
edaa9d
    # Define list of target documentation entries using find's regular
edaa9d
    # expression pattern as reference. This is required in order to
edaa9d
    # process non-existent documentation entries (e.g., when they are
edaa9d
    # created for first time). Otherwise, the list of documentation
edaa9d
    # entries will be empty an no entry would be processed.
edaa9d
    if [[ ${PATTERN} =~ '^/.+\.texinfo$' ]];then
edaa9d
edaa9d
        # When the pattern value is an absolute path to a
edaa9d
        # documentation entry, use that value as only documentation
edaa9d
        # entry in the list.
edaa9d
        MANUAL_ENTRIES=${PATTERN}
edaa9d
edaa9d
    else
edaa9d
edaa9d
        # When the pattern value is a regular expression, use
edaa9d
        # cli_getFilesList to build the list of documentation entries
edaa9d
        # using it.  Don't include manual or chapter definition files
edaa9d
        # in this list, it would create documentation entries for them
edaa9d
        # and that shouldn't happen.
5e989a
        MANUAL_ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR} \
edaa9d
            --pattern="$PATTERN" | egrep -v "/(${MANUAL_NAME}|chapter)")
edaa9d
    fi
edaa9d
edaa9d
    # Print action message.
edaa9d
    cli_printMessage "`gettext "Updating section menus, nodes and cross references."`" --as-response-line
edaa9d
edaa9d
    # Loop through target documentation entries in order to update
edaa9d
    # the documentation structure (e.g., It is not enough with copying
edaa9d
    # documentation entry files, it is also needed to update menu,
edaa9d
    # nodes and related cross-references).
edaa9d
    for MANUAL_ENTRY in ${MANUAL_ENTRIES};do
edaa9d
edaa9d
        # Update menu and node definitions for sections inside manual
edaa9d
        # in order to reflect the changes.
60a25c
        ${FLAG_BACKEND}_updateSectionMenu
4e0284
        ${FLAG_BACKEND}_updateSectionNodes
edaa9d
edaa9d
        # Resotre cross reference definitions inside manual structure.
edaa9d
        # If a documentation entry has been removed by mistake and
edaa9d
        # that mistake is later fixed by adding the removed
edaa9d
        # documentation entry back into the manual structure, it is
edaa9d
        # necessary to rebuild the missing cross reference information
edaa9d
        # inside the manual structure in order to reactivate the
edaa9d
        # removed cross refereces, as well.
edaa9d
        ${FLAG_BACKEND}_restoreCrossReferences $MANUAL_ENTRY
edaa9d
edaa9d
    done
edaa9d
edaa9d
}