|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
60a25c |
# texinfo_updateSectionMenu.sh -- This function updates the section's
|
|
|
60a25c |
# menu definition file of a chapter. If this function is called with
|
|
|
60a25c |
# the 'remove-entry' string as first argument, the menu line related
|
|
|
60a25c |
# to the entry being processed is removed. Otherwise, if this function
|
|
|
60a25c |
# is called with the 'update-entry' string as first argument, the menu
|
|
|
60a25c |
# line related to the entry being processed is added to menu's bottom.
|
|
|
60a25c |
# If no argument is passed to this function, the 'update-entry' action
|
|
|
60a25c |
# is assumed.
|
|
|
4c79b5 |
#
|
|
|
3b0984 |
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
dcd347 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
dcd347 |
# your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# 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
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
60a25c |
function texinfo_updateSectionMenu {
|
|
|
4c79b5 |
|
|
|
edaa9d |
# Specify which action to do with documentation entry inside the
|
|
|
edaa9d |
# chapter menu.
|
|
|
4c79b5 |
local ACTION="$1"
|
|
|
4c79b5 |
|
|
|
edaa9d |
# Build node information used inside chapter menu.
|
|
|
edaa9d |
local MENUNODE=$(${FLAG_BACKEND}_getNode "$MANUAL_ENTRY")
|
|
|
e124a8 |
|
|
|
edaa9d |
# Define menu entry using texinfo style and node information as
|
|
|
edaa9d |
# reference.
|
|
|
edaa9d |
local MENULINE="* ${MANUAL_CHAPTER_NAME} ${MENUNODE}::"
|
|
|
4c79b5 |
|
|
|
edaa9d |
# Retrive list of menu entries from chapter menu and exclude
|
|
|
edaa9d |
# `@menu', `@end menu' and empty lines from output.
|
|
|
9fa13b |
local MENU=$(cat $MANUAL_CHAPTER_DIR/chapter-menu.${MANUAL_EXTENSION} \
|
|
|
272536 |
| egrep -v '^[[:space:]]*$' | egrep -v '^@(end )?menu')
|
|
|
4c79b5 |
|
|
|
edaa9d |
# Re-defined chapter menu entries based on action provided to this
|
|
|
edaa9d |
# function as first positional parameter.
|
|
|
4c79b5 |
case $ACTION in
|
|
|
e124a8 |
|
|
|
4c79b5 |
'remove-entry' )
|
|
|
edaa9d |
# Remove menu entry from chapter menu.
|
|
|
272536 |
MENU=$(echo "$MENU" | egrep -v "$MENULINE")
|
|
|
4c79b5 |
;;
|
|
|
e124a8 |
|
|
|
4c79b5 |
'update-entry' | * )
|
|
|
edaa9d |
# Add menu entry to chapter menu list as last entry.
|
|
|
4c79b5 |
MENU="$MENU
|
|
|
4c79b5 |
$MENULINE"
|
|
|
4c79b5 |
;;
|
|
|
edaa9d |
|
|
|
4c79b5 |
esac
|
|
|
4c79b5 |
|
|
|
edaa9d |
# Remove empty lines from chapter menu entries. Don't order
|
|
|
edaa9d |
# alphabetically. That would suppress the idea of putting the
|
|
|
edaa9d |
# last entry added as last entry in the chapter menu entries.
|
|
|
edaa9d |
MENU=$(echo "$MENU" | egrep -v '^[[:space:]]*$')
|
|
|
4c79b5 |
|
|
|
edaa9d |
# Rebuild list of chapter menu entries including '@menu' and '@end
|
|
|
edaa9d |
# menu' lines back into chapter menu.
|
|
|
4c79b5 |
MENU="@menu
|
|
|
4c79b5 |
$MENU
|
|
|
4c79b5 |
@end menu"
|
|
|
4c79b5 |
|
|
|
4c79b5 |
# Remove opening spaces/tabs from final menu structure.
|
|
|
4c79b5 |
MENU=$(echo "$MENU" | sed -r 's!^[[:space:]]+!!g')
|
|
|
4c79b5 |
|
|
|
edaa9d |
# Dump chapter menu entries back into chapter's menu definition
|
|
|
edaa9d |
# file.
|
|
|
9fa13b |
echo "$MENU" > $MANUAL_CHAPTER_DIR/chapter-menu.${MANUAL_EXTENSION}
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|