From 2bd980673a32db4d0ff451716cedfe14dd9d7562 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Dec 28 2010 19:15:04 +0000 Subject: Update `manual' functionality: - Add manual_updateTexinfoStructure.sh - Move documentation entry definition from manual.sh to manual_getActions.sh. - Update command-line arguments interpretation inside manual_getActions.sh. --- diff --git a/Scripts/Bash/Functions/Manual/manual.sh b/Scripts/Bash/Functions/Manual/manual.sh index 8778773..4c38fbc 100755 --- a/Scripts/Bash/Functions/Manual/manual.sh +++ b/Scripts/Bash/Functions/Manual/manual.sh @@ -26,7 +26,7 @@ # ---------------------------------------------------------------------- function manual { - + # Define documentation base directory structure. MANUALS_DIR[0]='/home/centos/artwork/trunk/Manuals' MANUALS_DIR[1]=${MANUALS_DIR[0]}/$(cli_getCurrentLocale) @@ -58,26 +58,7 @@ function manual { MANUALS_FILE[10]=${MANUALS_DIR[6]}/repository-chapter-section.texi MANUALS_FILE[11]=${MANUALS_DIR[2]}/repository-chapter-index.texi - # Define documentation entry. - ENTRY=$(manual_getEntry) - - # Define directory used to store chapter's documentation entries. - # At this point, we need to take a desition about - # documentation-design, in order to answer the question: How do we - # assign chapters, sections and subsections automatically, based - # on the repository structure? - # - # One solution would be: to use three chapters only to represent - # the repository's first level structure (i.e., trunk, - # branches, and tags) and handle everything else as sections. Sub - # and subsub section will not have their own files, they will be - # written inside section files instead. - ENTRYCHAPTER=$(echo $ENTRY | cut -d / -f-10) - - # Define chapter name for this documentation entry. - CHAPTERNAME=$(basename $ENTRYCHAPTER) - - # Initialize documentation functions and path patterns. + # Define command-line interface. manual_getActions } diff --git a/Scripts/Bash/Functions/Manual/manual_getActions.sh b/Scripts/Bash/Functions/Manual/manual_getActions.sh index 7c3d4e0..01b8d9b 100755 --- a/Scripts/Bash/Functions/Manual/manual_getActions.sh +++ b/Scripts/Bash/Functions/Manual/manual_getActions.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# manual_getActions.sh -- This function initializes documentation -# functionalities, using action value as reference. +# manual_getActions.sh -- This function interpretes arguments passed +# to `manual' functionality and calls actions accordingly. # # Copyright (C) 2009, 2010 Alain Reguera Delgado # @@ -26,45 +26,151 @@ function manual_getActions { + # Verify language layout. manual_checkLanguageLayout - case $ACTIONNAM in - - --search ) - manual_searchIndex - ;; - - --edit ) - manual_editEntry - ;; + # Define short options we want to support. + local ARGSS="" + + # Define long options we want to support. + local ARGSL="search:,edit:,delete:,update-output,update-structure:,read:" + + # Parse arguments using getopt(1) command parser. + cli_doParseArguments + + # Reset positional parameters using output from (getopt) argument + # parser. + eval set -- "$ARGUMENTS" + + # Define action to take for each option passed. + while true; do + case "$1" in + + --search ) + + # Define action value passed through the command-line. + ACTIONVAL="$2" + + # Check action value passed through the command-line + # using source directory definition as reference. + cli_checkRepoDirSource + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_searchIndex" + + # Break options loop. + break + ;; - --remove ) - manual_removeEntry - ;; + --edit ) + + # Define action value passed through the command-line. + ACTIONVAL="$2" + + # Check action value passed through the command-line + # using source directory definition as reference. + cli_checkRepoDirSource + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_editEntry" + + # Break options loop. + break + ;; - --update ) - manual_updateOutputFiles - ;; + --delete ) + + # Define action value passed through the command-line. + ACTIONVAL="$2" + + # Check action value passed through the command-line + # using source directory definition as reference. + cli_checkRepoDirSource + + # Define action name. + ACTIONNAM="${FUNCNAM}_removeEntry" + + # Break options loop. + break + ;; - --update-structure ) - # This option is mainly used from path functionality, - # specifically when documentation entries are copied, removed, - # or renamed. We want to keep documentation structure - # syncronized with such changes. - manual_updateMenu - manual_updateNodes - manual_restoreCrossReferences - ;; - - --read ) - manual_searchNode - ;; - - * ) - cli_printMessage "`gettext "The option provided is not valid."`" - cli_printMessage "$(caller)" "AsToKnowMoreLine" - ;; + --update-output ) + + # Execute action name. There is no need of action + # value here, so let's execute the action right now. + manual_updateOutputFiles + + # Break options loop. + break + ;; - esac + --update-structure ) + + # Define action value passed through the command-line. + ACTIONVAL="$2" + + # Check action value passed through the command-line + # using source directory definition as reference. + cli_checkRepoDirSource + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_updateTexinfoStructure" + + # Break options loop. + break + ;; + + --read ) + + # Define action value passed through the command-line. + ACTIONVAL="$2" + + # Check action value passed through the command-line + # using source directory definition as reference. + cli_checkRepoDirSource + + # Define action name using action value as reference. + ACTIONNAM="${FUNCNAM}_searchNode" + + # Break options loop. + break + ;; + + * ) + break + esac + done + + # Verify action value variable. + if [[ $ACTIONVAL == '' ]];then + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Define documentation entry. + ENTRY=$(manual_getEntry) + + # Define directory used to store chapter's documentation entries. + # At this point, we need to take a desition about + # documentation-design, in order to answer the question: How do we + # assign chapters, sections and subsections automatically, based + # on the repository structure? + # + # One solution would be: to use three chapters only to represent + # the repository's first level structure (i.e., trunk, + # branches, and tags) and handle everything else as sections. Sub + # and subsub section will not have their own files, they will be + # written inside section files instead. + ENTRYCHAPTER=$(echo $ENTRY | cut -d / -f-10) + + # Define chapter name for this documentation entry. + CHAPTERNAME=$(basename $ENTRYCHAPTER) + + # Execute action name. + if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then + eval $ACTIONNAM + else + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi } diff --git a/Scripts/Bash/Functions/Manual/manual_updateTexinfoStructure.sh b/Scripts/Bash/Functions/Manual/manual_updateTexinfoStructure.sh new file mode 100755 index 0000000..0a78600 --- /dev/null +++ b/Scripts/Bash/Functions/Manual/manual_updateTexinfoStructure.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# +# manual_updateTexinfoStructure.sh -- This function updates texinfo +# documentation structure based on a documentation entry. This +# function is useful to keep documentation structure syncronized with +# repository directory structure. +# +# Copyright (C) 2009, 2010 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function manual_updateTexinfoStructure { + + # Update Texinfo menu information. + manual_updateMenu + + # Update Texinfo nodes information. + manual_updateNodes + + # Update Texinfo cross-reference information. + manual_restoreCrossReferences + + # Update Texinfo output. + manual_updateOutputFiles + +}