diff --git a/Scripts/Functions/Help/Texinfo/texinfo_copyEntryChapter.sh b/Scripts/Functions/Help/Texinfo/texinfo_copyEntryChapter.sh index f37f1c6..5f96842 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_copyEntryChapter.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_copyEntryChapter.sh @@ -73,7 +73,7 @@ function texinfo_copyEntryChapter { # At this point, all copying actions had took place and it is time # to update the document structure. Start updating chapter # menu and nodes inside manual structure, - ${FLAG_BACKEND}_updateChaptersMenu + ${FLAG_BACKEND}_updateChapterMenu ${FLAG_BACKEND}_updateChaptersNodes # and section menu, nodes and cross references later. diff --git a/Scripts/Functions/Help/Texinfo/texinfo_copyEntryManual.sh b/Scripts/Functions/Help/Texinfo/texinfo_copyEntryManual.sh index 5d3c275..d2243e7 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_copyEntryManual.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_copyEntryManual.sh @@ -67,7 +67,7 @@ function texinfo_copyEntryManual { # Update chapter information inside the manual's texinfo # structure. - ${FLAG_BACKEND}_updateChaptersMenu + ${FLAG_BACKEND}_updateChapterMenu ${FLAG_BACKEND}_updateChaptersNodes done diff --git a/Scripts/Functions/Help/Texinfo/texinfo_createChapter.sh b/Scripts/Functions/Help/Texinfo/texinfo_createChapter.sh index d730224..27695cd 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_createChapter.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_createChapter.sh @@ -99,7 +99,7 @@ function texinfo_createChapter { # Update chapter information inside the manual's texinfo # structure. - ${FLAG_BACKEND}_updateChaptersMenu + ${FLAG_BACKEND}_updateChapterMenu ${FLAG_BACKEND}_updateChaptersNodes } diff --git a/Scripts/Functions/Help/Texinfo/texinfo_updateChapterMenu.sh b/Scripts/Functions/Help/Texinfo/texinfo_updateChapterMenu.sh new file mode 100755 index 0000000..a477443 --- /dev/null +++ b/Scripts/Functions/Help/Texinfo/texinfo_updateChapterMenu.sh @@ -0,0 +1,86 @@ +#!/bin/bash +# +# texinfo_updateChapterMenu.sh -- This function updates chapter menu. +# +# 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_updateChapterMenu { + + local ACTION=$1 + local MENUCHAPTERS='' + + # Build menu of chapters. The Index node is not included as other + # nodes are. The Index node is defined inside the master texinfo + # file (repository.texinfo) as an included file. To create the final + # .info file correctly, the Index line in the menu should remain, + # even no other node exist. + if [[ -f ${MANUAL_BASEFILE}-menu.${MANUAL_EXTENSION} ]];then + MENUCHAPTERS=$(cat ${MANUAL_BASEFILE}-menu.${MANUAL_EXTENSION} \ + | egrep -v "^@(end )?menu$" \ + | egrep -v '^\* (Licenses|Index)::$') + fi + + # Re-defined menu of chapters based on action. + case $ACTION in + + 'remove-entry' ) + # Remove chapter from menu. + MENUCHAPTERS=$(echo "${MENUCHAPTERS}" \ + | egrep -v "^\* ${MANUAL_CHAPTER_NAME}::[[:print:]]*$") + ;; + + 'update-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 up being a definition error. + MENUCHAPTERS="$(echo "${MENUCHAPTERS}" | egrep -v "\* ${MANUAL_CHAPTER_NAME}::[[:print:]]*$") + * ${MANUAL_CHAPTER_NAME}::" + ;; + esac + + # Remove opening spaces/tabs and empty line from the menu of + # chapters. Empty lines may occur the first time the menu of + # chapters is created. + MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sed -r 's!^[[:space:]]+!!' \ + | egrep -v '^[[:space:]]*$') + + # Organize menu of chapters alphabetically and verify that no + # duplicated line be included on the list. Notice that organizing + # menu this way supresses the idea of putting the last chapter + # created at the end of the list. + #MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sort | uniq) + + # Give format to final menu output. + MENUCHAPTERS="@menu + ${MENUCHAPTERS} + * Licenses:: + * Index:: + @end menu" + + # Remove opening space/tabs from menu's final definition. + MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sed -r 's!^[[:space:]]+!!' \ + | egrep -v '^[[:space:]]*$') + + # Dump organized menu of chapters into file. + echo "${MENUCHAPTERS}" > ${MANUAL_BASEFILE}-menu.${MANUAL_EXTENSION} + +} diff --git a/Scripts/Functions/Help/Texinfo/texinfo_updateChaptersMenu.sh b/Scripts/Functions/Help/Texinfo/texinfo_updateChaptersMenu.sh deleted file mode 100755 index ed7b81c..0000000 --- a/Scripts/Functions/Help/Texinfo/texinfo_updateChaptersMenu.sh +++ /dev/null @@ -1,86 +0,0 @@ -#!/bin/bash -# -# texinfo_updateChaptersMenu.sh -- This function updates chapter menu. -# -# 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_updateChaptersMenu { - - local ACTION=$1 - local MENUCHAPTERS='' - - # Build menu of chapters. The Index node is not included as other - # nodes are. The Index node is defined inside the master texinfo - # file (repository.texinfo) as an included file. To create the final - # .info file correctly, the Index line in the menu should remain, - # even no other node exist. - if [[ -f ${MANUAL_BASEFILE}-menu.${MANUAL_EXTENSION} ]];then - MENUCHAPTERS=$(cat ${MANUAL_BASEFILE}-menu.${MANUAL_EXTENSION} \ - | egrep -v "^@(end )?menu$" \ - | egrep -v '^\* (Licenses|Index)::$') - fi - - # Re-defined menu of chapters based on action. - case $ACTION in - - 'remove-entry' ) - # Remove chapter from menu. - MENUCHAPTERS=$(echo "${MENUCHAPTERS}" \ - | egrep -v "^\* ${MANUAL_CHAPTER_NAME}::[[:print:]]*$") - ;; - - 'update-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 up being a definition error. - MENUCHAPTERS="$(echo "${MENUCHAPTERS}" | egrep -v "\* ${MANUAL_CHAPTER_NAME}::[[:print:]]*$") - * ${MANUAL_CHAPTER_NAME}::" - ;; - esac - - # Remove opening spaces/tabs and empty line from the menu of - # chapters. Empty lines may occur the first time the menu of - # chapters is created. - MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sed -r 's!^[[:space:]]+!!' \ - | egrep -v '^[[:space:]]*$') - - # Organize menu of chapters alphabetically and verify that no - # duplicated line be included on the list. Notice that organizing - # menu this way supresses the idea of putting the last chapter - # created at the end of the list. - #MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sort | uniq) - - # Give format to final menu output. - MENUCHAPTERS="@menu - ${MENUCHAPTERS} - * Licenses:: - * Index:: - @end menu" - - # Remove opening space/tabs from menu's final definition. - MENUCHAPTERS=$(echo "${MENUCHAPTERS}" | sed -r 's!^[[:space:]]+!!' \ - | egrep -v '^[[:space:]]*$') - - # Dump organized menu of chapters into file. - echo "${MENUCHAPTERS}" > ${MANUAL_BASEFILE}-menu.${MANUAL_EXTENSION} - -}