diff --git a/Scripts/Functions/Help/Texinfo/texinfo.sh b/Scripts/Functions/Help/Texinfo/texinfo.sh index ca4127d..e9178d0 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo.sh @@ -30,26 +30,6 @@ function texinfo { # Define file extension used by source files inside manuals. MANUAL_EXTENSION='texinfo' - # Verify existence of action names. When no action name is - # provided to centos-art.sh script, read manual's output in info - # format in order to provide a way for people to get oriented - # about The CentOS Artwork Repository and its automation tool, the - # centos-art.sh script. Be sure the manual's output file does - # exist and terminate the script execution once the reading is - # done. - if [[ $ACTIONNAM == '' ]];then - - # Verify existence of manual's output in info format. - cli_checkFiles ${MANUAL_BASEFILE}.info.bz2 - - # Read Top node from manual's output in info format. - /usr/bin/info --node="Top" --file=${MANUAL_BASEFILE}.info.bz2 - - # Terminate script execution right here. - exit - - fi - # Define absolute path to chapter's directory. This is the place # where chapter-specific files are stored in. MANUAL_CHAPTER_DIR=${MANUAL_BASEDIR_L10N}/$(cli_getRepoName \ @@ -76,9 +56,9 @@ function texinfo { # Initialize document structure of new manuals. ${FLAG_BACKEND}_createStructure - # Define documentation entry. To build the documentation entry, we - # combine the manual's name, the chapter's name and the section - # name retrived from the command-line. + # Define documentation entry default values. To build the + # documentation entry, we combine the manual's name, the chapter's + # name and the section name retrived from the command-line. if [[ $MANUAL_CHAPTER_NAME == '' ]];then # When chapter option is not provided, discard the section @@ -107,46 +87,65 @@ function texinfo { cli_printMessage "`gettext "The parameters you provided are not supported."`" --as-error-line fi - # Execute action names. Notice that we've separated action name - # execution in order to control and save the differences among - # them. For example, there are action names that need a fixed - # amount of non-option arguments (e.g., when we rename or copy - # documentation entries); but there are other action names that - # have no restriction in the amount of non-option arguments that - # can be provided to it (e.g., when we edit, read or delete - # documentation entries). - if [[ $ACTIONNAM =~ "^(copy|rename)Entry$" ]];then - - # Execute backend action names that may need to use more than - # one action value. - ${FLAG_BACKEND}_${ACTIONNAM} + # Execute action names. Notice that we've separated execution of + # action names in order to control and save differences among + # them. + if [[ $ACTIONNAM == "" ]];then - # Rebuild output files to propagate recent changes. - ${FLAG_BACKEND}_updateOutputFiles + # When no action name is provided to `centos-art.sh' script, + # read manual's output in info format in order to provide a + # way for people to get oriented about The CentOS Artwork + # Repository and its automation tool, the centos-art.sh + # script. Be sure the manual's output file does exist and + # terminate the script execution once the reading is done. - # Commit changes from working copy to central repository only. - # At this point, changes in the repository are not merged in - # the working copy, but chages in the working copy do are - # committed up to repository. - cli_commitRepoChanges ${MANUAL_BASEDIR} + # Update manual's info output format. + ${FLAG_BACKEND}_updateOutputFiles + + # Read Top node from manual's info output format. + info --node="Top" --file=${MANUAL_BASEFILE}.info.bz2 # Terminate script execution right here. exit - elif [[ $ACTIONNAM =~ "^(searchIndex|updateOutputFiles)$" ]];then + elif [[ $ACTIONNAM =~ "^(copy|rename)Entry$" ]];then - # Execute backend action names which don't require non-option - # arguments to be passed at all, in order for them to do their - # work. + # Both `--copy' and `--rename' actions interpret non-option + # arguments passed to `centos-art.sh' script in a special way. + # In this configuration, only two non-option arguments are + # used and interpreted from the first loop of their + # interpretation. ${FLAG_BACKEND}_${ACTIONNAM} - # Terminate script execution right here. + # Break interpretation of non-option arguments, to prevent the + # second non-option argument from be considered a source + # location. + break + + elif [[ $ACTIONNAM =~ "^(search(Node|Index)|updateOutputFiles)$" ]];then + + # The two final actions of help functionality are precisely to + # update manual output files and commit all changes from + # working copy to central repository. In this situation, when + # the `--update' action name is provided to `centos-art.sh', + # don't duplicate the rendition of manual output files (e.g., + # one as action name and another as help's normal execution + # flow) nor commit any change form working copy to central + # repository (e.g., output files are not under version + # control). + ${FLAG_BACKEND}_${ACTIONNAM} + + # Terminate script execution right here. Actions realized in + # this configuration doesn't need to update manual output + # files, nor commit changes from working copy up to central + # repository. exit else - # Execute action name on documentation entry. - ${FLAG_BACKEND}_$ACTIONNAM + # Execute action names that follow help's execution flow as it + # is, without any modification. + ${FLAG_BACKEND}_${ACTIONNAM} fi diff --git a/Scripts/Functions/Help/Texinfo/texinfo_copyEntry.sh b/Scripts/Functions/Help/Texinfo/texinfo_copyEntry.sh index 05b0710..1f58f10 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_copyEntry.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_copyEntry.sh @@ -32,47 +32,14 @@ function texinfo_copyEntry { local MANUAL_ENTRY='' local MANUAL_ENTRIES='' - # Define both source and target documentation entries. To build - # the source and target documentation entries we take into - # consideration the manual's main definition file, the chapter's - # main definition file and non-option arguments passed to - # centos-art.sh script through the command-line. + # Execute copying action based on documentation entries passed as + # non-option arguments to `centos-art.sh' script in the + # command-line. if [[ ${MANUAL_SECN[${MANUAL_DOCENTRY_ID}]} != '' ]];then - if [[ ${MANUAL_SECN[((${MANUAL_DOCENTRY_ID} + 1))]} != '' ]];then - - # When the section name is specified both in first and - # second non-option arguments, source and target are set - # as specified in first and second non-option arguments - # respectively. - - # Define documentation entry source's location. - MANUAL_ENTRY_SRC=$(${FLAG_BACKEND}_getEntry ${MANUAL_SECN[${MANUAL_DOCENTRY_ID}]}) - - # Define documentation entry target's location. - MANUAL_ENTRY_DST=$(${FLAG_BACKEND}_getEntry ${MANUAL_SECN[((${MANUAL_DOCENTRY_ID} + 1))]}) - - elif [[ ${MANUAL_SECN[((${MANUAL_DOCENTRY_ID} + 1))]} == '' ]] \ - && [[ ${MANUAL_CHAN[((${MANUAL_DOCENTRY_ID} + 1))]} != '' ]];then - - # When the section name is specified only in the first - # non-option argument and the chapter name has been - # provided in the second non-option argument, use the - # section name passed in first argument to build the - # section name that will be used as target. - - # Define documentation entry source's location. - MANUAL_ENTRY_SRC=$(${FLAG_BACKEND}_getEntry ${MANUAL_SECN[${MANUAL_DOCENTRY_ID}]}) - - # Define documentation entry target's location. - MANUAL_ENTRY_DST=$(echo $MANUAL_ENTRY_SRC \ - | sed -r "s!${MANUAL_CHAN[${MANUAL_DOCENTRY_ID}]}!${MANUAL_CHAN[((${MANUAL_DOCENTRY_ID} + 1))]}!") - - else - cli_printMessage "`gettext "The location provided as target isn't valid."`" --as-error-line - fi - - # Copy documentation entry using source and target locations. + # In this configuration, the section name is specified in + # first non-option argument and optionally in the second + # non-option arugment. ${FLAG_BACKEND}_copyEntrySection elif [[ ${MANUAL_CHAN[${MANUAL_DOCENTRY_ID}]} != '' ]] \ @@ -82,7 +49,7 @@ function texinfo_copyEntry { # neither in first or second non-option argument. So, we # perform a copying action for the chapter directory itself. # In this configuration, the whole chapter directory and all - # the content inside it is duplicated from source to target. + # the content inside are duplicated from source to target. ${FLAG_BACKEND}_copyEntryChapter elif [[ ${MANUAL_DIRN[${MANUAL_DOCENTRY_ID}]} != '' ]] \ diff --git a/Scripts/Functions/Help/Texinfo/texinfo_copyEntryChapter.sh b/Scripts/Functions/Help/Texinfo/texinfo_copyEntryChapter.sh index a0083f8..e38428d 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_copyEntryChapter.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_copyEntryChapter.sh @@ -25,15 +25,11 @@ function texinfo_copyEntryChapter { - # Define documentation entry source's location. - local MANUAL_ENTRY_SRC=${MANUAL_BASEDIR_L10N}/${MANUAL_CHAN[${MANUAL_DOCENTRY_ID}]} + # Redefine documentation entry source's location. + MANUAL_ENTRY_SRC=${MANUAL_BASEDIR_L10N}/${MANUAL_CHAN[${MANUAL_DOCENTRY_ID}]} - # Redefine chapter name using chapter name passed to - # `centos-art.sh' script as second non-option argument. - local MANUAL_CHAPTER_NAME=${MANUAL_CHAN[((${MANUAL_DOCENTRY_ID} + 1))]} - - # Define documentation entry target's location. - local MANUAL_ENTRY_DST=${MANUAL_BASEDIR_L10N}/${MANUAL_CHAN[((${MANUAL_DOCENTRY_ID} + 1))]} + # Redefine documentation entry target's location. + MANUAL_ENTRY_DST=${MANUAL_BASEDIR_L10N}/${MANUAL_CHAN[((${MANUAL_DOCENTRY_ID} + 1))]} # When we are copying chapters, the source location and the target # location must be different in value. They cannot point to the @@ -45,7 +41,7 @@ function texinfo_copyEntryChapter { # When we are copying chapters, document structure actualization # needs to be performed against the target chapter not the source # one used to create the duplication. To achieve this goal, - # redefine both chapter's directory and chapter's name at this + # define both chapter's directory and chapter's name at this # point. local MANUAL_CHAPTER_DIR=$MANUAL_ENTRY_DST local MANUAL_CHAPTER_NAME=${MANUAL_CHAN[((${MANUAL_DOCENTRY_ID} + 1))]} @@ -62,7 +58,7 @@ function texinfo_copyEntryChapter { # copied to target chapter. Don't include chapter main definition # files. local MANUAL_ENTRIES=$(cli_getFilesList $MANUAL_ENTRY_SRC \ - --pattern="${MANUAL_ENTRY_SRC}.*\.${MANUAL_EXTENSION}" \ + --pattern="${MANUAL_ENTRY_SRC}/.+\.${MANUAL_EXTENSION}" \ | egrep -v '/chapter') # Copy sections from source chapter to target chapter. @@ -70,13 +66,13 @@ function texinfo_copyEntryChapter { svn cp $MANUAL_ENTRY $MANUAL_ENTRY_DST --quiet done - # 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, + # Update section menu, nodes and cross reference definitions + # inside target chapter where all section entries were copied to. + ${FLAG_BACKEND}_updateStructureSection "${MANUAL_ENTRY_DST}/.+\.${MANUAL_EXTENSION}" + + # Update chapter menu and node definitions inside the manual + # structure. ${FLAG_BACKEND}_updateChapterMenu ${FLAG_BACKEND}_updateChapterNodes - # and section menu, nodes and cross references later. - ${FLAG_BACKEND}_updateStructureSection ".+\.${MANUAL_EXTENSION}" - } diff --git a/Scripts/Functions/Help/Texinfo/texinfo_copyEntryManual.sh b/Scripts/Functions/Help/Texinfo/texinfo_copyEntryManual.sh index 0088c32..63618f0 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_copyEntryManual.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_copyEntryManual.sh @@ -28,26 +28,26 @@ function texinfo_copyEntryManual { # Define list of chapters inside source manual excluding those # created from template, rendition output and subversion. local MANUAL_CHAPTER='' - local MANUAL_CHAPTERS=$(cli_getFilesList ${MANUAL_BASEDIR} \ + local MANUAL_CHAPTERS=$(cli_getFilesList ${MANUAL_BASEDIR_L10N} \ --maxdepth=1 --mindepth=1 --type="d" --pattern='.+' \ | egrep -v "(Licenses|\.svn|${MANUAL_NAME}-xhtml)$") # Redefine manual name using manual name passed to `centos-art.sh' # script as second non-option argument. - MANUAL_NAME=${MANUAL_SLFN[((${MANUAL_DOCENTRY_ID} + 1))]} + local MANUAL_NAME=${MANUAL_SLFN[((${MANUAL_DOCENTRY_ID} + 1))]} # Redefine absolute path to manual directory using manual name # passed to `centos-art.sh' script as second non-option argument. - MANUAL_BASEDIR="$(echo $MANUAL_BASEDIR \ + local MANUAL_BASEDIR="$(echo $MANUAL_BASEDIR \ | sed -r "s!${MANUAL_DIRN[${MANUAL_DOCENTRY_ID}]}!${MANUAL_DIRN[((${MANUAL_DOCENTRY_ID} + 1))]}!")" # Redefine absolute path to manual directory using manual name # passed to `centos-art.sh' script as second non-option argument. - MANUAL_BASEDIR_L10N="${MANUAL_BASEDIR}/${MANUAL_L10N}" + local MANUAL_BASEDIR_L10N="${MANUAL_BASEDIR}/${MANUAL_L10N}" # Redefine absolute path to base file using manual name passed to # `centos-art.sh' script as second non-option argument. - MANUAL_BASEFILE="${MANUAL_BASEDIR_L10}/${MANUAL_NAME}" + local MANUAL_BASEFILE="${MANUAL_BASEDIR_L10N}/${MANUAL_NAME}" # Create manual structure ${FLAG_BACKEND}_createStructure diff --git a/Scripts/Functions/Help/Texinfo/texinfo_copyEntrySection.sh b/Scripts/Functions/Help/Texinfo/texinfo_copyEntrySection.sh index 1d0eeb5..1fae087 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_copyEntrySection.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_copyEntrySection.sh @@ -25,50 +25,79 @@ function texinfo_copyEntrySection { + # Define absolute path to section source and target locations + # based on non-option arguments passed to `centos-art.sh' script. + if [[ ${MANUAL_SECN[((${MANUAL_DOCENTRY_ID} + 1))]} != '' ]];then + + # When the section name is specified in first and second + # non-option arguments, source and target are set as specified + # in first and second non-option arguments respectively. + MANUAL_ENTRY_SRC=$(${FLAG_BACKEND}_getEntry ${MANUAL_SECN[${MANUAL_DOCENTRY_ID}]}) + MANUAL_ENTRY_DST=$(${FLAG_BACKEND}_getEntry ${MANUAL_SECN[((${MANUAL_DOCENTRY_ID} + 1))]}) + + elif [[ ${MANUAL_SECN[((${MANUAL_DOCENTRY_ID} + 1))]} == '' ]] \ + && [[ ${MANUAL_CHAN[((${MANUAL_DOCENTRY_ID} + 1))]} != '' ]];then + + # When the section name is specified only in the first + # non-option argument and the chapter name has been provided + # in the second non-option argument, use the section name + # passed in first argument to build the section name that will + # be used as target. + MANUAL_ENTRY_SRC=$(${FLAG_BACKEND}_getEntry ${MANUAL_SECN[${MANUAL_DOCENTRY_ID}]}) + MANUAL_ENTRY_DST=$(echo $MANUAL_ENTRY_SRC \ + | sed -r "s!${MANUAL_CHAN[${MANUAL_DOCENTRY_ID}]}!${MANUAL_CHAN[((${MANUAL_DOCENTRY_ID} + 1))]}!") + + else + cli_printMessage "`gettext "The location provided as target isn't valid."`" --as-error-line + fi + # Verify source and target locations to be sure they are different # one another. We cannot copy a source location to itself. if [[ $MANUAL_ENTRY_SRC == $MANUAL_ENTRY_DST ]];then cli_printMessage "`gettext "The source and target locations cannot be the same."`" --as-error-line fi - # Print separator line. + # Print separator line along with action message. cli_printMessage '-' --as-separator-line + cli_printMessage "${MANUAL_ENTRY_DST}" --as-creating-line - # Redefine chapter name using chapter name passed to - # `centos-art.sh' script as second non-option argument. - MANUAL_CHAPTER_NAME=${MANUAL_CHAN[((${MANUAL_DOCENTRY_ID} + 1))]} + # Verify existence of source location. + if [[ ! -a ${MANUAL_ENTRY_SRC} ]];then + cli_printMessage "`gettext "The source location doesn't exist."`" --as-error-line + fi - # Redefine chapter directory to use the chapter provided to - # `centos-art.sh' script as second non-option argument. This is - # required in order to update the `chapter-menu.texinfo' file on - # the target chapter the documentation entry was copied in, not - # the source chapter where the documentation entry was taken from. - # This is particulary useful when a documentation entry is copied - # from one chapter to another different. - MANUAL_CHAPTER_DIR=$(dirname ${MANUAL_ENTRY_DST}) - - # When we copy sections, the chapter directory where the section - # copied will be placed in must exist first. In that sake, verify - # the chapter directory of target documentation entry and if it - # doesn't exist, create it adding it to version control. + # When we copy sections, the target chapter directory where the + # source section will be duplicated in, must exist first. In that + # sake, verify the chapter directory of target section entry and + # if it doesn't exist, create it adding using subversion. if [[ ! -d $(dirname ${MANUAL_ENTRY_DST}) ]];then svn mkdir $(dirname ${MANUAL_ENTRY_DST}) --quiet fi - # Copy documentation entry from source to target using subversion. - if [[ -a ${MANUAL_ENTRY_SRC} ]];then - if [[ ! -a ${MANUAL_ENTRY_DST} ]];then - cli_printMessage "${MANUAL_ENTRY_DST}" --as-creating-line - svn cp "${MANUAL_ENTRY_SRC}" "${MANUAL_ENTRY_DST}" --quiet - else - cli_printMessage "`gettext "The target location is not valid."`" --as-error-line - fi - else - cli_printMessage "`gettext "The source location is not valid."`" --as-error-line + # Verify existence of target location. + if [[ -a ${MANUAL_ENTRY_DST} ]];then + cli_printMessage "`gettext "The target location already exists."`" --as-error-line fi - # At this point, all copying actions had took place and it is time - # to update the document structure. + # Copy section entry from source to target using subversion. + svn cp "${MANUAL_ENTRY_SRC}" "${MANUAL_ENTRY_DST}" --quiet + + # Redefine chapter name using chapter name passed to + # `centos-art.sh' script as second non-option argument. + local MANUAL_CHAPTER_NAME=${MANUAL_CHAN[((${MANUAL_DOCENTRY_ID} + 1))]} + + # Redefine chapter directory to use the chapter provided to + # `centos-art.sh' script as second non-option argument. This is + # required in order to update the `chapter-menu.texinfo' file + # inside the target chapter where section entry was copied to, not + # the source chapter where the section entry was taken from. This + # is particulary useful section entries are copied from one + # chapter into another different. + local MANUAL_CHAPTER_DIR=$(dirname ${MANUAL_ENTRY_DST}) + + # At this point, all copying actions and chapter related + # redefinitions have took place. It is time, then, to update the + # document structure using the information collected so far. ${FLAG_BACKEND}_updateStructureSection "${MANUAL_ENTRY_DST}" } diff --git a/Scripts/Functions/Help/Texinfo/texinfo_createStructure.sh b/Scripts/Functions/Help/Texinfo/texinfo_createStructure.sh index 853ec28..ed0ef99 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_createStructure.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_createStructure.sh @@ -38,13 +38,6 @@ function texinfo_createStructure { cli_printMessage "`gettext "Do you want to continue?"`" --as-yesornorequest-line fi - # Initialize first time created variable. Through this variable it - # is possible to know when the manual has been created for first - # time or not. This variable is used to determine whether to - # relize subversion actions or not against the whole manual - # directory structure. - local MANUAL_FIRSTTIME_CREATED='false' - # Initialize manual's information (e.g., title, subtitle, abstract). local MANUAL_TITLE='' local MANUAL_SUBTITLE='' @@ -54,7 +47,6 @@ function texinfo_createStructure { # the place where all texinfo documentation manuals is stored in. if [[ ! -d ${MANUAL_BASEDIR} ]];then svn mkdir ${MANUAL_BASEDIR} --quiet - MANUAL_FIRSTTIME_CREATED='true' fi # Create manual's base directory. This is the place where @@ -118,12 +110,4 @@ function texinfo_createStructure { # Initialize chapter structure inside the manual. ${FLAG_BACKEND}_createStructureChapters - # Commit changes from working copy to central repository only. At - # this point, changes in the repository are not merged in the - # working copy, but chages in the working copy do are committed up - # to repository. - if [[ ${MANUAL_FIRSTTIME_CREATED} == 'true' ]];then - cli_commitRepoChanges ${MANUAL_BASEDIR} - fi - } diff --git a/Scripts/Functions/Help/Texinfo/texinfo_deleteCrossReferences.sh b/Scripts/Functions/Help/Texinfo/texinfo_deleteCrossReferences.sh index de4539a..6bfb96e 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_deleteCrossReferences.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_deleteCrossReferences.sh @@ -47,7 +47,7 @@ function texinfo_deleteCrossReferences { # Define regular expression patterns for texinfo cross reference # commands. PATTERN[0]="@(pxref|xref|ref)\{(${NODE})\}" - PATTERN[1]="^(\* ${NODE}:(.*)?:(.*)?)$" + REPLACE[0]='--- @strong{'`gettext "Removed"`'}(\1:\2) ---' # Define replacement string for missing entries. It is convenient # to keep missing entries in documentation for documentation team @@ -58,8 +58,8 @@ function texinfo_deleteCrossReferences { # 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) ---' + PATTERN[1]="^(\* ${NODE}:(.*):(.*))$" + REPLACE[1]='\@comment --- '`gettext "Removed"`'(\1) ---' # Define list of entries to process. local MANUAL_ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR_L10N} \ diff --git a/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryChapter.sh b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryChapter.sh index 9ffa534..2bcd286 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryChapter.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryChapter.sh @@ -26,11 +26,11 @@ function texinfo_deleteEntryChapter { # Print action message. - cli_printMessage "$MANUAL_ENTRY" --as-deleting-line + cli_printMessage "$MANUAL_CHAPTER_DIR" --as-deleting-line # Verify existence of documentation entry before deleting it. We # cannot delete an entry which doesn't exist. - cli_checkFiles "$MANUAL_ENTRY" + cli_checkFiles "$MANUAL_CHAPTER_DIR" # Build list of section entries inside the chapter. This is # required to delete cross references from other section entries diff --git a/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh index b15375e..749752e 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_deleteEntryManual.sh @@ -48,26 +48,8 @@ function texinfo_deleteEntryManual { if [[ $(ls -1 $MANUAL_BASEDIR | wc -l) -le 1 ]];then # Remove manual base directory. - svn del ${MANUAL_BASEDIR} --quiet - - # Commit changes from working copy to central repository only. - # At this point, changes in the repository are not merged in - # the working copy, but chages in the working copy do are - # committed up to repository. - cli_commitRepoChanges ${MANUAL_BASEDIR} - - else - - # Commit changes from working copy to central repository only. - # At this point, changes in the repository are not merged in - # the working copy, but chages in the working copy do are - # committed up to repository. - cli_commitRepoChanges ${MANUAL_BASEDIR_L10N} + svn del ${MANUAL_BASEDIR} --quiet --force fi - # Terminate script execution here. The documentation manual has - # been removed and there is nothing else to do here. - exit - } diff --git a/Scripts/Functions/Help/Texinfo/texinfo_getNode.sh b/Scripts/Functions/Help/Texinfo/texinfo_getNode.sh index ac2a74d..2c43c39 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_getNode.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_getNode.sh @@ -36,7 +36,8 @@ function texinfo_getNode { # Define node from documentation entry. local NODE=$(echo "$MANUAL_ENTRY" | sed -r \ -e "s!^${MANUAL_BASEDIR_L10N}/!!" \ - -e "s/(chapter-intro\.${MANUAL_EXTENSION}|\.${MANUAL_EXTENSION})$//" \ + -e "s/\.${MANUAL_EXTENSION}$//" \ + -e "s/chapter//" \ -e 's!(/|-)! !g' \ -e 's! ([[:alpha:]])! \u\1!g' \ -e 's!^[[:space:]]+!!') diff --git a/Scripts/Functions/Help/Texinfo/texinfo_renameCrossReferences.sh b/Scripts/Functions/Help/Texinfo/texinfo_renameCrossReferences.sh index 25b6229..d43fd01 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_renameCrossReferences.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_renameCrossReferences.sh @@ -1,8 +1,8 @@ #!/bin/bash # -# texinfo_renameCrossReferences.sh -- This function replaces a node -# pattern with a node replacement and updates cross-reference -# definitions to reflect the changes. +# texinfo_renameCrossReferences.sh -- This function renames menu, +# nodes and cross references related to chapters and sections that +# have been renamed previously. # # Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG # @@ -26,47 +26,57 @@ function texinfo_renameCrossReferences { - local MANUAL_ENTRY_SRC=$(${FLAG_BACKEND}_getEntry "$1") - local MANUAL_ENTRY_DST=$(${FLAG_BACKEND}_getEntry "$2") + local -a PATTERN + local -a REPLACE - # Define node pattern for source documenation entry. - local NODE_SRC=$(${FLAG_BACKEND}_getNode "$MANUAL_ENTRY_SRC") + # Build source and target node definitions. + local NODE_SRC="$(${FLAG_BACKEND}_getNode "$MANUAL_ENTRY_SRC")" + local NODE_DST="$(${FLAG_BACKEND}_getNode "$MANUAL_ENTRY_DST")" - # Define node replacement for target documentation entry. - local NODE_DST=$(${FLAG_BACKEND}_getNode "$MANUAL_ENTRY_DST") + # Define regular expression pattern and its replacement for node + # definitions that have been previously removed. + PATTERN[0]="--- @strong\{`gettext "Removed"`\}\((pxref|xref|ref):\<${NODE_SRC}\>(.*)\) ---" + REPLACE[0]="\@\1{${NODE_DST}\2}" - # Define list of entries to process. + # Define regular expression pattern and its replacement for menu + # definitions that have been previously removed. + PATTERN[1]="^@comment --- `gettext "Removed"`\(\* \<${NODE_SRC}\>(.*)\) ---$" + REPLACE[1]="* ${NODE_DST}\1" + + # Define list of entries to process. This is, all the texinfo + # source files the documentation manual is made of. local MANUAL_ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR_L10N} \ --pattern=".+\.${MANUAL_EXTENSION}") - # Update node-related cross-references. The node-related cross - # reference definition, long ones specially, could require more - # than one line to be set. By default, GNU sed does not matches - # newline characters in the pattern space, so we need to make use - # of `label' feature and the `N' command in order to build a - # pattern space that includes the newline character in it. Here we - # use the `a' letter to name the label we use, followed by N - # command to add a newline to the pattern space, the s command to - # make the pattern replacement using the `g' flag to make it - # global and finaly the command `b' to branch label named `a'. + # Update node cross references. The node-related cross reference + # definition, long ones specially, could require more than one + # line to be set. By default, GNU sed does not matches newline + # characters in the pattern space, so we need to make use of + # `label' feature and the `N' command in order to build a pattern + # space that includes the newline character in it. Here we use the + # `a' letter to name the label we use, followed by N command to + # add a newline to the pattern space, the s command to make the + # pattern replacement using the `g' flag to make it global and + # finaly the command `b' to branch label named `a'. # # Inside the pattern space, the `\<' and `\>' are used to restrict # the match pattern to a word boundary. The word boundary # restriction applied here is required to avoid undesired # replacements when we replace singular words with their plurals. - # For example, if we need to change the word `Manual' to its + # For example, if we need to change the node `Manual' to its # plular (i.e., `Manuals'), and no boundary restriction is used in - # the pattern space to do that, we might end up having words like - # `Manualsssss'. This is because this sed command might be applied - # to the same file many times; and each time it is applied a new - # `Manuals' replaces the previous `Manuals' replacement to form - # `Manualss', `Manualsss', and so on for each interaction. - sed -r -i ":a;N;s!\<${NODE_SRC}\>!${NODE_DST}!g;ba" ${MANUAL_ENTRIES} + # the pattern space to do that, we might end up having nodes like + # `Manualsssss' which probably doesn't exist. This is because this + # sed command might be applied to the same file more than once; + # and each time it is applied, a new `Manuals' replaces the + # previous `Manuals' replacement to form `Manualss', `Manualsss', + # and so on for each interaction. Using word boundaries + # restrictions prevent such issue from happening. + sed -r -i ":a;N;s!${PATTERN[0]}!${REPLACE[0]}!g;ba" ${MANUAL_ENTRIES} - # At this point, source documentation entry has been renamed from - # source to target documentation entry, but they are still - # commented. So, uncomment them restoring target documentation - # entries. - ${FLAG_BACKEND}_restoreCrossReferences "${MANUAL_ENTRY_DST}" + # Update menu cross references. Menu cross reference definitions + # hardly appear in more than one line, so there is no need to + # complicate the replacement command. + sed -r -i "s!${PATTERN[1]}!${REPLACE[1]}!" ${MANUAL_ENTRIES} } diff --git a/Scripts/Functions/Help/Texinfo/texinfo_renameEntry.sh b/Scripts/Functions/Help/Texinfo/texinfo_renameEntry.sh index 09fff4a..6fd22d9 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_renameEntry.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_renameEntry.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# texinfo_renameEntry.sh -- This function renames documentation entries -# and updates documentation structure to reflect changes. +# texinfo_renameEntry.sh -- This function standardizes renaming tasks +# related to manual, chapters and sections inside the working copy. # # Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG # @@ -25,18 +25,49 @@ function texinfo_renameEntry { - # Copy source documentation entry. - ${FLAG_BACKEND}_copyEntry "$1" "$2" + # Initialize source and target locations. + local MANUAL_ENTRY_SRC='' + local MANUAL_ENTRY_DST='' - # Delete source documentation entry. The source documentation - # entry has been copied already, so to create the rename effect - # delete it from repository filesystem. - ${FLAG_BACKEND}_deleteEntry "$1" + # Define both source and target documentation entries. To build + # the source and target documentation entries we take into + # consideration the manual's main definition file, the chapter's + # main definition file and non-option arguments passed to + # centos-art.sh script through the command-line. + if [[ ${MANUAL_SECN[${MANUAL_DOCENTRY_ID}]} != '' ]];then - # At this point, source documentation entry has been removed and - # all menu, nodes and cross-references have been commented. So, - # replace commented menu, nodes and cross-reference information - # from source to target documentation entry. - ${FLAG_BACKEND}_renameCrossReferences "$1" "$2" + # When a section is renamed, the section source location is + # duplicated into the section target location and later + # removed from the working copy. Once the section source + # location has been renamed, the section menu, nodes and cross + # references are updated to keep consistency inside the + # manual. + ${FLAG_BACKEND}_renameEntrySection + + elif [[ ${MANUAL_CHAN[$MANUAL_DOCENTRY_ID]} != '' ]] \ + && [[ ${MANUAL_CHAN[(($MANUAL_DOCENTRY_ID + 1))]} != '' ]];then + + # When a chapter is renamed, the chapter source location is + # duplicated into the chapter source location and later + # removed from the working copy. Once the chapter source + # location has been renamed, the chapter and section menu, + # nodes and cross references are updated to keep consistency + # inside the manual. + ${FLAG_BACKEND}_renameEntryChapter + + elif [[ ${MANUAL_DIRN[$MANUAL_DOCENTRY_ID]} != '' ]] \ + && [[ ${MANUAL_DIRN[(($MANUAL_DOCENTRY_ID + 1))]} != '' ]] ;then + + # When a manual is renamed, a new manual structure is created + # in the manual target location and all chapters and sections + # are duplicated from manual source location to manual target + # location. Once the source manual has been renamed, chapter + # and section menu, nodes and cross references are updated to + # keep consistency inside the manual. + ${FLAG_BACKEND}_renameEntryManual + + else + cli_printMessage "`gettext "The parameters you provided are not supported."`" --as-error-line + fi } diff --git a/Scripts/Functions/Help/Texinfo/texinfo_renameEntryChapter.sh b/Scripts/Functions/Help/Texinfo/texinfo_renameEntryChapter.sh new file mode 100755 index 0000000..c40115c --- /dev/null +++ b/Scripts/Functions/Help/Texinfo/texinfo_renameEntryChapter.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# texinfo_renameEntryChapter.sh -- This function standardizes renaming +# tasks related to manual chapters inside documentation manuals +# written in texinfo format. +# +# 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_renameEntryChapter { + + # Copy section source entry to target location. + ${FLAG_BACKEND}_copyEntryChapter + + # Delete section source entry. + ${FLAG_BACKEND}_deleteEntryChapter + + # Rename menu, nodes and cross references related entries. + ${FLAG_BACKEND}_renameCrossReferences + +} diff --git a/Scripts/Functions/Help/Texinfo/texinfo_renameEntryManual.sh b/Scripts/Functions/Help/Texinfo/texinfo_renameEntryManual.sh new file mode 100755 index 0000000..3ad77e9 --- /dev/null +++ b/Scripts/Functions/Help/Texinfo/texinfo_renameEntryManual.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# +# texinfo_renameEntryManual.sh -- This function standardizes renaming +# tasks related to documenation manuals written in texinfo format +# inside the working copy. +# +# 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_renameEntryManual { + + # Copy section source entry to target location. + ${FLAG_BACKEND}_copyEntryManual + + # Delete section source entry. + ${FLAG_BACKEND}_deleteEntryManual + + # From this time on, the manual information set so far is no + # longer useful. Redefine it to start using the new manual + # information instead. + + # Redefine manual name using manual name passed to `centos-art.sh' + # script as second non-option argument. + MANUAL_NAME=${MANUAL_SLFN[((${MANUAL_DOCENTRY_ID} + 1))]} + + # Redefine absolute path to manual directory using manual name + # passed to `centos-art.sh' script as second non-option argument. + MANUAL_BASEDIR="$(echo $MANUAL_BASEDIR \ + | sed -r "s!${MANUAL_DIRN[${MANUAL_DOCENTRY_ID}]}!${MANUAL_DIRN[((${MANUAL_DOCENTRY_ID} + 1))]}!")" + + # Redefine absolute path to manual directory using manual name + # passed to `centos-art.sh' script as second non-option argument. + MANUAL_BASEDIR_L10N="${MANUAL_BASEDIR}/${MANUAL_L10N}" + + # Redefine absolute path to base file using manual name passed to + # `centos-art.sh' script as second non-option argument. + MANUAL_BASEFILE="${MANUAL_BASEDIR_L10N}/${MANUAL_NAME}" + +} diff --git a/Scripts/Functions/Help/Texinfo/texinfo_renameEntrySection.sh b/Scripts/Functions/Help/Texinfo/texinfo_renameEntrySection.sh new file mode 100755 index 0000000..b713e51 --- /dev/null +++ b/Scripts/Functions/Help/Texinfo/texinfo_renameEntrySection.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# +# texinfo_renameEntrySection.sh -- This function standardizes renaming +# tasks related to chapter sections inside documentation manuals +# written in texinfo format. +# +# 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_renameEntrySection { + + # Copy section source entry to target location. + ${FLAG_BACKEND}_copyEntrySection + + # Delete section source entry. + ${FLAG_BACKEND}_deleteEntrySection + + # Rename menu, nodes and cross references related entries. + ${FLAG_BACKEND}_renameCrossReferences + +} diff --git a/Scripts/Functions/Help/Texinfo/texinfo_searchNode.sh b/Scripts/Functions/Help/Texinfo/texinfo_searchNode.sh index 1651783..1467e79 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_searchNode.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_searchNode.sh @@ -36,7 +36,7 @@ function texinfo_searchNode { # file at the specified node for reading it on the terminal. # Otherwise, ask the user to create it. if [[ -f "$MANUAL_ENTRY" ]];then - /usr/bin/info --node="$(${FLAG_BACKEND}_getNode "$MANUAL_ENTRY")" --file=${MANUAL_BASEFILE}.info.bz2 + info --node="$(${FLAG_BACKEND}_getNode "$MANUAL_ENTRY")" --file=${MANUAL_BASEFILE}.info.bz2 else ${FLAG_BACKEND}_editEntry fi diff --git a/Scripts/Functions/Help/Texinfo/texinfo_updateOutputFiles.sh b/Scripts/Functions/Help/Texinfo/texinfo_updateOutputFiles.sh index fe06a80..c494cc9 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_updateOutputFiles.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_updateOutputFiles.sh @@ -25,6 +25,13 @@ function texinfo_updateOutputFiles { + # Verify manual base file. We can update manual outputs only if + # its base file exists. For example, we cannot update manual + # outputs if the manual has been deleted previously. + if [[ ! -a ${MANUAL_BASEFILE}.${MANUAL_EXTENSION} ]];then + return + fi + # Print separator line. cli_printMessage '-' --as-separator-line diff --git a/Scripts/Functions/Help/Texinfo/texinfo_updateStructureSection.sh b/Scripts/Functions/Help/Texinfo/texinfo_updateStructureSection.sh index e722c9f..b411024 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_updateStructureSection.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_updateStructureSection.sh @@ -40,6 +40,43 @@ function texinfo_updateStructureSection { PATTERN=".+\.${MANUAL_EXTENSION}" fi + # Define manual entries based on pattern. + if [[ -a $PATTERN ]];then + + # Define list of target documentation entries using find's + # regular expression pattern as reference. Notice that, when + # wer update section definition files, the files already exist + # in the working copy so the pattern can be its absolute path + # without any problem. If the pattern is built correctly, it + # will match the location and so be returned to build the list + # of entries to process. Notice also that, when updating, it + # is possible to use a regular expression to match more than + # one location and build the list of entries based on such + # matching. In this last configuration, let you to update + # menu, nodes and cross references to many section definitions + # (i.e., all those section definition file that match the + # pattern you specified). + MANUAL_ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR_L10N} \ + --pattern="$PATTERN" | egrep -v "/(${MANUAL_NAME}|chapter)") + + else + + # Define list of target documentation entries using pattern as + # reference. When we delete a section entry from the working + # copy, using find to retrive its path isn't useful because + # the section definition file has been already removed from + # the working copy and even the regex pattern be correctly + # formed, the file doesn't exist and by consequence no match + # is found. This issue provokes no section entry to be + # removed from menu, nodes and cross references. In order to + # solve this, use the pattern value as list of target entries. + # Notice that, in this case, the pattern value must be the + # absolute path of that section entry removed we want to + # update menu, nodes and cross references information for. + MANUAL_ENTRIES=$PATTERN + + fi + # Define action to perform on definitions. case "$2" in @@ -70,30 +107,8 @@ function texinfo_updateStructureSection { # well. ACTIONNAM_CROSREF='restoreCrossReferences' ;; - esac - - # Define list of target documentation entries using find's regular - # expression pattern as reference. This is required in order to - # process non-existent documentation entries (e.g., when they are - # created for first time). Otherwise, the list of documentation - # entries will be empty an no entry would be processed. - if [[ ${PATTERN} =~ '^/.+\.texinfo$' ]];then - # When the pattern value is an absolute path to a - # documentation entry, use that value as only documentation - # entry in the list. - MANUAL_ENTRIES=${PATTERN} - - else - - # When the pattern value is a regular expression, use - # cli_getFilesList to build the list of documentation entries - # using it. Don't include manual or chapter definition files - # in this list, it would create documentation entries for them - # and that shouldn't happen. - MANUAL_ENTRIES=$(cli_getFilesList ${MANUAL_BASEDIR} \ - --pattern="$PATTERN" | egrep -v "/(${MANUAL_NAME}|chapter)") - fi + esac # Print action message. cli_printMessage "`gettext "Updating section menus, nodes and cross references."`" --as-response-line @@ -107,4 +122,5 @@ function texinfo_updateStructureSection { ${FLAG_BACKEND}_updateSectionNodes ${FLAG_BACKEND}_${ACTIONNAM_CROSREF} ${MANUAL_ENTRY} done + } diff --git a/Scripts/Functions/Help/help.sh b/Scripts/Functions/Help/help.sh index ce6ede8..27cf402 100755 --- a/Scripts/Functions/Help/help.sh +++ b/Scripts/Functions/Help/help.sh @@ -74,6 +74,11 @@ function help { # Interpret option arguments passed through the command-line. ${FUNCNAM}_getOptions + # Syncronize changes between repository and working copy. At this + # point, changes in the repository are merged in the working copy + # and changes in the working copy committed up to repository. + cli_syncroRepoChanges ${MANUAL_TLDIR} + # Redefine arrays related to documentation entries using # non-option arguments passed through the command-line. At this # point all options have been removed from ARGUMENTS and @@ -122,20 +127,6 @@ function help { # Define section name. MANUAL_SECTION_NAME=${MANUAL_SECN[${MANUAL_DOCENTRY_ID}]} - # Syncronize changes between repository and working copy. At - # this point, changes in the repository are merged in the - # working copy and changes in the working copy committed up to - # repository. Notice that, because we are processing - # non-option arguments one by one, there is no need to - # sycronize changes to the same manual time after time - # (assuming all documentation entries passed as non-option - # arguments refer the same manual directory name). - if [[ ${MANUAL_DOCENTRY_ID} -eq 0 \ - || ( ( ${MANUAL_DOCENTRY_ID} -gt 0 ) && ( \ - ${MANUAL_DIRN[${MANUAL_DOCENTRY_ID}]} != ${MANUAL_DIRN[((${MANUAL_DOCENTRY_ID} - 1))]} ) ) ]];then - cli_syncroRepoChanges ${MANUAL_BASEDIR} - fi - # Execute backend-specific documentation tasks. ${FLAG_BACKEND} @@ -151,6 +142,6 @@ function help { # this point, changes in the repository are not merged in the # working copy, but chages in the working copy do are committed up # to repository. - cli_commitRepoChanges ${MANUAL_BASEDIR} + cli_commitRepoChanges ${MANUAL_TLDIR} }