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

878a2b
#!/bin/bash
878a2b
#
878a2b
# texinfo_editEntry.sh -- This function implements the edition flow of
878a2b
# documentation entries inside the working copy.
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_editEntry {
878a2b
878a2b
    # Print separator line.
878a2b
    cli_printMessage '-' --as-separator-line
878a2b
878a2b
    # Verify section definition inside chapters. 
878a2b
    if [[ ! -f $MANUAL_ENTRY ]];then
878a2b
878a2b
        # Verify chapter related to documentation entry. Inside
878a2b
        # manuals, all documentation entries are stored directly under
878a2b
        # its chapter directory. There is no more levels deep so it is
878a2b
        # possible to perform a direct chapter verification here.
878a2b
        if [[ ! -a $(dirname $MANUAL_ENTRY)/chapter.${MANUAL_EXTENSION} ]];then
878a2b
            texinfo_createChapter
878a2b
        fi
878a2b
878a2b
        # Print confirmation question. 
5b3e17
        cli_printMessage "`gettext "The following documentation section doesn't exist:"`" --as-stdout-line
878a2b
        cli_printMessage "$MANUAL_ENTRY" --as-response-line
5b3e17
        cli_printMessage "`gettext "Do you want to create it now?"`" --as-yesornorequest-line
878a2b
878a2b
        # Update section menu, nodes and cross references based on
878a2b
        # changes in order for manual structure to remain cosistent.
878a2b
        texinfo_updateStructureSection "$MANUAL_ENTRY"
878a2b
878a2b
        # Use default text editor to write changes on documentation entry.
878a2b
        $EDITOR $MANUAL_ENTRY
878a2b
878a2b
    else
878a2b
878a2b
        # Print action message.
878a2b
        cli_printMessage "$MANUAL_ENTRY" --as-updating-line
878a2b
878a2b
        # Rebuild section menu definitions before editing the
878a2b
        # documentation entry. This way, if there is any change in the
878a2b
        # section menu definition, it will be visible to you on
878a2b
        # edition.
878a2b
        texinfo_makeSeeAlso "$MANUAL_ENTRY"
878a2b
878a2b
        # Use default text editor to write changes on documentation entry.
878a2b
        $EDITOR $MANUAL_ENTRY
878a2b
878a2b
        # Rebuild section menu definitions after editing the
878a2b
        # documentation entry. This way, if there is any change or
878a2b
        # expansion to realize in the section menu definition, it be
878a2b
        # applied right now. Don't see a reason for waiting until the
878a2b
        # next edition for expansions to happen.
878a2b
        texinfo_makeSeeAlso "$MANUAL_ENTRY"
878a2b
878a2b
    fi
878a2b
878a2b
}