From 1150944fbe616b9a649a0ec1ea93d66313641f31 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Jul 20 2011 02:40:24 +0000 Subject: Update `texinfo' documentation backend inside `help' functionality: help.sh - Start using MANUAL_CHANGED_DIRS variable to control what directories are changed after a documentation action. Generally all documentation actions take place inside MANUAL_BASEDIR_L10N, except when we rename an entire manual. When an entire manual is rename, there is a MANUAL_BASEDIR source location and one MANUAL_BASEDIR target location. The MANUAL_BASEDIR source location is marked for deletion and the MANUAL_BASEDIR target location is marked for addition. This way, when we rename an entire manual, the MANUAL_CHANGED_DIRS needs to be set to contain these two locations. - Put initial syncronization of changes back into non-option arguments interpretation loop. This is required in order to use MANUAL_CHANGED_DIRS as source location. - Don't use MANUAL_TLDIR as source location to realize final commit of changes. Use MANUAL_CHANGED_DIRS as source location instead. texinfo_deleteEntryManual.sh - Set MANUAL_CHANGED_DIRS to MANUAL_BASEDIR when MANUAL_BASEDIR_L10N is the last manual inside MANUAL_BASEDIR. texinfo_updateStructureSection.sh - Reorganize MANUAL_ENTRIES definition. texinfo_renameEntryManual.sh - Redefine absolute path to changed directories (MANUAL_CHANGED_DIRS). - It is important that MANUAL_CHANGED_DIRS be redefined after `texinfo_deleteEntryManual' invocation. Otherwise, redefinition of MANUAL_CHANGED_DIRS inside `texinfo_deleteEntryManual' will be the one used which might be not the value we need. --- diff --git a/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh index 749752e..3c99bd4 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh @@ -50,6 +50,12 @@ function texinfo_deleteEntryManual { # Remove manual base directory. svn del ${MANUAL_BASEDIR} --quiet --force + # Redefine absolute paths to changed directory. This is + # required in order for `cli_commitRepoChanges' to be aware + # that we are deleting MANUAL_BASEDIR, not + # MANUAL_BASEDIR_L10N. + MANUAL_CHANGED_DIRS="${MANUAL_BASEDIR}" + fi } diff --git a/Scripts/Functions/Help/Texinfo/texinfo_renameEntryManual.sh b/Scripts/Functions/Help/Texinfo/texinfo_renameEntryManual.sh index 3ad77e9..9fb46ed 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_renameEntryManual.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_renameEntryManual.sh @@ -32,6 +32,12 @@ function texinfo_renameEntryManual { # Delete section source entry. ${FLAG_BACKEND}_deleteEntryManual + # Redefine absolute paths to changed directories. This is + # required in order for `cli_commitRepoChanges' to be aware of + # manual source and target locations we've just renamed. + MANUAL_CHANGED_DIRS="${MANUAL_BASEDIR} $(echo $MANUAL_BASEDIR \ + | sed -r "s!${MANUAL_DIRN[${MANUAL_DOCENTRY_ID}]}!${MANUAL_DIRN[((${MANUAL_DOCENTRY_ID} + 1))]}!")" + # From this time on, the manual information set so far is no # longer useful. Redefine it to start using the new manual # information instead. diff --git a/Scripts/Functions/Help/Texinfo/texinfo_updateStructureSection.sh b/Scripts/Functions/Help/Texinfo/texinfo_updateStructureSection.sh index b411024..1372167 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_updateStructureSection.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_updateStructureSection.sh @@ -40,43 +40,6 @@ function texinfo_updateStructureSection { PATTERN=".+\.${MANUAL_EXTENSION}" fi - # Define manual entries based on pattern. - if [[ -a $PATTERN ]];then - - # Define list of target documentation entries using find's - # regular expression pattern as reference. Notice that, when - # wer update section definition files, the files already exist - # in the working copy so the pattern can be its absolute path - # without any problem. If the pattern is built correctly, it - # will match the location and so be returned to build the list - # of entries to process. Notice also that, when updating, it - # is possible to use a regular expression to match more than - # one location and build the list of entries based on such - # matching. In this last configuration, let you to update - # menu, nodes and cross references to many section definitions - # (i.e., all those section definition file that match the - # pattern you specified). - MANUAL_ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR_L10N} \ - --pattern="$PATTERN" | egrep -v "/(${MANUAL_NAME}|chapter)") - - else - - # Define list of target documentation entries using pattern as - # reference. When we delete a section entry from the working - # copy, using find to retrive its path isn't useful because - # the section definition file has been already removed from - # the working copy and even the regex pattern be correctly - # formed, the file doesn't exist and by consequence no match - # is found. This issue provokes no section entry to be - # removed from menu, nodes and cross references. In order to - # solve this, use the pattern value as list of target entries. - # Notice that, in this case, the pattern value must be the - # absolute path of that section entry removed we want to - # update menu, nodes and cross references information for. - MANUAL_ENTRIES=$PATTERN - - fi - # Define action to perform on definitions. case "$2" in @@ -110,6 +73,37 @@ function texinfo_updateStructureSection { esac + # Define list of target entries using find's regular expression + # pattern as reference. Notice that, when we update section + # definition files, the files already exist in the working copy so + # the pattern can be its absolute path without any problem. If the + # pattern is built correctly, it will match the location and so be + # returned to build the list of entries to process. Notice also + # that, when updating, it is possible to use a regular expression + # to match more than one location and build the list of entries + # based on such matching. In this last configuration, let you to + # update menu, nodes and cross references to many section + # definitions (i.e., all those section definition file that match + # the pattern you specified). + MANUAL_ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR_L10N} \ + --pattern="$PATTERN" | egrep -v "/(${MANUAL_NAME}|chapter)") + + # Verify list of target entries. Assuming is is empty, define + # list of target documentation entries using pattern as reference + # instead. When we delete a section entry from the working copy, + # using find to retrive its path isn't possible because the + # section definition file is removed before executing find and by + # consequence no match is found. This issue provokes no section + # entry to be removed from menu, nodes and cross references. In + # order to solve this, use the pattern value as list of target + # entries. Notice that, in this case, the pattern value must be + # the absolute path to that documentation entry which doesn't + # exist and we want to update menu, nodes and cross references + # information for. + if [[ $MANUAL_ENTRIES == '' ]];then + MANUAL_ENTRIES=$PATTERN + fi + # Print action message. cli_printMessage "`gettext "Updating section menus, nodes and cross references."`" --as-response-line diff --git a/Scripts/Functions/Help/help.sh b/Scripts/Functions/Help/help.sh index 27cf402..ae86c58 100755 --- a/Scripts/Functions/Help/help.sh +++ b/Scripts/Functions/Help/help.sh @@ -74,11 +74,6 @@ function help { # Interpret option arguments passed through the command-line. ${FUNCNAM}_getOptions - # Syncronize changes between repository and working copy. At this - # point, changes in the repository are merged in the working copy - # and changes in the working copy committed up to repository. - cli_syncroRepoChanges ${MANUAL_TLDIR} - # Redefine arrays related to documentation entries using # non-option arguments passed through the command-line. At this # point all options have been removed from ARGUMENTS and @@ -116,6 +111,30 @@ function help { # texinfo source files. MANUAL_BASEDIR_L10N="${MANUAL_BASEDIR}/${MANUAL_L10N}" + # Define absolute path to changed directories inside the + # manual. For example, when a section entry is edited, copied + # or renamed inside the same manual there is only one + # aboslute path to changed directory to look for changes, the + # one holding the section entry. However, when a manual entry + # is renamed, there are two different locations to look for + # changes, the source manual removed and the target manual + # added. + MANUAL_CHANGED_DIRS="${MANUAL_BASEDIR_L10N}" + + # Syncronize changes between repository and working copy. At + # this point, changes in the repository are merged in the + # working copy and changes in the working copy committed up to + # repository. Notice that, because we are processing + # non-option arguments one by one, there is no need to + # sycronize changes to the same manual time after time + # (assuming all documentation entries passed as non-option + # arguments refer the same manual directory name). + if [[ ${MANUAL_DOCENTRY_ID} -eq 0 \ + || ( ( ${MANUAL_DOCENTRY_ID} -gt 0 ) && ( \ + ${MANUAL_DIRN[${MANUAL_DOCENTRY_ID}]} != ${MANUAL_DIRN[((${MANUAL_DOCENTRY_ID} - 1))]} ) ) ]];then + cli_syncroRepoChanges ${MANUAL_CHANGED_DIRS} + fi + # Define absolute path to base file. This is the main file # name (without extension) we use as reference to build output # files in different formats (.info, .pdf, .xml, etc.). @@ -142,6 +161,6 @@ function help { # this point, changes in the repository are not merged in the # working copy, but chages in the working copy do are committed up # to repository. - cli_commitRepoChanges ${MANUAL_TLDIR} + cli_commitRepoChanges ${MANUAL_CHANGED_DIRS} }