|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
d286ed |
# texinfo_createChapter.sh -- This function standardizes chapter
|
|
|
d286ed |
# creation insdie the manual structure.
|
|
|
4c79b5 |
#
|
|
|
2fe9b7 |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
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 |
|
|
|
edaa9d |
function texinfo_createChapter {
|
|
|
4c79b5 |
|
|
|
d286ed |
# Verify chapter directory inside the manual structure. The
|
|
|
d286ed |
# chapter directory is where chapter-specific information (e.g.,
|
|
|
d286ed |
# chapter definition files and sections) are stored in. If this
|
|
|
d286ed |
# directory already exist, assume it was created correctly in the
|
|
|
d286ed |
# past. Otherwise, request confirmation for creating it.
|
|
|
edaa9d |
if [[ -d $MANUAL_CHAPTER_DIR ]];then
|
|
|
edaa9d |
return
|
|
|
edaa9d |
else
|
|
|
edaa9d |
cli_printMessage "`gettext "The following documentation chapter will be created:"`"
|
|
|
edaa9d |
cli_printMessage "${MANUAL_CHAPTER_DIR}" --as-response-line
|
|
|
edaa9d |
cli_printMessage "`gettext "Do you want to continue?"`" --as-yesornorequest-line
|
|
|
edaa9d |
fi
|
|
|
4c79b5 |
|
|
|
d286ed |
# Initialize chapter node, chapter index and chapter title.
|
|
|
7e33b8 |
local MANUAL_CHAPTER_NODE=''
|
|
|
edaa9d |
local MANUAL_CHAPTER_TITLE=''
|
|
|
7e33b8 |
local MANUAL_CHAPTER_CIND=''
|
|
|
edaa9d |
|
|
|
d286ed |
# Request the user to enter a chapter title.
|
|
|
7e33b8 |
cli_printMessage "`gettext "Chapter Title"`" --as-request-line
|
|
|
edaa9d |
read MANUAL_CHAPTER_TITLE
|
|
|
edaa9d |
|
|
|
d286ed |
# Sanitate chapter node, chapter index and chapter title.
|
|
|
0ca0ad |
MANUAL_CHAPTER_NODE=$(${MANUAL_BACKEND}_getEntryNode "$MANUAL_CHAPTER_NAME")
|
|
|
0ca0ad |
MANUAL_CHAPTER_CIND=$(${MANUAL_BACKEND}_getEntryIndex "$MANUAL_CHAPTER_TITLE")
|
|
|
0ca0ad |
MANUAL_CHAPTER_TITLE=$(${MANUAL_BACKEND}_getEntryTitle "$MANUAL_CHAPTER_TITLE")
|
|
|
7e33b8 |
|
|
|
edaa9d |
# Print action message.
|
|
|
edaa9d |
cli_printMessage "-" --as-separator-line
|
|
|
7e33b8 |
cli_printMessage "`gettext "Creating chapter files."`" --as-response-line
|
|
|
edaa9d |
|
|
|
d286ed |
# Define list of template files used to build the chapter main
|
|
|
edaa9d |
# definition files.
|
|
|
34f2ab |
local FILE=''
|
|
|
edaa9d |
local FILES=$(cli_getFilesList "${MANUAL_TEMPLATE_L10N}/Chapters" \
|
|
|
edaa9d |
--maxdepth='1' \
|
|
|
edaa9d |
--pattern="chapter(-menu|-nodes)?\.${MANUAL_EXTENSION}")
|
|
|
4c79b5 |
|
|
|
d286ed |
# Create chapter directory using subversion. This is the place
|
|
|
edaa9d |
# where all chapter-specific files will be stored in.
|
|
|
edaa9d |
if [[ ! -d ${MANUAL_CHAPTER_DIR} ]];then
|
|
|
edaa9d |
svn mkdir ${MANUAL_CHAPTER_DIR} --quiet
|
|
|
edaa9d |
fi
|
|
|
4c79b5 |
|
|
|
d286ed |
# Create chapter-specific files using template files as reference.
|
|
|
edaa9d |
for FILE in $FILES;do
|
|
|
4c79b5 |
|
|
|
d286ed |
# Verify texinfo templates used as based to build the chapter
|
|
|
d286ed |
# structure. Be sure they are inside the working copy of
|
|
|
d286ed |
# The CentOS Artwork Repository (-w) and under version control
|
|
|
d286ed |
# (-n), too.
|
|
|
34f2ab |
cli_checkFiles ${FILE} -wn
|
|
|
34f2ab |
|
|
|
d286ed |
# Copy template files into the chapter directory.
|
|
|
edaa9d |
svn cp ${FILE} ${MANUAL_CHAPTER_DIR} --quiet
|
|
|
34f2ab |
|
|
|
34f2ab |
done
|
|
|
5285d6 |
|
|
|
d286ed |
# Before expanding chapter information, be sure the slash (/)
|
|
|
d286ed |
# character be scaped. Otherwise, if the slashes aren't scape,
|
|
|
d286ed |
# they will be interpreted as sed's separator and might provoke
|
|
|
d286ed |
# sed to complain.
|
|
|
d286ed |
MANUAL_CHAPTER_NODE=$(echo "$MANUAL_CHAPTER_NODE" | sed -r 's/\//\\\//g')
|
|
|
d286ed |
MANUAL_CHAPTER_CIND=$(echo "$MANUAL_CHAPTER_CIND" | sed -r 's/\//\\\//g')
|
|
|
d286ed |
MANUAL_CHAPTER_TITLE=$(echo "$MANUAL_CHAPTER_TITLE" | sed -r 's/\//\\\//g')
|
|
|
d286ed |
MANUAL_CHAPTER_NAME=$(echo "$MANUAL_CHAPTER_NAME" | sed -r 's/\//\\\//g')
|
|
|
d286ed |
|
|
|
d286ed |
# Expand translation markers inside chapter main definition file.
|
|
|
edaa9d |
sed -i -r \
|
|
|
7e33b8 |
-e "s/=CHAPTER_NODE=/${MANUAL_CHAPTER_NODE}/" \
|
|
|
edaa9d |
-e "s/=CHAPTER_TITLE=/${MANUAL_CHAPTER_TITLE}/" \
|
|
|
7e33b8 |
-e "s/=CHAPTER_CIND=/${MANUAL_CHAPTER_CIND}/" \
|
|
|
7e33b8 |
-e "s/=CHAPTER_NAME=/${MANUAL_CHAPTER_NAME}/" \
|
|
|
edaa9d |
${MANUAL_CHAPTER_DIR}/chapter.${MANUAL_EXTENSION}
|
|
|
edaa9d |
|
|
|
edaa9d |
# Remove content from `chapter-nodes.texinfo' file to start with a
|
|
|
edaa9d |
# clean node structure. This file is also used to create new
|
|
|
edaa9d |
# documentation entries, but we don't need that information right
|
|
|
edaa9d |
# now (when the chapter structure is created), just an empty copy
|
|
|
edaa9d |
# of the file. The node structure of chapter is created
|
|
|
edaa9d |
# automatically based on action value.
|
|
|
edaa9d |
echo "" > ${MANUAL_CHAPTER_DIR}/chapter-nodes.${MANUAL_EXTENSION}
|
|
|
edaa9d |
|
|
|
edaa9d |
# Print action maessage.
|
|
|
edaa9d |
cli_printMessage "`gettext "Updating chapter menu and nodes inside manual structure."`" --as-response-line
|
|
|
edaa9d |
|
|
|
edaa9d |
# Update chapter information inside the manual's texinfo
|
|
|
edaa9d |
# structure.
|
|
|
0ca0ad |
${MANUAL_BACKEND}_updateChapterMenu
|
|
|
0ca0ad |
${MANUAL_BACKEND}_updateChapterNodes
|
|
|
edaa9d |
|
|
|
4c79b5 |
}
|