|
|
878a2b |
#!/bin/bash
|
|
|
878a2b |
#
|
|
|
878a2b |
# texinfo_updateSectionNodes.sh -- This function updates section's
|
|
|
878a2b |
# nodes definition files using section's menu definition file both
|
|
|
878a2b |
# inside the same chapter.
|
|
|
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_updateSectionNodes {
|
|
|
878a2b |
|
|
|
878a2b |
# Build list of chapter nodes using entries from chapter menu as
|
|
|
878a2b |
# reference.
|
|
|
878a2b |
local NODES=$(cat $(dirname ${MANUAL_ENTRY})/chapter-menu.${MANUAL_EXTENSION} \
|
|
|
878a2b |
| sed -r 's!^\* !!' | sed -r 's!:{1,2}.*$!!g' \
|
|
|
878a2b |
| egrep -v '^@(end )?menu$' | sed -r 's! !:!g')
|
|
|
878a2b |
|
|
|
878a2b |
# Build chapter nodes based on chapter menu.
|
|
|
878a2b |
for NODE in $NODES;do
|
|
|
878a2b |
|
|
|
878a2b |
local NODE=$(echo "${NODE}" | sed -r 's!:! !g')
|
|
|
eb679a |
local INCL=$(echo "${NODE}" | sed -r -e 's! !/!' -e 's! !-!g' -e's!/(.+)!/\L\1!').${MANUAL_EXTENSION}
|
|
|
878a2b |
local SECT=$(texinfo_getEntryTitle "$NODE")
|
|
|
878a2b |
local CIND=$(texinfo_getEntryIndex "$NODE")
|
|
|
878a2b |
|
|
|
878a2b |
# Create texinfo section file using templates, only if the
|
|
|
878a2b |
# section file doesn't exist and hasn't been marked for
|
|
|
878a2b |
# deletion. Otherwise, when the files have been marked for
|
|
|
878a2b |
# deletion, they will be created again from texinfo template
|
|
|
878a2b |
# to working copy and that might create confusion.
|
|
|
878a2b |
if [[ ! -f ${MANUAL_BASEDIR_L10N}/$INCL ]] \
|
|
|
dc21ee |
&& [[ $(${CLI_NAME} svn --get-status ${MANUAL_BASEDIR_L10N}/$INCL) != 'D' ]];then
|
|
|
878a2b |
|
|
|
878a2b |
# Retrive configuration lines from configuration file. Be
|
|
|
878a2b |
# sure no line begining with `#' or space remain in the
|
|
|
878a2b |
# line. Otherwise, it would be difficult to loop through
|
|
|
878a2b |
# configuration lines.
|
|
|
878a2b |
local CONFLINE=''
|
|
|
878a2b |
local CONFLINES=$(cli_getConfigLines "${MANUAL_CONFIG_FILE}" "templates")
|
|
|
878a2b |
|
|
|
878a2b |
# Initialize both left hand side and right hand side
|
|
|
878a2b |
# configuration values.
|
|
|
878a2b |
local CONFLHS=''
|
|
|
878a2b |
local CONFRHS=''
|
|
|
878a2b |
|
|
|
878a2b |
# Initialize absolute path to final texinfo template.
|
|
|
878a2b |
local TEMPLATE=''
|
|
|
878a2b |
|
|
|
878a2b |
# Define what section template to apply using
|
|
|
878a2b |
# documentation entry absolute path and values provided by
|
|
|
878a2b |
# configuration line. Be sure to break the loop in the
|
|
|
878a2b |
# first match.
|
|
|
878a2b |
for CONFLINE in $CONFLINES;do
|
|
|
878a2b |
|
|
|
878a2b |
CONFLHS=$(echo $CONFLINE \
|
|
|
878a2b |
| gawk 'BEGIN{FS="="}; { print $1 }' \
|
|
|
878a2b |
| sed -r 's![[:space:]]*!!g')
|
|
|
878a2b |
|
|
|
878a2b |
CONFRHS=$(echo $CONFLINE \
|
|
|
878a2b |
| gawk 'BEGIN{FS="="}; { print $2 }' \
|
|
|
47dbe5 |
| sed -r -e 's![[:space:]]*!!g' -e 's!^"(.+)"$!\1!')
|
|
|
878a2b |
|
|
|
878a2b |
if [[ ${MANUAL_BASEDIR_L10N}/${INCL} =~ $CONFRHS ]];then
|
|
|
878a2b |
TEMPLATE="${MANUAL_TEMPLATE_L10N}/${CONFLHS}"
|
|
|
878a2b |
break
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
# Verify existence of texinfo template file. If no
|
|
|
878a2b |
# template is found, stop script execution with an error
|
|
|
878a2b |
# message. We cannot continue without it.
|
|
|
b006ad |
cli_checkFiles -e $TEMPLATE
|
|
|
878a2b |
|
|
|
878a2b |
# Create documentation entry using texinfo template as
|
|
|
878a2b |
# reference.
|
|
|
04e60f |
${CLI_NAME} svn --copy ${TEMPLATE} ${MANUAL_BASEDIR_L10N}/$INCL
|
|
|
878a2b |
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
# Expand common translation markers in documentation entry.
|
|
|
878a2b |
cli_expandTMarkers "${MANUAL_BASEDIR_L10N}/$INCL"
|
|
|
878a2b |
|
|
|
878a2b |
# Replace node, section and concept index definitions already
|
|
|
878a2b |
# defined with node, section and concept index translation
|
|
|
878a2b |
# markers. Otherwise, incorrect sectioning may happen. Take
|
|
|
878a2b |
# care with index definitions, more than one index definition
|
|
|
878a2b |
# might be found in the section file but only the first
|
|
|
878a2b |
# concept index entry (i.e., `cindex') will be updated, the
|
|
|
878a2b |
# rest will remain as they are.
|
|
|
878a2b |
sed -i -r \
|
|
|
878a2b |
-e '/^@node/c@node =NODE=' \
|
|
|
878a2b |
-e '/^@section/c@section =SECT=' \
|
|
|
878a2b |
-e '0,/^@cindex/c@cindex =CIND=' \
|
|
|
878a2b |
"${MANUAL_BASEDIR_L10N}/$INCL"
|
|
|
878a2b |
|
|
|
878a2b |
# Before expading node, section and concept index, be sure
|
|
|
878a2b |
# that all slash characters (`/') be escaped. Otherwise, they
|
|
|
878a2b |
# might be interpreted as separators and that isn't
|
|
|
878a2b |
# desireable in anyway.
|
|
|
878a2b |
NODE=$(echo "$NODE" | sed -r 's/\//\\\//g')
|
|
|
878a2b |
SECT=$(echo "$SECT" | sed -r 's/\//\\\//g')
|
|
|
878a2b |
CIND=$(echo "$CIND" | sed -r 's/\//\\\//g')
|
|
|
878a2b |
|
|
|
878a2b |
# Expand node, section and concept index translation
|
|
|
878a2b |
# markers in documentation entry.
|
|
|
878a2b |
sed -i -r \
|
|
|
878a2b |
-e "s/=NODE=/${NODE}/g" \
|
|
|
878a2b |
-e "s/=SECT=/${SECT}/g" \
|
|
|
878a2b |
-e "s/=CIND=/${CIND}/g" \
|
|
|
878a2b |
"${MANUAL_BASEDIR_L10N}/$INCL"
|
|
|
878a2b |
|
|
|
878a2b |
# Verify existence of chapter-nodes template file. If no
|
|
|
878a2b |
# chapter-nodes template is found, stop script execution with
|
|
|
878a2b |
# an error message. We cannot continue without it.
|
|
|
b006ad |
cli_checkFiles -e ${MANUAL_TEMPLATE_L10N}/Chapters/chapter-nodes.${MANUAL_EXTENSION}
|
|
|
878a2b |
|
|
|
878a2b |
# Expand chapter node inclusion definition.
|
|
|
878a2b |
cat ${MANUAL_TEMPLATE_L10N}/Chapters/chapter-nodes.${MANUAL_EXTENSION} \
|
|
|
878a2b |
| sed -r "s!=INCL=!${INCL}!g"
|
|
|
878a2b |
|
|
|
878a2b |
# Dump chapter node definition into manual structure.
|
|
|
878a2b |
done > $(dirname ${MANUAL_ENTRY})/chapter-nodes.${MANUAL_EXTENSION}
|
|
|
878a2b |
|
|
|
878a2b |
}
|