diff --git a/Scripts/Bash/Functions/Manual/manual_deleteCrossReferences.sh b/Scripts/Bash/Functions/Manual/manual_deleteCrossReferences.sh new file mode 100755 index 0000000..3bb727f --- /dev/null +++ b/Scripts/Bash/Functions/Manual/manual_deleteCrossReferences.sh @@ -0,0 +1,72 @@ +#!/bin/bash +# +# manual_deleteCrossReferences.sh -- This function looks inside +# texinfo source files, from section level on, and removes all cross +# referece definitions related to a documentation entry. Use this +# function in coordination with manual_deleteEntry function, in order +# to keep cross reference information, inside the documentation +# manual, syncronized. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function manual_deleteCrossReferences { + + local -a PATTERN + local -a REPLACE + + # Build the node string using global entry (ENTRY) variable being + # processed currently. + local NODE=$(echo "$ENTRY" \ + | cut -d / -f10- \ + | tr '/' ' ' \ + | sed -r "s/(${MANUALS_FILE[7]}|\.texi)$//") + + # Define regular expression patterns for texinfo cross reference + # commands. + PATTERN[0]="@(pxref|xref|ref)\{(${NODE})\}" + PATTERN[1]="^(\* ${NODE}:(.*)?:(.*)?)$" + + # Define replacement string for missing entries. It is convenient + # to keep missing entries in documentation for documentation team + # to know. Removing the missing cross reference may intorudce + # confussion. Imagine that! you are spending lots of hours in an + # article and suddenly one of your cross refereces disappears with + # no visible reason, with the next working copy update you + # perform. That's frustrating. Instead, when centos-art.sh script + # finds a missing cross reference it removes the link and remark + # the issue for you to act on it. + REPLACE[0]='--- @strong{'`gettext "Removed"`'}(\1:\2) ---' + REPLACE[1]='@comment --- '`gettext "Removed"`'(\1) ---' + + # Sanitate all missing cross references, related to entry, in + # section texinfo files. Missing cross references, related to + # entry, in chapter texinfo files are already handled by + # manual_updateMenu, and manual_updateNode functions. If we don't + # sanitate missing cross refereces before info file is created, + # errors are displayed since makeinfo don't produce info output + # with broken cross refereces. + sed -r -i \ + -e "s!${PATTERN[0]}!${REPLACE[0]}!Mg" \ + -e "s!${PATTERN[1]}!${REPLACE[1]}!g" \ + $(find ${MANUALS_DIR[2]} -mindepth 3 -name '*.texi') + +} diff --git a/Scripts/Bash/Functions/Manual/manual_deleteEntry.sh b/Scripts/Bash/Functions/Manual/manual_deleteEntry.sh new file mode 100755 index 0000000..ca7d213 --- /dev/null +++ b/Scripts/Bash/Functions/Manual/manual_deleteEntry.sh @@ -0,0 +1,126 @@ +#!/bin/bash +# +# manual_deleteEntry.sh -- This function removes a documentation entry +# from your working copy documentation structure. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function manual_deleteEntry { + + # Define variables as local to avoid conflicts outside. + local ENTRIES='' + local LOCATION='' + + # Check if the entry has been already removed. + cli_checkFiles $ENTRY 'f' + + # Define entries. Start with the one being processed currently. + ENTRIES=$ENTRY + + # Define root location to look for entries. + LOCATION=$(echo $ENTRY | sed -r 's!\.texi$!!') + + # Redefine location to match the chapter's root directory. This + # applies when you try to remove the whole chapter from the + # working copy (e.g., centos-art manual --delete=/home/centos/artwork/trunk/). + if [[ $ENTRY =~ "${MANUALS_FILE[7]}$" ]];then + LOCATION=$(dirname $ENTRY) + fi + + # Look for dependent entries. In this context, dependent entries + # are all files ending in .texi which have a directory name that + # matches the file name (without .texi extension) of the entry + # being processed currently. See LOCATION default definition + # above. If location directory doesn't exist it is probably + # because there is no dependent entries. + if [[ -d $LOCATION ]];then + for ENTRY in $(find $LOCATION -name '*.texi');do + ENTRIES="$ENTRIES $ENTRY $(dirname $ENTRY)" + done + fi + + # Remove duplicated lines from entries list. + ENTRIES=$(echo "$ENTRIES" | tr ' ' "\n" | sort -r | uniq) + + # Print action preamble. + cli_printActionPreamble "$ENTRIES" 'doDelete' 'AsResponseLine' + + # Redefine ENTRY using affected entries as reference. + for ENTRY in $ENTRIES;do + + # Verify entry inside the working copy. + if [[ $(cli_getRepoStatus "$ENTRY") =~ '^( |\?)' ]];then + + # Print action message. + cli_printMessage "$ENTRY" "AsDeletingLine" + + else + + # Do not remove a versioned documentation entry with + # changes inside. Print a message about it and stop script + # execution instead. + cli_printMessage "`gettext "There are pendent changes that need to be committed first."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + + fi + + # Remove documentation entry. At this point, documentation + # entry can be under version control or not versioned at all. + # Here we need to decide how to remove documentation entries + # based on wether they are under version control or not. + if [[ "$(cli_getRepoStatus "$ENTRY")" == ' ' ]];then + + # Documentation entry is under version control and there + # is no change to be commited up to central repository. We + # are safe to schedule it for deletion. + svn del "$ENTRY" --quiet + + elif [[ "$(cli_getRepoStatus "$ENTRY")" == '?' ]];then + + # Documentation entry is not under version control, so we + # don't care about changes inside it. If you say + # centos-art.sh script to remove an unversion + # documentation entry it will do so, using convenctional + # `rm' command. + rm -r "$ENTRY" + + fi + + # Remove entry on section's menu and nodes to reflect the + # fact that documentation entry has been removed. + manual_updateMenu "remove-entry" + manual_updateNodes + + # Remove entry cross references from documentation manual. + manual_deleteCrossReferences + + done + + # Update chapter's menu and nodes in the master texinfo document. + # This is mainly applied when one of the chapters (e.g., trunk/, + # tags/, or branches/) is removed. + if [[ ! -d $ENTRYCHAPTER ]];then + manual_updateChaptersMenu 'remove-entry' + manual_updateChaptersNodes + fi + +} diff --git a/Scripts/Bash/Functions/Manual/manual_getActions.sh b/Scripts/Bash/Functions/Manual/manual_getActions.sh index 51650a3..04410b5 100755 --- a/Scripts/Bash/Functions/Manual/manual_getActions.sh +++ b/Scripts/Bash/Functions/Manual/manual_getActions.sh @@ -88,7 +88,7 @@ function manual_getActions { ACTIONVAL="$2" # Define action name. - ACTIONNAM="${FUNCNAM}_removeEntry" + ACTIONNAM="${FUNCNAM}_deleteEntry" # Rotate positional parameters. shift 2 diff --git a/Scripts/Bash/Functions/Manual/manual_removeCrossReferences.sh b/Scripts/Bash/Functions/Manual/manual_removeCrossReferences.sh deleted file mode 100755 index 8fcafc0..0000000 --- a/Scripts/Bash/Functions/Manual/manual_removeCrossReferences.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# -# manual_removeCrossReferences.sh -- This function looks inside -# texinfo source files, from section level on, and removes all cross -# referece definitions related to a documentation entry. Use this -# function in coordination with manual_removeEntry function, in order -# to keep cross reference information, inside the documentation -# manual, syncronized. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function manual_removeCrossReferences { - - local -a PATTERN - local -a REPLACE - - # Build the node string using global entry (ENTRY) variable being - # processed currently. - local NODE=$(echo "$ENTRY" \ - | cut -d / -f10- \ - | tr '/' ' ' \ - | sed -r "s/(${MANUALS_FILE[7]}|\.texi)$//") - - # Define regular expression patterns for texinfo cross reference - # commands. - PATTERN[0]="@(pxref|xref|ref)\{(${NODE})\}" - PATTERN[1]="^(\* ${NODE}:(.*)?:(.*)?)$" - - # Define replacement string for missing entries. It is convenient - # to keep missing entries in documentation for documentation team - # to know. Removing the missing cross reference may intorudce - # confussion. Imagine that! you are spending lots of hours in an - # article and suddenly one of your cross refereces disappears with - # no visible reason, with the next working copy update you - # perform. That's frustrating. Instead, when centos-art.sh script - # finds a missing cross reference it removes the link and remark - # the issue for you to act on it. - REPLACE[0]='--- @strong{'`gettext "Removed"`'}(\1:\2) ---' - REPLACE[1]='@comment --- '`gettext "Removed"`'(\1) ---' - - # Sanitate all missing cross references, related to entry, in - # section texinfo files. Missing cross references, related to - # entry, in chapter texinfo files are already handled by - # manual_updateMenu, and manual_updateNode functions. If we don't - # sanitate missing cross refereces before info file is created, - # errors are displayed since makeinfo don't produce info output - # with broken cross refereces. - sed -r -i \ - -e "s!${PATTERN[0]}!${REPLACE[0]}!Mg" \ - -e "s!${PATTERN[1]}!${REPLACE[1]}!g" \ - $(find ${MANUALS_DIR[2]} -mindepth 3 -name '*.texi') - -} diff --git a/Scripts/Bash/Functions/Manual/manual_removeEntry.sh b/Scripts/Bash/Functions/Manual/manual_removeEntry.sh deleted file mode 100755 index 8a9a925..0000000 --- a/Scripts/Bash/Functions/Manual/manual_removeEntry.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/bash -# -# manual_removeEntry.sh -- This function removes a documentation entry -# from your working copy documentation structure. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function manual_removeEntry { - - # Define variables as local to avoid conflicts outside. - local ENTRIES='' - local LOCATION='' - - # Check if the entry has been already removed. - cli_checkFiles $ENTRY 'f' - - # Define entries. Start with the one being processed currently. - ENTRIES=$ENTRY - - # Define root location to look for entries. - LOCATION=$(echo $ENTRY | sed -r 's!\.texi$!!') - - # Redefine location to match the chapter's root directory. This - # applies when you try to remove the whole chapter from the - # working copy (e.g., centos-art manual --delete=/home/centos/artwork/trunk/). - if [[ $ENTRY =~ "${MANUALS_FILE[7]}$" ]];then - LOCATION=$(dirname $ENTRY) - fi - - # Look for dependent entries. In this context, dependent entries - # are all files ending in .texi which have a directory name that - # matches the file name (without .texi extension) of the entry - # being processed currently. See LOCATION default definition - # above. If location directory doesn't exist it is probably - # because there is no dependent entries. - if [[ -d $LOCATION ]];then - for ENTRY in $(find $LOCATION -name '*.texi');do - ENTRIES="$ENTRIES $ENTRY $(dirname $ENTRY)" - done - fi - - # Remove duplicated lines from entries list. - ENTRIES=$(echo "$ENTRIES" | tr ' ' "\n" | sort -r | uniq) - - # Print action preamble. - cli_printActionPreamble "$ENTRIES" 'doDelete' 'AsResponseLine' - - # Redefine ENTRY using affected entries as reference. - for ENTRY in $ENTRIES;do - - # Verify entry inside the working copy. - if [[ $(cli_getRepoStatus "$ENTRY") =~ '^( |\?)' ]];then - - # Print action message. - cli_printMessage "$ENTRY" "AsDeletingLine" - - else - - # Do not remove a versioned documentation entry with - # changes inside. Print a message about it and stop script - # execution instead. - cli_printMessage "`gettext "There are pendent changes that need to be committed first."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - - fi - - # Remove documentation entry. At this point, documentation - # entry can be under version control or not versioned at all. - # Here we need to decide how to remove documentation entries - # based on wether they are under version control or not. - if [[ "$(cli_getRepoStatus "$ENTRY")" == ' ' ]];then - - # Documentation entry is under version control and there - # is no change to be commited up to central repository. We - # are safe to schedule it for deletion. - svn del "$ENTRY" --quiet - - elif [[ "$(cli_getRepoStatus "$ENTRY")" == '?' ]];then - - # Documentation entry is not under version control, so we - # don't care about changes inside it. If you say - # centos-art.sh script to remove an unversion - # documentation entry it will do so, using convenctional - # `rm' command. - rm -r "$ENTRY" - - fi - - # Remove entry on section's menu and nodes to reflect the - # fact that documentation entry has been removed. - manual_updateMenu "remove-entry" - manual_updateNodes - - # Remove entry cross references from documentation manual. - manual_removeCrossReferences - - done - - # Update chapter's menu and nodes in the master texinfo document. - # This is mainly applied when one of the chapters (e.g., trunk/, - # tags/, or branches/) is removed. - if [[ ! -d $ENTRYCHAPTER ]];then - manual_updateChaptersMenu 'remove-entry' - manual_updateChaptersNodes - fi - -} diff --git a/Scripts/Bash/Functions/Manual/manual_restoreCrossReferences.sh b/Scripts/Bash/Functions/Manual/manual_restoreCrossReferences.sh index 11b8ed1..febda70 100755 --- a/Scripts/Bash/Functions/Manual/manual_restoreCrossReferences.sh +++ b/Scripts/Bash/Functions/Manual/manual_restoreCrossReferences.sh @@ -6,9 +6,9 @@ # those cases where documentation entries are created/recreated to # documentation structure. It is a verification that looks for # matching documentation entries previously defined as removed by -# manual_removeCrossReferences function. The +# manual_deleteCrossReferences function. The # manual_restoreCrossReferences function relays in the removed message -# format produced by manual_removeCrossReferences function, in order +# format produced by manual_deleteCrossReferences function, in order # to return them back into the link format. # # Copyright (C) 2009-2011 Alain Reguera Delgado