|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
4e0284 |
# texinfo_updateSectionNodes.sh -- This function updates section's
|
|
|
4e0284 |
# nodes definition files using section's menu definition file both
|
|
|
4e0284 |
# inside the same chapter.
|
|
|
4c79b5 |
#
|
|
|
3b0984 |
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
dcd347 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
dcd347 |
# your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# 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
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
4e0284 |
function texinfo_updateSectionNodes {
|
|
|
4c79b5 |
|
|
|
edaa9d |
# Build list of chapter nodes using entries from chapter menu as
|
|
|
edaa9d |
# reference.
|
|
|
9fa13b |
local NODES=$(cat $MANUAL_CHAPTER_DIR/chapter-menu.${MANUAL_EXTENSION} \
|
|
|
4c79b5 |
| sed -r 's!^\* !!' | sed -r 's!:{1,2}.*$!!g' \
|
|
|
edaa9d |
| egrep -v '^@(end )?menu$' | sed -r 's! !:!g')
|
|
|
4c79b5 |
|
|
|
edaa9d |
# Build chapter nodes based on chapter menu.
|
|
|
4c79b5 |
for NODE in $NODES;do
|
|
|
4c79b5 |
|
|
|
fa17ed |
NODE=$(echo "${NODE}" | sed -r 's!:! !g')
|
|
|
edaa9d |
INCL=$(echo "${NODE}" | sed -r 's! !/!' | sed -r 's! !-!g' | sed -r 's!/(.+)!/\L\1!').${MANUAL_EXTENSION}
|
|
|
edaa9d |
SECT=$(echo "${NODE}" | cut -d' ' -f2- )
|
|
|
edaa9d |
CIND=$(echo "${SECT}" | sed -r 's!^([[:alpha:]]+) (.+)!\u\1 \L\2!')
|
|
|
4c79b5 |
|
|
|
7d58ac |
# Create texinfo section file using templates, only if the
|
|
|
7d58ac |
# section file doesn't exist and hasn't been marked for
|
|
|
7d58ac |
# deletion. Otherwise, when the files have been marked for
|
|
|
7d58ac |
# deletion, they will be created again from texinfo template
|
|
|
7d58ac |
# to working copy and that might create confusion.
|
|
|
5e989a |
if [[ ! -f ${MANUAL_BASEDIR_L10N}/$INCL ]] \
|
|
|
5e989a |
&& [[ $(cli_getRepoStatus ${MANUAL_BASEDIR_L10N}/$INCL) != 'D' ]];then
|
|
|
858566 |
|
|
|
edaa9d |
# Define absolute path to template assignment file. This
|
|
|
edaa9d |
# is the file that controls the way texinfo template files
|
|
|
edaa9d |
# are applied to documentation entries once they have been
|
|
|
edaa9d |
# created.
|
|
|
edaa9d |
local CONFFILE="${MANUAL_TEMPLATE}/manual.conf"
|
|
|
0f80c1 |
|
|
|
0f80c1 |
# Verify existence of configuration file.
|
|
|
0f80c1 |
cli_checkFiles $CONFFILE
|
|
|
0f80c1 |
|
|
|
0f80c1 |
# Retrive configuration lines from configuration file. Be
|
|
|
0f80c1 |
# sure no line begining with `#' or space remain in the
|
|
|
0f80c1 |
# line. Otherwise, it would be difficult to loop through
|
|
|
0f80c1 |
# configuration lines.
|
|
|
0f80c1 |
local CONFLINE=''
|
|
|
0f80c1 |
local CONFLINES=$(cat ${CONFFILE} \
|
|
|
108ddd |
| egrep -v '^#' \
|
|
|
0f80c1 |
| egrep -v '^[[:space:]]*$' \
|
|
|
0f80c1 |
| sed -r 's![[:space:]]*!!g')
|
|
|
0f80c1 |
|
|
|
0f80c1 |
# Initialize both left hand side and right hand side
|
|
|
0f80c1 |
# configuration values.
|
|
|
0f80c1 |
local CONFLHS=''
|
|
|
0f80c1 |
local CONFRHS=''
|
|
|
0f80c1 |
|
|
|
0f80c1 |
# Initialize absolute path to final texinfo template.
|
|
|
0f80c1 |
local TEMPLATE=''
|
|
|
0f80c1 |
|
|
|
0f80c1 |
# Define what section template to apply using
|
|
|
0f80c1 |
# documentation entry absolute path and values provided by
|
|
|
0f80c1 |
# configuration line. Be sure to break the loop in the
|
|
|
0f80c1 |
# first match.
|
|
|
0f80c1 |
for CONFLINE in $CONFLINES;do
|
|
|
0f80c1 |
|
|
|
0f80c1 |
CONFLHS=$(echo $CONFLINE \
|
|
|
edaa9d |
| gawk 'BEGIN{FS="="}; { print $1 }' \
|
|
|
0f80c1 |
| sed -r 's![[:space:]]*!!g')
|
|
|
858566 |
|
|
|
0f80c1 |
CONFRHS=$(echo $CONFLINE \
|
|
|
edaa9d |
| gawk 'BEGIN{FS="="}; { print $2 }' \
|
|
|
0f80c1 |
| sed -r 's![[:space:]]*!!g' | sed -r 's!^"(.+)"$!\1!')
|
|
|
7d58ac |
|
|
|
5e989a |
if [[ ${MANUAL_BASEDIR_L10N}/${INCL} =~ $CONFRHS ]];then
|
|
|
6150a1 |
TEMPLATE="${MANUAL_TEMPLATE_L10N}/${CONFLHS}"
|
|
|
0f80c1 |
break
|
|
|
0f80c1 |
fi
|
|
|
858566 |
|
|
|
0f80c1 |
done
|
|
|
0f80c1 |
|
|
|
0f80c1 |
# Verify existence of texinfo template file. If no
|
|
|
0f80c1 |
# template is found, stop script execution with an error
|
|
|
0f80c1 |
# message. We cannot continue without it.
|
|
|
0f80c1 |
cli_checkFiles $TEMPLATE
|
|
|
0f80c1 |
|
|
|
0f80c1 |
# Create documentation entry using texinfo template as
|
|
|
0f80c1 |
# reference.
|
|
|
5e989a |
svn cp ${TEMPLATE} ${MANUAL_BASEDIR_L10N}/$INCL --quiet
|
|
|
0f80c1 |
|
|
|
4c79b5 |
fi
|
|
|
0f80c1 |
|
|
|
edaa9d |
# Expand common translation markers in documentation entry.
|
|
|
5e989a |
cli_expandTMarkers "${MANUAL_BASEDIR_L10N}/$INCL"
|
|
|
edaa9d |
|
|
|
edaa9d |
# Replace node, section and concept index definitions already
|
|
|
edaa9d |
# defined with node, section and concept index translation
|
|
|
edaa9d |
# markers. Otherwise, incorrect sectioning may happen.
|
|
|
edaa9d |
sed -i -r \
|
|
|
edaa9d |
-e '/@node/c@node =NODE=' \
|
|
|
edaa9d |
-e '/@section/c@section =SECT=' \
|
|
|
edaa9d |
-e '/@cindex/c@cindex =CIND=' \
|
|
|
5e989a |
"${MANUAL_BASEDIR_L10N}/$INCL"
|
|
|
edaa9d |
|
|
|
edaa9d |
# Expand noce, section and concept index translation
|
|
|
edaa9d |
# markers in documentation entry.
|
|
|
edaa9d |
sed -i -r \
|
|
|
edaa9d |
-e "s!=NODE=!${NODE}!g" \
|
|
|
edaa9d |
-e "s!=SECT=!${SECT}!g" \
|
|
|
edaa9d |
-e "s!=CIND=!${CIND}!g" \
|
|
|
5e989a |
"${MANUAL_BASEDIR_L10N}/$INCL"
|
|
|
edaa9d |
|
|
|
0f80c1 |
# Verify existence of chapter-nodes template files. If no
|
|
|
0f80c1 |
# chapter-nodes template is found, stop script execution with
|
|
|
0f80c1 |
# an error message. We cannot continue without it.
|
|
|
edaa9d |
cli_checkFiles ${MANUAL_TEMPLATE_L10N}/Chapters/chapter-nodes.${MANUAL_EXTENSION}
|
|
|
0f80c1 |
|
|
|
0f80c1 |
# Output node information chapter-nodes template file using
|
|
|
0f80c1 |
# the current texinfo menu information.
|
|
|
edaa9d |
cat ${MANUAL_TEMPLATE_L10N}/Chapters/chapter-nodes.${MANUAL_EXTENSION} \
|
|
|
edaa9d |
| sed -r "s!=INCL=!${INCL}!g"
|
|
|
0f80c1 |
|
|
|
0f80c1 |
# Dump node definitions into document structure.
|
|
|
9fa13b |
done > $MANUAL_CHAPTER_DIR/chapter-nodes.${MANUAL_EXTENSION}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|