Blame Scripts/Bash/Functions/Manual/manual_updateNodes.sh

4c79b5
#!/bin/bash
4c79b5
#
4de5d4
# manual_updateNodes.sh -- This function updates chapter's nodes
4c79b5
# definition using the chapter's menu as reference.
4c79b5
#
9f5f2e
# Copyright (C) 2009-2011 Alain Reguera Delgado
4c79b5
# 
7cd8e9
# This program is free software; you can redistribute it and/or
7cd8e9
# modify it under the terms of the GNU General Public License as
7cd8e9
# published by the Free Software Foundation; either version 2 of the
7cd8e9
# License, or (at your option) any later version.
4c79b5
# 
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4c79b5
# USA.
4c79b5
# 
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
4de5d4
function manual_updateNodes {
4c79b5
4c79b5
    # Retrive nodes' entries from chapter-menu.texi file.
4c79b5
    local NODES=$(cat $ENTRYCHAPTER/${MANUALS_FILE[8]} \
4c79b5
        | sed -r 's!^\* !!' | sed -r 's!:{1,2}.*$!!g' \
4c79b5
        | egrep -v '^@(end )?menu$' | sed -r 's! !:!g' | sort | uniq)
4c79b5
4c79b5
    # Re-build node structure based on menu information.
4c79b5
    for NODE in $NODES;do
4c79b5
ddf424
        NODE=$(echo "$NODE" | sed -r 's!:! !g')
ddf424
        SECT=$(echo "$NODE" | sed -r 's! !/!g')
ddf424
        INCL=$(echo "$NODE" | sed -r 's! !/!g').texi
ddf424
        CIND=$(echo "$NODE")
4c79b5
4c79b5
        # Create an emtpy directory to store texinfo files.
ddf424
        if [[ ! -d ${MANUALS_DIR[2]}/$(dirname "$INCL") ]];then
ddf424
             mkdir -p ${MANUALS_DIR[2]}/$(dirname "$INCL")
4c79b5
        fi
4c79b5
4c79b5
        # Create texinfo section file using its template.
4c79b5
        if [[ ! -f ${MANUALS_DIR[2]}/$INCL ]];then
4c79b5
4c79b5
            cp ${MANUALS_FILE[10]} ${MANUALS_DIR[2]}/$INCL
4c79b5
4c79b5
            # Translate template instance.
4c79b5
            sed -r -i \
4c79b5
                -e "s!=GOALS=!`gettext "Goals"`!g" \
4c79b5
                -e "s!=USAGE=!`gettext "Usage"`!g" \
4c79b5
                -e "s!=DESCRIPTION=!`gettext "Description"`!g" \
4c79b5
                -e "s!=SEEALSO=!`gettext "See also"`!g" \
4c79b5
                ${MANUALS_DIR[2]}/$INCL
4c79b5
4c79b5
        fi
4c79b5
4c79b5
        # Output node information based on texinfo menu.
4c79b5
        echo "@node $NODE"
4c79b5
        echo "@section $SECT"
4c79b5
        echo "@cindex $CIND"
4c79b5
        echo "@include $INCL"
4c79b5
        echo ""
4c79b5
4c79b5
    # Dump node information into chapter node file.
4c79b5
    done > $ENTRYCHAPTER/${MANUALS_FILE[9]}
4c79b5
4c79b5
}
4c79b5