|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
4de5d4 |
# manual_getEntry.sh -- This function builds a documentation entry based
|
|
|
638bf8 |
# on a location specified. Location specification can be both action
|
|
|
638bf8 |
# value (ACTIONVAL) variable or a value passed as first positional
|
|
|
638bf8 |
# parameter.
|
|
|
4c79b5 |
#
|
|
|
9f5f2e |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
4c79b5 |
#
|
|
|
7cd8e9 |
# This program is free software; you can redistribute it and/or
|
|
|
7cd8e9 |
# modify it under the terms of the GNU General Public License as
|
|
|
7cd8e9 |
# published by the Free Software Foundation; either version 2 of the
|
|
|
7cd8e9 |
# License, or (at your option) any later version.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# This program is distributed in the hope that it will be useful, but
|
|
|
4c79b5 |
# 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
|
|
|
4c79b5 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
4c79b5 |
# USA.
|
|
|
4c79b5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
4de5d4 |
function manual_getEntry {
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Define variables as local to avoid conflicts outside.
|
|
|
4c79b5 |
local DIR=''
|
|
|
4c79b5 |
local FILE=''
|
|
|
4c79b5 |
local ENTRY=''
|
|
|
638bf8 |
local LOCATION=''
|
|
|
638bf8 |
|
|
|
638bf8 |
# Redefine location in order to make this function reusable not
|
|
|
638bf8 |
# just for action value variable but whatever value passed as
|
|
|
638bf8 |
# first possitional argument.
|
|
|
638bf8 |
if [[ "$1" != '' ]];then
|
|
|
638bf8 |
LOCATION="$1"
|
|
|
638bf8 |
else
|
|
|
638bf8 |
LOCATION="$ACTIONVAL"
|
|
|
638bf8 |
fi
|
|
|
4c79b5 |
|
|
|
be7b87 |
# Build directory to store documenation entry.
|
|
|
638bf8 |
DIR=$(echo $LOCATION | sed -r 's!^/home/centos/artwork/!!')
|
|
|
be7b87 |
DIR=$(dirname "$DIR")
|
|
|
4c79b5 |
DIR=${MANUALS_DIR[2]}/$DIR
|
|
|
4c79b5 |
|
|
|
be7b87 |
# Build file for documentation entry. Notice that directory
|
|
|
be7b87 |
# structure convenction is not used here through cli_getRepoName.
|
|
|
be7b87 |
# This is because documentation structures mirror other directory
|
|
|
be7b87 |
# structures inside the repository. So, if we are documenting
|
|
|
be7b87 |
# trunk/Identity/Brands/ directory we don't want to have the
|
|
|
be7b87 |
# trunk/Identity/brands.texi documentation entry, but
|
|
|
be7b87 |
# trunk/Identity/Brands.texi in order to reflect the fact that we
|
|
|
be7b87 |
# are documenting a directory structure. Something similar occurs
|
|
|
be7b87 |
# with files, but using repository file convenction instead. This
|
|
|
be7b87 |
# way we just use basename to find out the last component in the
|
|
|
be7b87 |
# path without sanitation. We assume it has been already
|
|
|
be7b87 |
# sanitated.
|
|
|
be7b87 |
FILE=$(basename "$LOCATION").texi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Combine both directory (DIR) and file (FILE) to build entry's
|
|
|
4c79b5 |
# absolute path. When the entry's absolute path is built for the
|
|
|
be7b87 |
# current location, the string "." is returned by cli_getRepoName
|
|
|
be7b87 |
# and used as current directory to store the .texi file. This is
|
|
|
be7b87 |
# not desirable because we are using absolute path already and the
|
|
|
be7b87 |
# "." string adds another level in the path (e.g.,
|
|
|
4c79b5 |
# /home/centos/artwork/trunk/Manuals/Texinfo/en/./trunk/chapter.texi).
|
|
|
4c79b5 |
# This extra level in the path confuses the script when it tries
|
|
|
4c79b5 |
# to find out where the chapter's directory is. In the example
|
|
|
4c79b5 |
# above, the chapter's directory is "trunk/" not "./". So, remove
|
|
|
4c79b5 |
# the string './' from entry's absolute path in order to build the
|
|
|
4c79b5 |
# entry's absolute path correctly.
|
|
|
4c79b5 |
ENTRY=$(echo $DIR/$FILE | sed -r 's!\./!!')
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Re-define documentation entry if it is the chapter entry.
|
|
|
4c79b5 |
# TODO: automate the verification, in order to accept any other
|
|
|
4c79b5 |
# structure in the first level.
|
|
|
4c79b5 |
if [[ $ENTRY =~ "(trunk|branches|tags)\.texi$" ]];then
|
|
|
4c79b5 |
ENTRY=$(echo $ENTRY \
|
|
|
4c79b5 |
| sed -r "s/(trunk|branches|tags)\.texi$/\1\/${MANUALS_FILE[7]}/")
|
|
|
4c79b5 |
fi
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Output entry's absolute path.
|
|
|
4c79b5 |
echo $ENTRY
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|