|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
02d6e2 |
# help.sh -- This function standardizes the way documentation is
|
|
|
06d8c8 |
# produced and maintained inside the working copy of CentOS Artwork
|
|
|
02d6e2 |
# Repository.
|
|
|
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 |
|
|
|
0211a4 |
function help {
|
|
|
2bd980 |
|
|
|
c145a8 |
local ACTIONNAM=''
|
|
|
c145a8 |
local ACTIONVAL=''
|
|
|
c145a8 |
|
|
|
1b527b |
# Initialize the search option. The search option (`--search')
|
|
|
1b527b |
# specifies the pattern used inside info files when an index
|
|
|
1b527b |
# search is perform.
|
|
|
1b527b |
FLAG_SEARCH=""
|
|
|
1b527b |
|
|
|
fa1906 |
# Initialize the backend option. The backend option (`--backend')
|
|
|
fa1906 |
# specifies the backend used to manipulate the repository
|
|
|
deaa54 |
# documentation manual.
|
|
|
9de1b5 |
FLAG_BACKEND="texinfo"
|
|
|
5285d6 |
|
|
|
e5750b |
# Interpret option arguments passed through the command-line.
|
|
|
e5750b |
${FUNCNAM}_getOptions
|
|
|
e5750b |
|
|
|
420e77 |
# Define manual backend directory. This is the place where all
|
|
|
420e77 |
# language specific documentation manuals, for the same backend
|
|
|
420e77 |
# documentation system, are stored in.
|
|
|
420e77 |
MANUAL_BACKEND=$(cli_getRepoTLDir)/Manuals/$(cli_getRepoName ${FLAG_BACKEND} -d)
|
|
|
420e77 |
|
|
|
420e77 |
# Define manual base directory. This is the place where
|
|
|
420e77 |
# language-specific documentation manual is stored in.
|
|
|
420e77 |
MANUAL_BASEDIR="${MANUAL_BACKEND}/$(cli_getCurrentLocale)"
|
|
|
e5750b |
|
|
|
3ae895 |
# Define file name (without extension) for documentation manual.
|
|
|
420e77 |
MANUAL_NAME=$(cli_getRepoName "repository" -f)
|
|
|
1f6dd8 |
|
|
|
e5750b |
# Define base name for documentation manual files (without
|
|
|
e5750b |
# extension). This is the main file name used to build output
|
|
|
e5750b |
# related files (.info, .pdf, .xml, etc.).
|
|
|
e5750b |
MANUAL_BASEFILE="${MANUAL_BASEDIR}/${MANUAL_NAME}"
|
|
|
c145a8 |
|
|
|
420e77 |
# Define chapter name of directory where repository documentation
|
|
|
420e77 |
# entries will be stored in.
|
|
|
420e77 |
MANUAL_CHAPTER_NAME=$(cli_getRepoName "Directories" -d)
|
|
|
420e77 |
|
|
|
420e77 |
# Define absolute path to chapter directory where repository
|
|
|
420e77 |
# documentation entries will be stored in. At this point, we need
|
|
|
420e77 |
# to take a desition about documentation design, in order to
|
|
|
420e77 |
# answer the question: How do we assign chapters, sections and
|
|
|
420e77 |
# subsections automatically, based on the repository structure?
|
|
|
420e77 |
# and also, how such design could be adapted to changes in the
|
|
|
420e77 |
# repository structure?
|
|
|
420e77 |
#
|
|
|
420e77 |
# One solution would be: represent the repository's directory
|
|
|
420e77 |
# structure as sections inside a chapter named `Directories' or
|
|
|
420e77 |
# something similar. Subsections and subsubsections will not have
|
|
|
420e77 |
# their own files, they all will be written inside the same
|
|
|
420e77 |
# section file that represents the repository documentation entry.
|
|
|
420e77 |
MANUAL_CHAPTER_DIR=${MANUAL_BASEDIR}/${MANUAL_CHAPTER_NAME}
|
|
|
420e77 |
|
|
|
420e77 |
# Define absolute path to backend template files.
|
|
|
420e77 |
MANUAL_TEMPLATE=${FUNCDIR}/${FUNCDIRNAM}/Templates/$(cli_getCurrentLocale)
|
|
|
420e77 |
|
|
|
420e77 |
# Verify absolute path to backend template files. If the absolute
|
|
|
420e77 |
# path doesn't exist, use the English language templates.
|
|
|
420e77 |
if [[ ! -d $MANUAL_TEMPLATE ]];then
|
|
|
420e77 |
MANUAL_TEMPLATE=${FUNCDIR}/${FUNCDIRNAM}/Templates/en_US
|
|
|
420e77 |
fi
|
|
|
116f45 |
|
|
|
c145a8 |
# Redefine positional parameters using ARGUMENTS. At this point,
|
|
|
c145a8 |
# option arguments have been removed from ARGUMENTS variable and
|
|
|
c145a8 |
# only non-option arguments remain in it.
|
|
|
c145a8 |
eval set -- "$ARGUMENTS"
|
|
|
e5750b |
|
|
|
e5750b |
# Verify and initialize backend functions. There is no need to
|
|
|
e5750b |
# load all backend-specific functions when we can use just one
|
|
|
e5750b |
# backend among many. Keep the cli_getFunctions function calling
|
|
|
e5750b |
# after all variables and arguments definitions.
|
|
|
e5750b |
if [[ ${FLAG_BACKEND} =~ '^texinfo$' ]];then
|
|
|
e5750b |
cli_getFunctions "${FUNCDIR}/${FUNCDIRNAM}" 'texinfo'
|
|
|
e5750b |
elif [[ ${FLAG_BACKEND} =~ '^docbook$' ]];then
|
|
|
e5750b |
cli_getFunctions "${FUNCDIR}/${FUNCDIRNAM}" 'docbook'
|
|
|
e5750b |
else
|
|
|
e5750b |
cli_printMessage "`gettext "The backend provided is not supported."`" --as-error-line
|
|
|
e5750b |
fi
|
|
|
c145a8 |
|
|
|
420e77 |
# Create documentation structure, if it doesn't exist.
|
|
|
420e77 |
${FLAG_BACKEND}_createStructure
|
|
|
420e77 |
|
|
|
420e77 |
# Syncronize changes between repository and working copy. At this
|
|
|
420e77 |
# point, changes in the repository are merged in the working copy
|
|
|
420e77 |
# and changes in the working copy committed up to repository.
|
|
|
420e77 |
cli_syncroRepoChanges ${MANUAL_CHAPTER_DIR}
|
|
|
420e77 |
|
|
|
e5750b |
# Execute backend functionalities. Notice that there are
|
|
|
e5750b |
# functionalities that need more than one action value in order to
|
|
|
b45dde |
# be executed (e.g., copying, and renaming), functionalities
|
|
|
e5750b |
# that need just one action value to be executed (e.g.,
|
|
|
b45dde |
# documentation reading and edition) and functionalities that
|
|
|
40e4a4 |
# don't need action value at all (e.g., searching, reading and
|
|
|
40e4a4 |
# updating output files). This way, the execution of backend
|
|
|
b45dde |
# functionalities is splitted here.
|
|
|
e5750b |
if [[ $ACTIONNAM =~ "${FLAG_BACKEND}_(copy|rename|delete)Entry" ]];then
|
|
|
5ec287 |
|
|
|
e5750b |
# Execute backend action names that may need to use more than
|
|
|
e5750b |
# one action value.
|
|
|
b45dde |
${ACTIONNAM} $@
|
|
|
b45dde |
|
|
|
40e4a4 |
elif [[ $ACTIONNAM =~ "${FLAG_BACKEND}_(search(Index|Node)|updateOutputFiles)" ]];then
|
|
|
b45dde |
|
|
|
40e4a4 |
# Execute backend action names that might not need any action
|
|
|
40e4a4 |
# value as reference to do their work.
|
|
|
40e4a4 |
$ACTIONNAM $@
|
|
|
b45dde |
|
|
|
b45dde |
# Backend action names that don't need to use any action value
|
|
|
b45dde |
# as reference to do their work are of one-pass only. They are
|
|
|
b45dde |
# executed and then the script execution is finished.
|
|
|
b45dde |
exit
|
|
|
5ec287 |
|
|
|
5ec287 |
else
|
|
|
5ec287 |
|
|
|
e5750b |
# Execute backend action names that use one action value, only.
|
|
|
b45dde |
for ACTIONVAL in $@;do
|
|
|
b45dde |
|
|
|
b45dde |
# Define documentation entry.
|
|
|
40e4a4 |
MANUAL_ENTRY=$(${FLAG_BACKEND}_getEntry $ACTIONVAL)
|
|
|
b45dde |
|
|
|
b45dde |
# Execute backend action names that may need to use more
|
|
|
b45dde |
# than one action value.
|
|
|
b45dde |
$ACTIONNAM
|
|
|
b45dde |
|
|
|
e5750b |
done
|
|
|
5ec287 |
|
|
|
f11f54 |
fi
|
|
|
f11f54 |
|
|
|
420e77 |
# Commit changes from working copy to central repository only. At
|
|
|
420e77 |
# this point, changes in the repository are not merged in the
|
|
|
420e77 |
# working copy, but chages in the working copy do are committed up
|
|
|
420e77 |
# to repository.
|
|
|
420e77 |
cli_commitRepoChanges ${MANUAL_CHAPTER_DIR}
|
|
|
420e77 |
|
|
|
b45dde |
# Rebuild output files to propagate recent changes.
|
|
|
b45dde |
${FLAG_BACKEND}_updateOutputFiles
|
|
|
b45dde |
|
|
|
4c79b5 |
}
|