diff --git a/Scripts/Functions/Help/Config/manual-section-functions.texi b/Scripts/Functions/Help/Config/manual-section-functions.texi new file mode 100644 index 0000000..5f76133 --- /dev/null +++ b/Scripts/Functions/Help/Config/manual-section-functions.texi @@ -0,0 +1,35 @@ +@subheading Name + +@dots{} + +@subheading Synopsis + +@dots{} + +@subheading Description + +@dots{} + +@subheading Examples + +@dots{} + +@subheading Author + +Written by @dots{} + +@subheading Reporting bugs + +Report bugs to @email{centos-artwork@@centos.org} mailing list. + +@subheading Copyright + +Copyright @copyright{} 2009, 2010, 2011 =COPYRIGHT_HOLDER= + +This is free software. You may redistribute copies of it under the +terms of the GNU General Public License (@pxref{GNU General Public +License}). There is NO WARRANTY, to the extent permitted by law. + +@subheading See also + +=TEXINFO_SEEALSO= diff --git a/Scripts/Functions/Help/help_doTexinfoSeealso.sh b/Scripts/Functions/Help/help_doTexinfoSeealso.sh new file mode 100755 index 0000000..87cbe09 --- /dev/null +++ b/Scripts/Functions/Help/help_doTexinfoSeealso.sh @@ -0,0 +1,70 @@ +#!/bin/bash +# +# help_doTexinfoSeealso.sh -- This function creates an itemized list +# of links to refer parent documentation entries. This list of links +# is expanded wherever the =TEXINFO_SEEALSO= translation marker be +# placed in the documentation entry. +# +# Copyright (C) 2009, 2010, 2011 The CentOS Project +# +# 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 help_doTexinfoSeealso { + + local FILE="$1" + local NODE="$2" + local NODECOMP='' + local NODECOMPS_TOTAL='' + local -a NODECOMPS + local SEEALSO_LIST='' + + # Stript out the node information in order to retrive its + # components individually. + for NODECOMP in $(echo $NODE);do + NODECOMPS[((++${#NODECOMPS[*]}))]=$NODECOMP + done + + # Define how many components does the node have. + local NODECOMPS_TOTAL=$((${#NODECOMPS[*]})) + + # Define the list content. This list should contain all the parent + # documentation entries under the same chapter, using the current + # documentation entry as reference. Assuming no parent directory + # exist for the current documentation entry, print just one item + # with three dots as content so as to let the user deside what the + # most appropriate content for this section would be. + if [[ $NODECOMPS_TOTAL -gt 2 ]];then + SEEALSO_LIST=$(\ + until [[ ${NODECOMPS_TOTAL} -eq 2 ]];do + echo "@item @ref{$NODE" \ + | cut -d ' ' -f-"$NODECOMPS_TOTAL" \ + | sed -r -e 's!^[:space:]*!\\n!' -e 's!$!}!'; + NODECOMPS_TOTAL=$(($NODECOMPS_TOTAL - 1)) + done) + else + SEEALSO_LIST=$(echo "@item @dots{}") + fi + + # Define the list type and merge its content. + SEEALSO_LIST="$(echo '@itemize'$SEEALSO_LIST'\n@end itemize')" + + # Expand translation marker in the documentation entry. + sed -i -e "/=TEXINFO_SEEALSO=/c\\$SEEALSO_LIST" $FILE + +} diff --git a/Scripts/Functions/Help/help_updateNodes.sh b/Scripts/Functions/Help/help_updateNodes.sh index d30ffe9..dd03df2 100755 --- a/Scripts/Functions/Help/help_updateNodes.sh +++ b/Scripts/Functions/Help/help_updateNodes.sh @@ -25,6 +25,8 @@ function help_updateNodes { + local TEXINFO_TEMPLATE='' + # Retrive nodes' entries from chapter-menu.texi file. local NODES=$(cat $MANUAL_CHAPTER_DIR/chapter-menu.texi \ | sed -r 's!^\* !!' | sed -r 's!:{1,2}.*$!!g' \ @@ -43,9 +45,26 @@ function help_updateNodes { mkdir -p ${MANUAL_BASEDIR}/$(dirname "$INCL") fi - # Create texinfo section file using its template. + # Create texinfo section file using templates. if [[ ! -f ${MANUAL_BASEDIR}/$INCL ]];then - cp ${FUNCCONFIG}/manual-section.texi ${MANUAL_BASEDIR}/$INCL + + # Define what template to apply using the absolute path of + # the documentation entry as reference. + if [[ ${MANUAL_BASEDIR}/${INCL} =~ 'trunk/Scripts/Functions/.+' ]];then + TEXINFO_TEMPLATE="${FUNCCONFIG}/manual-section-functions.texi" + else + TEXINFO_TEMPLATE="${FUNCCONFIG}/manual-section.texi" + fi + + # Copy template to its destination. + cp ${TEXINFO_TEMPLATE} ${MANUAL_BASEDIR}/$INCL + + # Expand common translation markers. + cli_replaceTMarkers "${MANUAL_BASEDIR}/$INCL" + + # Expand texinfo-specific translation markers. + ${FUNCNAM}_doTexinfoSeealso "${MANUAL_BASEDIR}/$INCL" "$NODE" + fi # Output node information based on texinfo menu.