|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
edaa9d |
# texinfo_createChapter.sh -- This function creates manual's chapters
|
|
|
edaa9d |
# based on templates.
|
|
|
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 |
|
|
|
edaa9d |
function texinfo_createChapter {
|
|
|
4c79b5 |
|
|
|
edaa9d |
# Verify chapter's directory inside the manual. The chapter's
|
|
|
edaa9d |
# directory is where chapter-specific information (e.g., manual's
|
|
|
edaa9d |
# sections) are stored in. If this directory already exist,
|
|
|
edaa9d |
# assume it was created correctly in the past. Otherwise, prompt
|
|
|
edaa9d |
# its creation.
|
|
|
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 |
|
|
|
edaa9d |
# Initialize chapter information (e.g., title).
|
|
|
edaa9d |
local MANUAL_CHAPTER_TITLE=''
|
|
|
edaa9d |
|
|
|
edaa9d |
# Retrive manual's information from standard input.
|
|
|
edaa9d |
cli_printMessage "`gettext "Enter chapter's title"`" --as-request-line
|
|
|
edaa9d |
read MANUAL_CHAPTER_TITLE
|
|
|
edaa9d |
|
|
|
edaa9d |
# Print action message.
|
|
|
edaa9d |
cli_printMessage "-" --as-separator-line
|
|
|
edaa9d |
cli_printMessage "`gettext "Creating chapter's files."`" --as-response-line
|
|
|
edaa9d |
|
|
|
edaa9d |
# Define list of template files used to build chapter's 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 |
|
|
|
edaa9d |
# Create chapter's 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 |
|
|
|
edaa9d |
# Create chapter's files using template files as reference.
|
|
|
edaa9d |
for FILE in $FILES;do
|
|
|
4c79b5 |
|
|
|
34f2ab |
# Verify texinfo templates used as based to build the chapter.
|
|
|
34f2ab |
# Be sure they are inside the working copy of CentOS Artwork
|
|
|
34f2ab |
# Repository (-w) and under version control (-n), too.
|
|
|
34f2ab |
cli_checkFiles ${FILE} -wn
|
|
|
34f2ab |
|
|
|
34f2ab |
# Copy template files into chapter's directory.
|
|
|
edaa9d |
svn cp ${FILE} ${MANUAL_CHAPTER_DIR} --quiet
|
|
|
34f2ab |
|
|
|
34f2ab |
done
|
|
|
5285d6 |
|
|
|
edaa9d |
# Expand translation markers inside chapter's main definition
|
|
|
edaa9d |
# file. Before expanding chapter information, be sure the slash
|
|
|
edaa9d |
# (/) character be scaped. Otherwise, if the slashes aren't scape,
|
|
|
edaa9d |
# they will be interpreted as sed's separator and provoke sed to
|
|
|
edaa9d |
# fail.
|
|
|
edaa9d |
sed -i -r \
|
|
|
edaa9d |
-e 's/ \// \\\//g' \
|
|
|
edaa9d |
-e "s/=CHAPTER_NAME=/${MANUAL_CHAPTER_NAME}/" \
|
|
|
edaa9d |
-e "s/=CHAPTER_TITLE=/${MANUAL_CHAPTER_TITLE}/" \
|
|
|
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.
|
|
|
c5c74e |
${FLAG_BACKEND}_updateChapterMenu
|
|
|
9328e8 |
${FLAG_BACKEND}_updateChapterNode
|
|
|
edaa9d |
|
|
|
4c79b5 |
}
|