diff --git a/Scripts/Functions/Help/Texinfo/texinfo_createChapter.sh b/Scripts/Functions/Help/Texinfo/texinfo_createChapter.sh index f0b5645..2f1c2a2 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_createChapter.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_createChapter.sh @@ -1,7 +1,7 @@ #!/bin/bash # -# texinfo_createChapter.sh -- This function creates manual's chapters -# based on templates. +# texinfo_createChapter.sh -- This function standardizes chapter +# creation insdie the manual structure. # # Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG # @@ -25,11 +25,11 @@ function texinfo_createChapter { - # Verify chapter's directory inside the manual. The chapter's - # directory is where chapter-specific information (e.g., manual's - # sections) are stored in. If this directory already exist, - # assume it was created correctly in the past. Otherwise, prompt - # its creation. + # Verify chapter directory inside the manual structure. The + # chapter directory is where chapter-specific information (e.g., + # chapter definition files and sections) are stored in. If this + # directory already exist, assume it was created correctly in the + # past. Otherwise, request confirmation for creating it. if [[ -d $MANUAL_CHAPTER_DIR ]];then return else @@ -38,60 +38,62 @@ function texinfo_createChapter { cli_printMessage "`gettext "Do you want to continue?"`" --as-yesornorequest-line fi + # Initialize chapter node, chapter index and chapter title. local MANUAL_CHAPTER_NODE='' local MANUAL_CHAPTER_TITLE='' local MANUAL_CHAPTER_CIND='' - # Define chapter title asking user for it. + # Request the user to enter a chapter title. cli_printMessage "`gettext "Chapter Title"`" --as-request-line read MANUAL_CHAPTER_TITLE - # Define chapter node using chapter name as reference. + # Sanitate chapter node, chapter index and chapter title. MANUAL_CHAPTER_NODE=$(${FLAG_BACKEND}_getEntryNode "$MANUAL_CHAPTER_NAME") - - # Define chapter title based value entered and the style provided. + MANUAL_CHAPTER_CIND=$(${FLAG_BACKEND}_getEntryIndex "$MANUAL_CHAPTER_TITLE") MANUAL_CHAPTER_TITLE=$(${FLAG_BACKEND}_getEntryTitle "$MANUAL_CHAPTER_TITLE") - # Define chapter concept index using chapter node as reference. - MANUAL_CHAPTER_CINDX=$(${FLAG_BACKEND}_getEntryIndex "$MANUAL_CHAPTER_NODE") - # Print action message. cli_printMessage "-" --as-separator-line cli_printMessage "`gettext "Creating chapter files."`" --as-response-line - # Define list of template files used to build chapter's main + # Define list of template files used to build the chapter main # definition files. local FILE='' local FILES=$(cli_getFilesList "${MANUAL_TEMPLATE_L10N}/Chapters" \ --maxdepth='1' \ --pattern="chapter(-menu|-nodes)?\.${MANUAL_EXTENSION}") - # Create chapter's directory using subversion. This is the place + # Create chapter directory using subversion. This is the place # where all chapter-specific files will be stored in. if [[ ! -d ${MANUAL_CHAPTER_DIR} ]];then svn mkdir ${MANUAL_CHAPTER_DIR} --quiet fi - # Create chapter's files using template files as reference. + # Create chapter-specific files using template files as reference. for FILE in $FILES;do - # Verify texinfo templates used as based to build the chapter. - # Be sure they are inside the working copy of CentOS Artwork - # Repository (-w) and under version control (-n), too. + # Verify texinfo templates used as based to build the chapter + # structure. Be sure they are inside the working copy of + # The CentOS Artwork Repository (-w) and under version control + # (-n), too. cli_checkFiles ${FILE} -wn - # Copy template files into chapter's directory. + # Copy template files into the chapter directory. svn cp ${FILE} ${MANUAL_CHAPTER_DIR} --quiet done - # Expand translation markers inside chapter's main definition - # file. Before expanding chapter information, be sure the slash - # (/) character be scaped. Otherwise, if the slashes aren't scape, - # they will be interpreted as sed's separator and provoke sed to - # fail. + # Before expanding chapter information, be sure the slash (/) + # character be scaped. Otherwise, if the slashes aren't scape, + # they will be interpreted as sed's separator and might provoke + # sed to complain. + MANUAL_CHAPTER_NODE=$(echo "$MANUAL_CHAPTER_NODE" | sed -r 's/\//\\\//g') + MANUAL_CHAPTER_CIND=$(echo "$MANUAL_CHAPTER_CIND" | sed -r 's/\//\\\//g') + MANUAL_CHAPTER_TITLE=$(echo "$MANUAL_CHAPTER_TITLE" | sed -r 's/\//\\\//g') + MANUAL_CHAPTER_NAME=$(echo "$MANUAL_CHAPTER_NAME" | sed -r 's/\//\\\//g') + + # Expand translation markers inside chapter main definition file. sed -i -r \ - -e 's/ \// \\\//g' \ -e "s/=CHAPTER_NODE=/${MANUAL_CHAPTER_NODE}/" \ -e "s/=CHAPTER_TITLE=/${MANUAL_CHAPTER_TITLE}/" \ -e "s/=CHAPTER_CIND=/${MANUAL_CHAPTER_CIND}/" \ diff --git a/Scripts/Functions/Help/Texinfo/texinfo_createStructure.sh b/Scripts/Functions/Help/Texinfo/texinfo_createStructure.sh index ed0ef99..4840ea9 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_createStructure.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_createStructure.sh @@ -94,7 +94,7 @@ function texinfo_createStructure { # Copy using subversion to register this action. svn cp ${FILE} ${DST} --quiet - + # Expand common translation markers inside target file. cli_expandTMarkers ${DST} @@ -110,4 +110,7 @@ function texinfo_createStructure { # Initialize chapter structure inside the manual. ${FLAG_BACKEND}_createStructureChapters + # Redefine absolute path to changed directory. + MANUAL_CHANGED_DIRS=${MANUAL_BASEDIR} + } diff --git a/Scripts/Functions/Help/Texinfo/texinfo_getEntryIndex.sh b/Scripts/Functions/Help/Texinfo/texinfo_getEntryIndex.sh new file mode 100755 index 0000000..aedf3bc --- /dev/null +++ b/Scripts/Functions/Help/Texinfo/texinfo_getEntryIndex.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# texinfo_getEntryTitle.sh -- This function standardizes the way +# values for chapter and section index definitions are printed out. +# +# 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_getEntryIndex { + + # Initialize phrase we want to transform based on style provided. + local PHRASE="$1" + + # In the entire phrase provided, capitalize the first word only. + PHRASE=$(echo "${PHRASE}" | tr '[:upper:]' '[:lower:]' \ + | sed -r 's!^([[:alpha:]])!\u\1!') + + # Output transformed phrase. + echo "$PHRASE" + +} + diff --git a/Scripts/Functions/Help/Texinfo/texinfo_getEntryTitle.sh b/Scripts/Functions/Help/Texinfo/texinfo_getEntryTitle.sh new file mode 100755 index 0000000..d438e77 --- /dev/null +++ b/Scripts/Functions/Help/Texinfo/texinfo_getEntryTitle.sh @@ -0,0 +1,61 @@ +#!/bin/bash +# +# texinfo_getEntryTitle.sh -- This function standardizes the way entry +# titles for chapters and sections are printed out. +# +# 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_getEntryTitle { + + # Initialize phrase we want to transform based on style provided. + local PHRASE="$1" + + # Verify style provided through `--style' option and transform + # the phrase value in accordance with it. + if [[ $FLAG_STYLE == 'cap-first-only' ]];then + + # In the entire phrase provided, capitalize the first word + # only. + PHRASE=$(echo "${PHRASE}" | tr '[:upper:]' '[:lower:]' \ + | sed -r 's!^([[:alpha:]])!\u\1!') + + elif [[ $FLAG_STYLE == 'directory' ]];then + + # In the entire phrase provided, concatenate all words with + # slash (/) character and remark the fact it is a directory. + PHRASE=$(echo "${PHRASE}" | sed -r \ + -e 's/^(Trunk|Branches|Tags)/\l\1/' \ + -e 's/ /\//g') + + PHRASE="`eval_gettext "The @file{$PHRASE} Directory"`" + + else + + # In the entire phrase provided, capitalize all words. + PHRASE=$(echo "${PHRASE}" | tr '[:upper:]' '[:lower:]' \ + | sed -r 's!\<([[:alpha:]]+)\>!\u\1!g') + + fi + + # Output transformed phrase. + echo "$PHRASE" + +} diff --git a/Scripts/Functions/Help/Texinfo/texinfo_updateSectionNodes.sh b/Scripts/Functions/Help/Texinfo/texinfo_updateSectionNodes.sh index 5ab4c19..d5d5106 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_updateSectionNodes.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_updateSectionNodes.sh @@ -35,10 +35,13 @@ function texinfo_updateSectionNodes { # Build chapter nodes based on chapter menu. for NODE in $NODES;do - NODE=$(echo "${NODE}" | sed -r 's!:! !g') - INCL=$(echo "${NODE}" | sed -r 's! !/!' | sed -r 's! !-!g' | sed -r 's!/(.+)!/\L\1!').${MANUAL_EXTENSION} - SECT=$(echo "${NODE}" | cut -d' ' -f2- ) - CIND=$(echo "${SECT}" | sed -r 's!^([[:alpha:]]+) (.+)!\u\1 \L\2!') + local NODE=$(echo "${NODE}" | sed -r 's!:! !g') + local INCL=$(echo "${NODE}" | sed -r 's! !/!' | sed -r 's! !-!g' | sed -r 's!/(.+)!/\L\1!').${MANUAL_EXTENSION} + local SECT=$(echo "${NODE}" | cut -d' ' -f2- ) + local CIND=$(${FLAG_BACKEND}_getEntryIndex "$SECT") + + # Redefine section value based on style provided. + SECT=$(${FLAG_BACKEND}_getEntryTitle "$SECT") # Create texinfo section file using templates, only if the # section file doesn't exist and hasn't been marked for @@ -123,25 +126,32 @@ function texinfo_updateSectionNodes { -e '0,/^@cindex/c@cindex =CIND=' \ "${MANUAL_BASEDIR_L10N}/$INCL" - # Expand noce, section and concept index translation + # Before expading node, section and concept index, be sure + # that all slash characters (`/') be escaped. Otherwise, they + # might be interpreted as separators and that isn't + # desireable in anyway. + NODE=$(echo "$NODE" | sed -r 's/\//\\\//g') + SECT=$(echo "$SECT" | sed -r 's/\//\\\//g') + CIND=$(echo "$CIND" | sed -r 's/\//\\\//g') + + # Expand node, section and concept index translation # markers in documentation entry. sed -i -r \ - -e "s!=NODE=!${NODE}!g" \ - -e "s!=SECT=!${SECT}!g" \ - -e "s!=CIND=!${CIND}!g" \ + -e "s/=NODE=/${NODE}/g" \ + -e "s/=SECT=/${SECT}/g" \ + -e "s/=CIND=/${CIND}/g" \ "${MANUAL_BASEDIR_L10N}/$INCL" - # Verify existence of chapter-nodes template files. If no + # Verify existence of chapter-nodes template file. If no # chapter-nodes template is found, stop script execution with # an error message. We cannot continue without it. cli_checkFiles ${MANUAL_TEMPLATE_L10N}/Chapters/chapter-nodes.${MANUAL_EXTENSION} - # Output node information chapter-nodes template file using - # the current texinfo menu information. + # Expand chapter node inclusion definition. cat ${MANUAL_TEMPLATE_L10N}/Chapters/chapter-nodes.${MANUAL_EXTENSION} \ | sed -r "s!=INCL=!${INCL}!g" - # Dump node definitions into document structure. + # Dump chapter node definition into manual structure. done > $MANUAL_CHAPTER_DIR/chapter-nodes.${MANUAL_EXTENSION} } diff --git a/Scripts/Functions/Help/help.sh b/Scripts/Functions/Help/help.sh index ae86c58..c8c9e32 100755 --- a/Scripts/Functions/Help/help.sh +++ b/Scripts/Functions/Help/help.sh @@ -37,6 +37,13 @@ function help { # documentation backed used to perform documentation actions. local FLAG_BACKEND='texinfo' + # Initialize the style flag (`--style'). This option lets you to + # create chapters and sections in predefined ways. By default, + # both chapter and section names are printed with each word + # capitalized (e.g., `cap-each-word'). Other values to this option + # are `cap-first-only' and `directory'. + local FLAG_STYLE='cap-each-word' + # Initialize manual's language. local MANUAL_L10N=$(cli_getCurrentLocale) @@ -157,10 +164,9 @@ function help { # Rebuild output files to propagate recent changes. ${FLAG_BACKEND}_updateOutputFiles - # 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_CHANGED_DIRS} + # 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_CHANGED_DIRS} } diff --git a/Scripts/Functions/Help/help_getOptions.sh b/Scripts/Functions/Help/help_getOptions.sh index a67ecc8..5647eb7 100755 --- a/Scripts/Functions/Help/help_getOptions.sh +++ b/Scripts/Functions/Help/help_getOptions.sh @@ -30,7 +30,7 @@ function help_getOptions { local ARGSS="" # Define long options we want to support. - local ARGSL="quiet,answer-yes,dont-commit-changes,backend:,read,search:,edit,update,copy,delete,rename" + local ARGSL="quiet,answer-yes,dont-commit-changes,backend:,read,search:,edit,update,copy,delete,rename,style:" # Parse arguments using getopt(1) command parser. cli_parseArguments @@ -103,6 +103,11 @@ function help_getOptions { ACTIONNAM="searchNode" shift 1 ;; + + --style ) + FLAG_STYLE="$2" + shift 2 + ;; -- ) # Remove the `--' argument from the list of arguments