diff --git a/Scripts/Functions/Help/help.sh b/Scripts/Functions/Help/help.sh index e59ef57..130dbe8 100755 --- a/Scripts/Functions/Help/help.sh +++ b/Scripts/Functions/Help/help.sh @@ -34,22 +34,53 @@ function help { # search is perform. FLAG_SEARCH="" - # Initialize the backend option. The backend option (`--backend') - # specifies the backend used to manipulate the repository - # documentation manual. - FLAG_BACKEND="texinfo" - - # Define manual base directory. This is the place where all - # different formats of repository documentation manual are stored - # in. - MANUAL_BASEDIR="$(cli_getRepoTLDir)/Manuals" - # Define file name (without extension) for documentation manual. MANUAL_NAME=$(cli_getRepoName "repository" -f) # Define language information used by manual. MANUAL_LANG=$(cli_getCurrentLocale) + # Define manual base directory to refere the place where + # language-specific source files used by texinfo documentation + # backend are stored in. + MANUAL_BASEDIR="${HOME}/trunk/Manuals/RepoReference/${MANUAL_LANG}" + + # Define base name for documentation manual files (without + # extension). This is the main file name used to build output + # related files (.info, .pdf, .xml, etc.). + MANUAL_BASEFILE="${MANUAL_BASEDIR}/${MANUAL_NAME}" + + # Define chapter name of directory where repository documentation + # entries will be stored in. + MANUAL_CHAPTER_NAME=$(cli_getRepoName "Directories" -d) + + # Define absolute path to chapter directory where repository + # documentation entries will be stored in. At this point, we need + # to take a desition about documentation design, in order to + # answer the question: How do we assign chapters, sections and + # subsections automatically, based on the repository structure? + # and also, how such design could be adapted to changes in the + # repository structure? + # + # One solution would be: represent the repository's directory + # structure as sections inside a chapter named `Directories' or + # something similar. Subsections and subsubsections will not have + # their own files, they all will be written inside the same + # section file that represents the repository documentation entry. + MANUAL_CHAPTER_DIR=${MANUAL_BASEDIR}/${MANUAL_CHAPTER_NAME} + + # Define absolute path to backend template files. + MANUAL_TEMPLATE=${FUNCDIR}/${FUNCDIRNAM}/Templates/$(cli_getCurrentLocale) + + # Verify absolute path to backend template files. If the absolute + # path doesn't exist, use the English language templates. + if [[ ! -d $MANUAL_TEMPLATE ]];then + MANUAL_TEMPLATE=${FUNCDIR}/${FUNCDIRNAM}/Templates/en_US + fi + + # Create documentation structure, if it doesn't exist. + ${FUNCNAM}_createStructure + # Interpret option arguments passed through the command-line. ${FUNCNAM}_getOptions @@ -58,19 +89,61 @@ function help { # only non-option arguments remain in it. eval set -- "$ARGUMENTS" - # Verify and initialize backend functions. There is no need to - # load all backend-specific functions when we can use just one - # backend among many. Keep the cli_exportFunctions function - # calling after all variables and arguments definitions. - if [[ ${FLAG_BACKEND} =~ '^texinfo$' ]];then - cli_exportFunctions "${FUNCDIR}/${FUNCDIRNAM}" 'texinfo' - elif [[ ${FLAG_BACKEND} =~ '^docbook$' ]];then - cli_exportFunctions "${FUNCDIR}/${FUNCDIRNAM}" 'docbook' + # 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_CHAPTER_DIR} + + # Execute backend functionalities. Notice that there are + # functionalities that need more than one action value in order to + # be executed (e.g., copying, and renaming), functionalities + # that need just one action value to be executed (e.g., + # documentation reading and edition) and functionalities that + # don't need action value at all (e.g., searching, reading and + # updating output files). This way, the execution of backend + # functionalities is splitted here. + if [[ $ACTIONNAM =~ "${FUNCNAM}_(copy|rename|delete)Entry" ]];then + + # Execute backend action names that may need to use more than + # one action value. + ${ACTIONNAM} $@ + + elif [[ $ACTIONNAM =~ "${FUNCNAM}_(search(Index|Node)|updateOutputFiles)" ]];then + + # Execute backend action names that might not need any action + # value as reference to do their work. + $ACTIONNAM $@ + + # Backend action names that don't need to use any action value + # as reference to do their work are of one-pass only. They are + # executed and then the script execution is finished. + exit + else - cli_printMessage "`gettext "The backend provided is not supported."`" --as-error-line + + # Execute backend action names that use one action value, only. + for ACTIONVAL in $@;do + + # Define documentation entry. + MANUAL_ENTRY=$(${FUNCNAM}_getEntry $ACTIONVAL) + + # Execute backend action names that may need to use more + # than one action value. + $ACTIONNAM + + done + fi - # Execute backend initialization. - ${FLAG_BACKEND} "$@" + # 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_CHAPTER_DIR} + + # Rebuild output files to propagate recent changes. + ${FUNCNAM}_updateOutputFiles + +} }