|
|
f8fb31 |
#!/bin/bash
|
|
|
f8fb31 |
#
|
|
|
e9dba2 |
# manual_restoreCrossReferences.sh -- This function looks inside
|
|
|
e9dba2 |
# texinfo source files, from section level on, and restores any cross
|
|
|
e9dba2 |
# reference related to a documentation entry. This function is used in
|
|
|
e9dba2 |
# those cases where documentation entries are created/recreated to
|
|
|
e9dba2 |
# documentation structure. It is a verification that looks for
|
|
|
e9dba2 |
# matching documentation entries previously defined as removed by
|
|
|
e9dba2 |
# manual_removeCrossReferences function. The
|
|
|
e9dba2 |
# manual_restoreCrossReferences function relays in the removed message
|
|
|
e9dba2 |
# format produced by manual_removeCrossReferences function, in order
|
|
|
e9dba2 |
# to return them back into the link format.
|
|
|
f8fb31 |
#
|
|
|
9f5f2e |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
f8fb31 |
#
|
|
|
f8fb31 |
# This program is free software; you can redistribute it and/or
|
|
|
f8fb31 |
# modify it under the terms of the GNU General Public License as
|
|
|
f8fb31 |
# published by the Free Software Foundation; either version 2 of the
|
|
|
f8fb31 |
# License, or (at your option) any later version.
|
|
|
f8fb31 |
#
|
|
|
f8fb31 |
# This program is distributed in the hope that it will be useful, but
|
|
|
f8fb31 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
f8fb31 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
f8fb31 |
# General Public License for more details.
|
|
|
f8fb31 |
#
|
|
|
f8fb31 |
# You should have received a copy of the GNU General Public License
|
|
|
f8fb31 |
# along with this program; if not, write to the Free Software
|
|
|
f8fb31 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
f8fb31 |
# USA.
|
|
|
f8fb31 |
#
|
|
|
f8fb31 |
# ----------------------------------------------------------------------
|
|
|
f8fb31 |
# $Id$
|
|
|
f8fb31 |
# ----------------------------------------------------------------------
|
|
|
f8fb31 |
|
|
|
f8fb31 |
function manual_restoreCrossReferences {
|
|
|
f8fb31 |
|
|
|
f8fb31 |
local -a PATTERN
|
|
|
f8fb31 |
local -a REPLACE
|
|
|
f8fb31 |
|
|
|
f8fb31 |
# Build the node string using global entry (ENTRY) variable being
|
|
|
f8fb31 |
# processed currently.
|
|
|
f8fb31 |
local NODE=$(echo "$ENTRY" \
|
|
|
f8fb31 |
| cut -d / -f10- \
|
|
|
f8fb31 |
| tr '/' ' ' \
|
|
|
f8fb31 |
| sed -r "s/(${MANUALS_FILE[7]}|\.texi)$//")
|
|
|
f8fb31 |
|
|
|
e9dba2 |
# Define regular expression patterns to match removed message
|
|
|
e9dba2 |
# format produced by message_removeCrossReferences function.
|
|
|
f8fb31 |
PATTERN[0]="--- @strong\{`gettext "Removed"`\}\((pxref|xref|ref):(${NODE})\) ---"
|
|
|
f8fb31 |
PATTERN[1]="^@comment --- `gettext "Removed"`\((\* ${NODE}:(.*)?:(.*)?)\) ---$"
|
|
|
f8fb31 |
|
|
|
e9dba2 |
# Define replacement string to turn removed message back to cross
|
|
|
e9dba2 |
# reference link.
|
|
|
f8fb31 |
REPLACE[0]='@\1{\2}'
|
|
|
f8fb31 |
REPLACE[1]='\1'
|
|
|
f8fb31 |
|
|
|
e9dba2 |
# Build list of source texinfo files to process, from section
|
|
|
e9dba2 |
# level on, and apply replacement string previously defined. At
|
|
|
e9dba2 |
# this point we don't touch chapter related texinfo files (i.e.,
|
|
|
e9dba2 |
# repository-menu.texi and repository-nodes.texi) nor section
|
|
|
e9dba2 |
# related definition files (i.e., chapter-nodes.texi,
|
|
|
e9dba2 |
# chapter-menu.texi, chapter-index.texi) because they are handled
|
|
|
e9dba2 |
# by manual_updateChapterMenu, manual_updateChapterNode,
|
|
|
e9dba2 |
# manual_updateMenu, and manual_updateNodes functions
|
|
|
e9dba2 |
# respectively. If we don't sanitate messages built from broken
|
|
|
e9dba2 |
# cross reference messages, they may become obsolete since the
|
|
|
f8fb31 |
# documentation entry, they represent, can be recreated in the
|
|
|
e9dba2 |
# future and, at that time, the link wouldn't be broken any more,
|
|
|
e9dba2 |
# so we need to be aware of this.
|
|
|
f8fb31 |
sed -r -i \
|
|
|
f8fb31 |
-e "s!${PATTERN[0]}!${REPLACE[0]}!Mg" \
|
|
|
f8fb31 |
-e "s!${PATTERN[1]}!${REPLACE[1]}!g" \
|
|
|
f8fb31 |
$(find ${MANUALS_DIR[2]} -mindepth 3 -name '*.texi')
|
|
|
f8fb31 |
|
|
|
f8fb31 |
}
|