3 # Ran without arguments, will publish the current Doxygen output.
9 # 20220301 (petrillo@slac.stanford.edu) [v1.2]
10 # * added `--overwrite` option and reworked the internals of the update mode
11 # * added `--force` option (affects only `--overwrite` so far)
12 # * added current directory as priority source for the location of Doxyfile
13 # 20200520 (petrillo@slac.stanford.edu) [v1.1]
14 # * added script argument parsing
15 # * added `--update` option
16 # * the option to remove the existing data (`CleanOutputArea`) is not enabled
20 # -- BEGIN -- boilerplate settings and library loading -------------------------
25 for LibraryToLoad
in 'settings.sh' 'utilities.sh' ;
do
27 source "${SCRIPTDIR%/}/${LibraryToLoad}" ||
exit $?
31 # -- END -- boilerplate settings and library loading ---------------------------
33 # ------------------------------------------------------------------------------
37 declare -
r RepoDir=
"./"
39 declare -
r UpdateMode=
'update'
40 declare -
r OverwriteMode=
'overwrite'
41 declare -
r CleanPublishMode=
'newonly'
44 # ------------------------------------------------------------------------------
49 Copies
the documentation into
the public web page storage area.
54 --srcdocdir=SOURCEDIR [autodetect]
58 --codeversion=VERSION [
from metadata]
61 if there is already documentation
for the same
version, update it
62 instead of refusing to proceed;
the existing
directory is not removed
67 in options like \`--overwrite\` it does not ask
for confirmation
69 prints
the script version
and exits (hint: it
's version ${SCRIPTVERSION}
71 prints this usage message and exits
78 function printVersion() {
79 echo "${SCRIPTNAME} version ${SCRIPTVERSION}."
83 ################################################################################
85 ################################################################################
89 declare -i NoMoreOptions
90 declare -i DoVersion=0 DoHelp=0
91 declare PublishMode="$CleanPublishMode"
94 for (( iParam = 1 ; iParam <= $# ; ++iParam )); do
96 if isFlagUnset NoMoreOptions && [[ "${Param:0:1}" == '-
' ]]; then
98 ( '--experiment=
'* ) ExperimentName="${Param#--*=}" ;;
99 ( '--srcdocdir=
'* ) SourceDir="${Param#--*=}" ;;
100 ( '--codeversion=
'* ) Version="${Param#--*=}" ;;
101 ( '--update
' ) PublishMode="$UpdateMode" ;;
102 ( '--overwrite
' ) PublishMode="$OverwriteMode" ;;
103 ( '--force
' ) FORCE=1 ;;
104 ( '--version
' | '-
V' ) DoVersion=1 ;;
105 ( '--
help' | '-
h' | '-?
' ) DoHelp=1 ;;
106 ( '-
' | '--
' ) NoMoreOptions=1 ;;
108 ERROR "Unknown option: '${
Param}
'."
112 PositionalArguments+=( "$Param" )
116 [[ "${#PositionalArguments[@]}" -gt 0 ]] && FATAL 1 "Found ${#PositionalArguments[@]} spurious arguments on command line: ${PositionalArguments[@]}."
118 : ${ExperimentName="$(FindExperiment)"}
119 LASTFATAL "Can't detect
the experiment
name.
"
121 : ${ExperimentCodeName:="$(ExperimentCodeProduct
"$ExperimentName")
"}
122 LASTFATAL "Can
't put together the experiment code repository name for '${
ExperimentName}
'."
124 if isFlagSet DoVersion ; then
126 [[ -z "$ExitWithCode" ]] && ExitWithCode=0
128 if isFlagSet DoHelp ; then
130 [[ -z "$ExitWithCode" ]] && ExitWithCode=0
133 [[ -n "$ExitWithCode" ]] && exit "$ExitWithCode"
136 # ------------------------------------------------------------------------------
138 # find the GIT repository (may contain doxygen file!)
141 GitRepoPath="$(FindGitRepository "$ExperimentCodeName")"
142 if [[ $? == 0 ]] && [[ -n "$GitRepoPath" ]]; then
143 echo "GIT repository: '${GitRepoPath}
'"
145 echo "GIT repository not found."
150 # find the Doxygen configuration file
153 Doxyfile="$(FindDoxyfile "$ExperimentName" "$(pwd)")"
154 if [[ $? == 0 ]] && [[ -n "$Doxyfile" ]]; then
155 echo "Doxygen configuration: '${Doxyfile}
'"
157 echo "Doxygen configuration file not found."
162 # finally find the directory of Doxygen output (hint: it's "html")
164 if [[ -
z "$SourceDir" ]]; then
165 [[ -
r "$Doxyfile" ]] ||
FATAL 1
"The source directory must be specified."
166 SourceDir=
"$(ExtractValueFromDoxyfile 'HTML_OUTPUT' "$Doxyfile
")"
167 [[ -
n "$SourceDir" ]] ||
FATAL 1
"Can't extract the output directory from the Doxygen configuration file."
168 echo
"Doxygen output directory detected: '${SourceDir}'."
169 MetadataFile=
"${SourceDir%/}/${MetadataFileRelPath}"
170 if [[ -
r "$MetadataFile" ]]; then
171 MetadataVersion=
"$(ExtractFromMetadata 'MetadataVersion' "$MetadataFile
")"
172 echo
" => metadata (version ${MetadataVersion}) found at: '${MetadataFile}'"
175 [[ -d
"$SourceDir" ]] ||
FATAL 2
"Can't find the source directory '${SourceDir}'."
178 # with metadata we know everything about generation of documentation
180 if [[
"${MetadataVersion:-0}" -ge 1 ]]; then
181 Version=
"$(ExtractFromMetadata 'CodeVersion' "$MetadataFile
")"
182 [[ $? == 0 ]] && [[ -
n "$Version" ]] && echo
"Code version from metadata: ${Version}."
185 [[ -
z "$Version" ]] &&
FATAL 1
"The version of the documentation must be specified."
188 # transfer the content
190 declare TransferLogFile=
"${LogDir:+${LogDir%/}/}transfer-${ExperimentCodeName}-${Version}.log"
191 declare -
r DestVersionsDir=
"${PublishBaseDir:+${PublishBaseDir%/}/}${ExperimentCodeName}"
192 mkdir -
p "$DestVersionsDir"
193 declare -
r DestDir=
"${DestVersionsDir}/${Version}"
194 if [[ -d
"$DestDir" ]]; then
195 case "$PublishMode" in
197 echo
"The existing content in '${DestDir}' will be removed before proceeding."
200 echo
"Please confirm the removal of its content:"
202 rm -Rf $ConfirmOpt
"$DestDir"
203 [[ -d
"$DestDir" ]] &&
FATAL 1
"output directory won't be overwritten."
206 echo
"The existing content in '${DestDir}' will be updated."
207 # no
action actually needed
209 (
"$CleanPublishMode" )
210 FATAL 1
"Output directory '${DestDir}' already exists: remove it first!"
213 FATAL 1
"INTERNAL ERROR: PublishMode='${PublishMode}' not recognised."
217 declare -
a Cmd=( rsync -av
"${SourceDir%/}/" "${DestDir%/}/" ">&" "$TransferLogFile")
219 echo
"Copying the documentation content:"
222 LASTFATAL "Error while copying the content from '${SourceDir}' to '${DestDir}'."
227 echo
"Updating latest version link:"
228 declare -
r LatestLinkPath=
"${DestVersionsDir}/${LatestLinkName}"
229 [[ -
h "$LatestLinkPath" ]] && rm
"$LatestLinkPath"
230 ln -sfv
"$(basename "$DestDir
")" "$LatestLinkPath"
process_name opflash particleana ie ie ie z
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
then echo Work directory not specified exit fi echo Work directory
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
then echo File list $list not found else cat $list while read file do echo $file sed s
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker options