|
|
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
|
|
|
d92dde |
# the '--delete-entry' string as first argument, the menu line related
|
|
|
60a25c |
# to the entry being processed is removed. Otherwise, if this function
|
|
|
d92dde |
# is called with the '--add-entry' string as first argument, the menu
|
|
|
60a25c |
# line related to the entry being processed is added to menu's bottom.
|
|
|
d92dde |
# If no argument is passed to this function, the '--add-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.
|
|
|
7e33b8 |
local MENUNODE=$(${FLAG_BACKEND}_getEntryNode "$MANUAL_ENTRY")
|
|
|
e124a8 |
|
|
|
edaa9d |
# Define menu entry using texinfo style and node information as
|
|
|
edaa9d |
# reference.
|
|
|
d92dde |
local MENULINE="* ${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 |
|
|
|
d92dde |
--delete-entry )
|
|
|
edaa9d |
# Remove menu entry from chapter menu.
|
|
|
272536 |
MENU=$(echo "$MENU" | egrep -v "$MENULINE")
|
|
|
4c79b5 |
;;
|
|
|
e124a8 |
|
|
|
d92dde |
--add-entry | * )
|
|
|
edaa9d |
# Add menu entry to chapter menu list as last entry.
|
|
|
4c79b5 |
MENU="$MENU
|
|
|
4c79b5 |
$MENULINE"
|
|
|
4c79b5 |
;;
|
|
|
edaa9d |
|
|
|
4c79b5 |
esac
|
|
|
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 |
|
|
|
d92dde |
# Remove opening spaces/tabs and empty lines from final menu
|
|
|
d92dde |
# structure.
|
|
|
d92dde |
MENU=$(echo "$MENU" | sed -r 's!^[[:space:]]+!!g' \
|
|
|
d92dde |
| egrep -v '^[[:space:]]*$')
|
|
|
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 |
}
|