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

858566
#!/bin/bash
858566
#
993f6a
# texinfo_makeSeeAlso.sh -- This function creates an itemized list
858566
# of links to refer parent documentation entries. This list of links
858566
# is expanded wherever the =TEXINFO_SEEALSO= translation marker be
858566
# placed in the documentation entry.
858566
#
3b0984
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
858566
#
858566
# This program is free software; you can redistribute it and/or modify
858566
# it under the terms of the GNU General Public License as published by
858566
# the Free Software Foundation; either version 2 of the License, or (at
858566
# your option) any later version.
858566
#
858566
# This program is distributed in the hope that it will be useful, but
858566
# WITHOUT ANY WARRANTY; without even the implied warranty of
858566
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
858566
# General Public License for more details.
858566
#
858566
# You should have received a copy of the GNU General Public License
858566
# along with this program; if not, write to the Free Software
858566
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
858566
#
858566
# ----------------------------------------------------------------------
858566
# $Id$
858566
# ----------------------------------------------------------------------
858566
993f6a
function texinfo_makeSeeAlso {
858566
858566
    local FILE="$1"
858566
    local NODE="$2"
858566
    local NODECOMP=''
858566
    local NODECOMPS_TOTAL=''
858566
    local -a NODECOMPS
858566
    local SEEALSO_LIST=''
858566
858566
    # Stript out the node information in order to retrive its
858566
    # components individually.
858566
    for NODECOMP in $(echo $NODE);do
858566
        NODECOMPS[((++${#NODECOMPS[*]}))]=$NODECOMP
858566
    done
858566
858566
    # Define how many components does the node have.
858566
    local NODECOMPS_TOTAL=$((${#NODECOMPS[*]}))
858566
858566
    # Define the list content. This list should contain all the parent
858566
    # documentation entries under the same chapter, using the current
858566
    # documentation entry as reference. Assuming no parent directory
858566
    # exist for the current documentation entry, print just one item
858566
    # with three dots as content so as to let the user deside what the
858566
    # most appropriate content for this section would be.
858566
    if [[ $NODECOMPS_TOTAL -gt 2 ]];then
858566
        SEEALSO_LIST=$(\
858566
            until [[ ${NODECOMPS_TOTAL} -eq 2 ]];do
858566
                echo "@item @ref{$NODE" \
858566
                    | cut -d ' ' -f-"$NODECOMPS_TOTAL" \
858566
                    | sed -r -e 's!^[:space:]*!\\n!' -e 's!$!}!';
858566
                NODECOMPS_TOTAL=$(($NODECOMPS_TOTAL - 1))
858566
            done)
858566
    else
6150a1
        SEEALSO_LIST=$(echo '\n@item @dots{}')
858566
    fi
858566
858566
    # Define the list type and merge its content.
858566
    SEEALSO_LIST="$(echo '@itemize'$SEEALSO_LIST'\n@end itemize')"
858566
858566
    # Expand translation marker in the documentation entry.
858566
    sed -i -e "/=TEXINFO_SEEALSO=/c\\$SEEALSO_LIST" $FILE
858566
858566
}