From d92dded5cec67b0264ab5504d8c494755add95f3 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Jul 18 2011 13:29:23 +0000 Subject: Update `texinfo' documentation backend inside `help' functionality: - Add `texinfo_deleteEntrySection.sh', `texinfo_deleteEntryChapter.sh', and `texinfo_deleteEntryManual.sh' to separate deletion of documentation entries based on value passed as non-option argument to `centos-art.sh' script. - Update `texinfo_deleteEntry' to start using `texinfo_deleteEntrySection', `texinfo_deleteEntryChapter', and `texinfo_deleteEntryManual'. - Fix node construction inside `texinfo_getNode' function. Don't remove the chapter name from node. - Update `texinfo_updateStructureSection' to be reused in both cases when nodes are added and removed. - Remove chapter name from menu entries build from node. The node value already holds the chapter name. Don't duplicate it here. - Update replacement pattern in `texinfo_restoreCrossReferences' and in `texinfo_deleteCrossReferences'. There is no need to use word boundaries matching here. - Rename `texinfo_updateChapterNode' to `texinfo_updateChapterNodes'. --- diff --git a/Scripts/Functions/Help/Texinfo/texinfo_copyEntryChapter.sh b/Scripts/Functions/Help/Texinfo/texinfo_copyEntryChapter.sh index a763d8f..a0083f8 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_copyEntryChapter.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_copyEntryChapter.sh @@ -74,7 +74,7 @@ function texinfo_copyEntryChapter { # to update the document structure. Start updating chapter # menu and nodes inside manual structure, ${FLAG_BACKEND}_updateChapterMenu - ${FLAG_BACKEND}_updateChapterNode + ${FLAG_BACKEND}_updateChapterNodes # and section menu, nodes and cross references later. ${FLAG_BACKEND}_updateStructureSection ".+\.${MANUAL_EXTENSION}" diff --git a/Scripts/Functions/Help/Texinfo/texinfo_copyEntryManual.sh b/Scripts/Functions/Help/Texinfo/texinfo_copyEntryManual.sh index c0e3cff..0088c32 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_copyEntryManual.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_copyEntryManual.sh @@ -68,7 +68,7 @@ function texinfo_copyEntryManual { # Update chapter information inside the manual's texinfo # structure. ${FLAG_BACKEND}_updateChapterMenu - ${FLAG_BACKEND}_updateChapterNode + ${FLAG_BACKEND}_updateChapterNodes done diff --git a/Scripts/Functions/Help/Texinfo/texinfo_createChapter.sh b/Scripts/Functions/Help/Texinfo/texinfo_createChapter.sh index b986332..8f88f78 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_createChapter.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_createChapter.sh @@ -100,6 +100,6 @@ function texinfo_createChapter { # Update chapter information inside the manual's texinfo # structure. ${FLAG_BACKEND}_updateChapterMenu - ${FLAG_BACKEND}_updateChapterNode + ${FLAG_BACKEND}_updateChapterNodes } diff --git a/Scripts/Functions/Help/Texinfo/texinfo_deleteCrossReferences.sh b/Scripts/Functions/Help/Texinfo/texinfo_deleteCrossReferences.sh index e6f0aeb..de4539a 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_deleteCrossReferences.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_deleteCrossReferences.sh @@ -42,7 +42,7 @@ function texinfo_deleteCrossReferences { fi # Build the node string using entry location. - local NODE=$(${FLAG_BACKEND}_getNode "$MANUAL_ENTRY") + local NODE="$(${FLAG_BACKEND}_getNode "$MANUAL_ENTRY")" # Define regular expression patterns for texinfo cross reference # commands. @@ -75,23 +75,11 @@ function texinfo_deleteCrossReferences { # command to add a newline to the pattern space, the s command to # make the pattern replacement using the `g' flag to make it # global and finaly the command `b' to branch label named `a'. - # - # Inside the pattern space, the `\<' and `\>' are used to restrict - # the match pattern to a word boundary. The word boundary - # restriction applied here is required to avoid undesired - # replacements when we replace singular words with their plurals. - # For example, if we need to change the word `Manual' to its - # plular (i.e., `Manuals'), and no boundary restriction is used in - # the pattern space to do that, we might end up having words like - # `Manualsssss'. This is because this sed command might be applied - # to the same file many times; and each time it is applied a new - # `Manuals' replaces the previous `Manuals' replacement to form - # `Manualss', `Manualsss', and so on for each interaction. - sed -r -i ":a;N;s!\<${PATTERN[0]}\>!${REPLACE[0]}!g;ba" ${MANUAL_ENTRIES} + sed -r -i ":a;N;s!${PATTERN[0]}!${REPLACE[0]}!g;ba" ${MANUAL_ENTRIES} # Update menu-related cross references. Menu-related cross # references hardly appear in more than one line, so there is no # need to complicate much the replacement command. - sed -r -i "s!\<${PATTERN[1]}\>!${REPLACE[1]}!" ${MANUAL_ENTRIES} + sed -r -i "s!${PATTERN[1]}!${REPLACE[1]}!" ${MANUAL_ENTRIES} } diff --git a/Scripts/Functions/Help/Texinfo/texinfo_deleteEntry.sh b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntry.sh index 6432be0..47ec256 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_deleteEntry.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntry.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# texinfo_deleteEntry.sh -- This function removes a documentation entry -# from documentation directory structure. +# texinfo_deleteEntry.sh -- This function removes a documentation +# manuals, chapters or sections from the working copy. # # Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG # @@ -25,113 +25,53 @@ function texinfo_deleteEntry { - local MANUAL_ENTRY='' - local MANUAL_ENTRY_DIR='' - local MANUAL_ENTRY_SUBDIR='' - - # Define list of entries to remove using the entry specified in - # the command line. - local MANUAL_ENTRIES=$(${FLAG_BACKEND}_getEntry "$@") - - # Print separator line. - cli_printMessage '-' --as-separator-line - - # Define list of dependen entries. Dependent entries are stored - # inside a directory with the same name of the entry being - # removed. - for MANUAL_ENTRY in $MANUAL_ENTRIES;do - - # Define directory where dependent documentation entries are - # stored in. - MANUAL_ENTRY_DIR=$(echo $MANUAL_ENTRY \ - | sed -r "s/\.${MANUAL_EXTENSION}$//") - - if [[ -d $MANUAL_ENTRY_DIR ]];then - - # Add dependent documentation entries to the list of - # documentation entries that will be deleted. - MANUAL_ENTRIES="${MANUAL_ENTRIES} $(cli_getFilesList ${MANUAL_ENTRY_DIR} \ - --pattern=".*\.${MANUAL_EXTENSION}")" - - for MANUAL_ENTRY in $MANUAL_ENTRIES;do - - # Define directory name for dependent documentation - # entries which have their own dependent directories. - MANUAL_ENTRY_SUBDIR=$(basename $MANUAL_ENTRY \ - | sed -r "s/\.${MANUAL_EXTENSION}$//") - - # Add directory paths from dependent documentation - # entries which have their own dependent directories - # to the list of documentation entries that will be - # deleted. - MANUAL_ENTRIES="${MANUAL_ENTRIES} $(cli_getFilesList \ - ${MANUAL_ENTRY_DIR} \ - --pattern=".*/${MANUAL_ENTRY_SUBDIR}" \ - --type='d')" - - done - - fi - - done - - # Sanitate list of documentation entries that will be removed. - MANUAL_ENTRIES=$(echo ${MANUAL_ENTRIES} | tr ' ' "\n" | sort -r | uniq | tr "\n" ' ') - - # Verify existence of entries before deleting them. We cannot - # delete an entry which doesn't exist. Assuming that an entry - # doesn't exist, end script execution with an error message. - cli_checkFiles "$MANUAL_ENTRIES" - - # Remove documentation entry using Subversion's `delete' command - # to know when the action took place. Do not use regular `rm' - # command here. - for MANUAL_ENTRY in $MANUAL_ENTRIES;do - cli_printMessage "$MANUAL_ENTRY" --as-deleting-line - svn del ${MANUAL_ENTRY} --quiet - done - - # Verify exit status from subversion command to be sure everything - # went well. Otherwise stop script execution with an error - # message. - if [[ $? -ne 0 ]];then - cli_printMessage "`gettext "An error occurred when deleting entries."`" --as-toknowmore-line - fi - # Print separator line. cli_printMessage '-' --as-separator-line # Print action message. - cli_printMessage "`gettext "Updating menus, nodes and cross-references."`" --as-response-line - - # Process list of entries in order to update menus, nodes and - # cross references. Since we are verifying entry status before - # remove the we cannot update the information in the same loop we - # remove files. This would modify some file before be removed and - # that would stop script execution. Similary, if we do update - # menus, nodes and cross references before removing files it would - # be needed to remove farther status verification in order for the - # script to continue its execution. Thereby, I can't see a - # different way but removing files first using status verification - # and later go through entries list again to update menus, nodes - # and cross references in remaining files. - for MANUAL_ENTRY in ${MANUAL_ENTRIES};do - - # Skip all directories, they are not documentation entries on - # themselves. Use documentation entries only. - if [[ ! $MANUAL_ENTRY =~ "\.${MANUAL_EXTENSION}$" ]];then - continue - fi - - # Update menu and node definitions from manual sections to - # reflect the changes. - ${FLAG_BACKEND}_updateSectionMenu "remove-entry" - ${FLAG_BACKEND}_updateSectionNodes + cli_printMessage "$MANUAL_ENTRY" --as-deleting-line + + # Verify existence of documentation entry before deleting it. We + # cannot delete an entry which doesn't exist. + cli_checkFiles "$MANUAL_ENTRY" + + # Remove manual, chapter or section based on documentation entry + # provided as non-option argument to `centos-art.sh' script. + if [[ ${MANUAL_SECN[$MANUAL_DOCENTRY_ID]} != '' ]];then + + # When a section is deleted, documentation entry points to a + # section name. In this configuration, documentation entry is + # deleted through subversion in order to register the change. + # Once the documentation entry is deleted, the section menu + # and nodes definition files are updated to keep manual in a + # consistent state. + ${FLAG_BACKEND}_deleteEntrySection + + elif [[ ${MANUAL_CHAN[$MANUAL_DOCENTRY_ID]} != '' ]];then + + # When a chapter is deleted, documentation entry doesn't point + # to a section name but a chapter name. In this configuration, + # it is necessary to build a list of all the section entries + # available inside the chapter before deleting it. Once the + # chapter has been marked for deletion, it is time to update + # chapter definition files and later section definition files + # using the list of section entries previously defined. + # Actualization of section definition files must be done one + # at a time because menu entries related to section + # definitions are updated one at a time. + ${FLAG_BACKEND}_deleteEntryChapter + + elif [[ ${MANUAL_DIRN[$MANUAL_DOCENTRY_ID]} != '' ]];then + + # When a manual is deleted, documentation entry doesnt' point + # to either a section or chapter but a manual name only. In + # this configuration the entire manual directory is marked for + # deletion, and that way processed. + ${FLAG_BACKEND}_deleteEntryManual + + else + cli_printMessage "`gettext "The parameters you provided are not supported."`" --as-error-line + fi - # Update cross reference definitions from manual to reflect - # the changes. - ${FLAG_BACKEND}_deleteCrossReferences $MANUAL_ENTRY - done - } diff --git a/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryChapter.sh b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryChapter.sh new file mode 100755 index 0000000..a7c14c4 --- /dev/null +++ b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryChapter.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# texinfo_deleteEntryChapter.sh -- This function standardizes chapter +# deletion inside the manual structure. +# +# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function texinfo_deleteEntryChapter { + + # Build list of section entries inside the chapter. This is + # required to delete cross references from other section entries + # that point to section entries inside the chapter that will be + # deleted. Take care don't include the chapter definition files. + local MANUAL_ENTRIES=$(cli_getFilesList $MANUAL_CHAPTER_DIR \ + --pattern=".+\.${MANUAL_EXTENSION}" \ + | egrep -v '/chapter') + + # Remove chapter directory using subversion to register the + # change. + svn del ${MANUAL_CHAPTER_DIR} --quiet + + # Update chapter menu and nodes inside manual structure. + ${FLAG_BACKEND}_updateChapterMenu --delete-entry + ${FLAG_BACKEND}_updateChapterNodes + + # Loop through section entries retrived from chapter, before + # deleting it, in order to remove cross references pointing to + # those section entries. Since the chapter and all its sections + # have been removed, cross references pointing them will point to + # non-existent section entries. This way, all cross references + # pointing to non-existent section entries will be transformed in + # order for documentors to advertise the section entry state. + for MANUAL_ENTRY in $MANUAL_ENTRIES;do + ${FLAG_BACKEND}_deleteCrossReferences ${MANUAL_ENTRY} + done + +} + diff --git a/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh new file mode 100755 index 0000000..7b856f5 --- /dev/null +++ b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh @@ -0,0 +1,63 @@ +#!/bin/bash +# +# texinfo_deleteEntryManual.sh -- This function standardized manual +# deletion inside the working copy. +# +# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function texinfo_deleteEntryManual { + + # Remove locale-specific documentation manual directory from the + # working copy. Using subversion to register the change. Be sure + # that related output files are removed too. + svn del ${MANUAL_BASEDIR_L10N} --quiet --force + + # Verify manual base directory. When the locale-specific + # documentaion manual is the last one inside the manual base + # directory, remove the manual base directory from the working + # copy. There is no need to have an empty manual base directories + # inside the working copy. + if [[ $(ls -1 $MANUAL_BASEDIR | wc -l) -le 1 ]];then + + # Remove manual base directory. + svn del ${MANUAL_BASEDIR} --quiet + + # Commit changes from working copy to central repository only. + # At 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_BASEDIR} + + else + + # Commit changes from working copy to central repository only. + # At 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_BASEDIR_L10N} + + fi + + # Terminate script execution here. The documentation manual has + # been removed and there is nothing else to do here. + exit + +} diff --git a/Scripts/Functions/Help/Texinfo/texinfo_deleteEntrySection.sh b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntrySection.sh new file mode 100755 index 0000000..6e25499 --- /dev/null +++ b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntrySection.sh @@ -0,0 +1,35 @@ +#!/bin/bash +# +# texinfo_deleteEntrySection.sh -- This function standardized section +# deletion inside the manual structure. +# +# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function texinfo_deleteEntrySection { + + # Remove documentation entry using subversion to register the + # change. + svn del $MANUAL_ENTRY --quiet + + # Update section menu, nodes and cross references. + ${FLAG_BACKEND}_updateStructureSection "${MANUAL_ENTRY}" --delete + +} diff --git a/Scripts/Functions/Help/Texinfo/texinfo_getNode.sh b/Scripts/Functions/Help/Texinfo/texinfo_getNode.sh index 6863284..ac2a74d 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_getNode.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_getNode.sh @@ -35,7 +35,7 @@ function texinfo_getNode { # Define node from documentation entry. local NODE=$(echo "$MANUAL_ENTRY" | sed -r \ - -e "s!^${MANUAL_BASEDIR_L10N}/${MANUAL_CHAPTER_NAME}!!" \ + -e "s!^${MANUAL_BASEDIR_L10N}/!!" \ -e "s/(chapter-intro\.${MANUAL_EXTENSION}|\.${MANUAL_EXTENSION})$//" \ -e 's!(/|-)! !g' \ -e 's! ([[:alpha:]])! \u\1!g' \ diff --git a/Scripts/Functions/Help/Texinfo/texinfo_restoreCrossReferences.sh b/Scripts/Functions/Help/Texinfo/texinfo_restoreCrossReferences.sh index 5a15609..2ba3885 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_restoreCrossReferences.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_restoreCrossReferences.sh @@ -46,7 +46,7 @@ function texinfo_restoreCrossReferences { fi # Build the node string using entry location. - local NODE=$(${FLAG_BACKEND}_getNode "$MANUAL_ENTRY") + local NODE="$(${FLAG_BACKEND}_getNode "$MANUAL_ENTRY")" # Define regular expression patterns to match removed message # format produced by message_removeCrossReferences function. @@ -55,7 +55,7 @@ function texinfo_restoreCrossReferences { # Define replacement string to turn removed message back to cross # reference link. - REPLACE[0]='@\1{\2}' + REPLACE[0]='\@\1{\2}' REPLACE[1]='\1' # Define list of entries to process. @@ -72,23 +72,11 @@ function texinfo_restoreCrossReferences { # command to add a newline to the pattern space, the s command to # make the pattern replacement using the `g' flag to make it # global and finaly the command `b' to branch label named `a'. - # - # Inside the pattern space, the `\<' and `\>' are used to restrict - # the match pattern to a word boundary. The word boundary - # restriction applied here is required to avoid undesired - # replacements when we replace singular words with their plurals. - # For example, if we need to change the word `Manual' to its - # plular (i.e., `Manuals'), and no boundary restriction is used in - # the pattern space to do that, we might end up having words like - # `Manualsssss'. This is because this sed command might be applied - # to the same file many times; and each time it is applied a new - # `Manuals' replaces the previous `Manuals' replacement to form - # `Manualss', `Manualsss', and so on for each interaction. - sed -r -i ":a;N;s!\<${PATTERN[0]}\>!${REPLACE[0]}!g;ba" ${MANUAL_ENTRIES} + sed -r -i ":a;N;s!${PATTERN[0]}!${REPLACE[0]}!g;ba" ${MANUAL_ENTRIES} # Update menu-related cross references. Menu-related cross # references hardly appear in more than one line, so there is no # need to complicate the replacement command. - sed -r -i "s!\<${PATTERN[1]}\>!${REPLACE[1]}!" ${MANUAL_ENTRIES} + sed -r -i "s!${PATTERN[1]}!${REPLACE[1]}!" ${MANUAL_ENTRIES} } diff --git a/Scripts/Functions/Help/Texinfo/texinfo_updateChapterMenu.sh b/Scripts/Functions/Help/Texinfo/texinfo_updateChapterMenu.sh index 38ea6cb..3989645 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_updateChapterMenu.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_updateChapterMenu.sh @@ -41,13 +41,13 @@ function texinfo_updateChapterMenu { # Re-defined menu of chapters based on action. case $ACTION in - 'remove-entry' ) + --delete-entry ) # Remove chapter from menu. MENUCHAPTERS=$(echo "${MENUCHAPTERS}" \ | egrep -v '^\* '"${MANUAL_CHAPTER_NAME}"'::[[:print:]]*$') ;; - 'update-entry' | * ) + --add-entry | * ) # Update chapter menu using texinfo format. Be sure the # chapter node itself is not included here, that would # duplicate it inside the menu definition file which end diff --git a/Scripts/Functions/Help/Texinfo/texinfo_updateChapterNodes.sh b/Scripts/Functions/Help/Texinfo/texinfo_updateChapterNodes.sh index 50a46e9..2944d3f 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_updateChapterNodes.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_updateChapterNodes.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# texinfo_updateChapterNode.sh -- This function updates nodes of +# texinfo_updateChapterNodes.sh -- This function updates nodes of # chapters based on menu of chapters. # # Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG @@ -23,7 +23,7 @@ # $Id$ # ---------------------------------------------------------------------- -function texinfo_updateChapterNode { +function texinfo_updateChapterNodes { # Build chapter nodes using entries from chapter menu as # reference. Don't include `Licenses' or `Index' chapters here. diff --git a/Scripts/Functions/Help/Texinfo/texinfo_updateSectionMenu.sh b/Scripts/Functions/Help/Texinfo/texinfo_updateSectionMenu.sh index cacdfaf..17caafe 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_updateSectionMenu.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_updateSectionMenu.sh @@ -2,11 +2,11 @@ # # texinfo_updateSectionMenu.sh -- This function updates the section's # menu definition file of a chapter. If this function is called with -# the 'remove-entry' string as first argument, the menu line related +# the '--delete-entry' string as first argument, the menu line related # to the entry being processed is removed. Otherwise, if this function -# is called with the 'update-entry' string as first argument, the menu +# is called with the '--add-entry' string as first argument, the menu # line related to the entry being processed is added to menu's bottom. -# If no argument is passed to this function, the 'update-entry' action +# If no argument is passed to this function, the '--add-entry' action # is assumed. # # Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG @@ -40,7 +40,7 @@ function texinfo_updateSectionMenu { # Define menu entry using texinfo style and node information as # reference. - local MENULINE="* ${MANUAL_CHAPTER_NAME} ${MENUNODE}::" + local MENULINE="* ${MENUNODE}::" # Retrive list of menu entries from chapter menu and exclude # `@menu', `@end menu' and empty lines from output. @@ -51,12 +51,12 @@ function texinfo_updateSectionMenu { # function as first positional parameter. case $ACTION in - 'remove-entry' ) + --delete-entry ) # Remove menu entry from chapter menu. MENU=$(echo "$MENU" | egrep -v "$MENULINE") ;; - 'update-entry' | * ) + --add-entry | * ) # Add menu entry to chapter menu list as last entry. MENU="$MENU $MENULINE" @@ -64,19 +64,16 @@ function texinfo_updateSectionMenu { esac - # Remove empty lines from chapter menu entries. Don't order - # alphabetically. That would suppress the idea of putting the - # last entry added as last entry in the chapter menu entries. - MENU=$(echo "$MENU" | egrep -v '^[[:space:]]*$') - # Rebuild list of chapter menu entries including '@menu' and '@end # menu' lines back into chapter menu. MENU="@menu $MENU @end menu" - # Remove opening spaces/tabs from final menu structure. - MENU=$(echo "$MENU" | sed -r 's!^[[:space:]]+!!g') + # Remove opening spaces/tabs and empty lines from final menu + # structure. + MENU=$(echo "$MENU" | sed -r 's!^[[:space:]]+!!g' \ + | egrep -v '^[[:space:]]*$') # Dump chapter menu entries back into chapter's menu definition # file. diff --git a/Scripts/Functions/Help/Texinfo/texinfo_updateStructureSection.sh b/Scripts/Functions/Help/Texinfo/texinfo_updateStructureSection.sh index 36dffa9..e722c9f 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_updateStructureSection.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_updateStructureSection.sh @@ -1,8 +1,9 @@ #!/bin/bash # # texinfo_updateStructureSection.sh -- This function looks for all -# documentation entry (section) files inside manual's base directory and -# updates menu, nodes and cross references for them. +# documentation entry (section) files inside manual's base directory +# and updates menu, nodes and cross references definitions for them +# all, one at a time. # # Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG # @@ -29,14 +30,48 @@ function texinfo_updateStructureSection { local PATTERN='' local MANUAL_ENTRY='' local MANUAL_ENTRIES='' + local ACTIONNAM_SECMENU='' + local ACTIONNAM_CROSREF='' # Define find's regular expression pattern. - if [[ $1 != '' ]];then + if [[ "$1" != '' ]];then PATTERN="$1" else PATTERN=".+\.${MANUAL_EXTENSION}" fi + # Define action to perform on definitions. + case "$2" in + + --delete ) + + # Remove menu and node definitions for sections inside + # manual, in order to reflect the changes. + ACTIONNAM_SECMENU='updateSectionMenu --delete-entry' + + # Remove cross reference definitions inside manual + # structure. + ACTIONNAM_CROSREF='deleteCrossReferences' + ;; + + --update | * ) + + # Update menu and node definitions for sections inside + # manual, in order to reflect the changes. + ACTIONNAM_SECMENU='updateSectionMenu --add-entry' + + # Resotre cross reference definitions inside manual + # structure. If a documentation entry has been removed by + # mistake and that mistake is later fixed by adding the + # removed documentation entry back into the manual + # structure, it is necessary to rebuild the missing cross + # reference information inside the manual structure in + # order to reactivate the removed cross refereces, as + # well. + ACTIONNAM_CROSREF='restoreCrossReferences' + ;; + esac + # Define list of target documentation entries using find's regular # expression pattern as reference. This is required in order to # process non-existent documentation entries (e.g., when they are @@ -68,21 +103,8 @@ function texinfo_updateStructureSection { # documentation entry files, it is also needed to update menu, # nodes and related cross-references). for MANUAL_ENTRY in ${MANUAL_ENTRIES};do - - # Update menu and node definitions for sections inside manual - # in order to reflect the changes. - ${FLAG_BACKEND}_updateSectionMenu + ${FLAG_BACKEND}_${ACTIONNAM_SECMENU} ${FLAG_BACKEND}_updateSectionNodes - - # Resotre cross reference definitions inside manual structure. - # If a documentation entry has been removed by mistake and - # that mistake is later fixed by adding the removed - # documentation entry back into the manual structure, it is - # necessary to rebuild the missing cross reference information - # inside the manual structure in order to reactivate the - # removed cross refereces, as well. - ${FLAG_BACKEND}_restoreCrossReferences $MANUAL_ENTRY - + ${FLAG_BACKEND}_${ACTIONNAM_CROSREF} ${MANUAL_ENTRY} done - }