[1714] | 1 | #!/bin/bash |
---|
| 2 | #--------------------------------------------------------------------------------# |
---|
[2696] | 3 | # This file is part of the PALM model system. |
---|
[1714] | 4 | # |
---|
| 5 | # PALM is free software: you can redistribute it and/or modify it under the terms |
---|
| 6 | # of the GNU General Public License as published by the Free Software Foundation, |
---|
| 7 | # either version 3 of the License, or (at your option) any later version. |
---|
| 8 | # |
---|
| 9 | # PALM is distributed in the hope that it will be useful, but WITHOUT ANY |
---|
| 10 | # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR |
---|
| 11 | # A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
---|
| 12 | # |
---|
| 13 | # You should have received a copy of the GNU General Public License along with |
---|
| 14 | # PALM. If not, see <http://www.gnu.org/licenses/>. |
---|
| 15 | # |
---|
[2718] | 16 | # Copyright 1997-2018 Leibniz Universitaet Hannover |
---|
[1714] | 17 | #--------------------------------------------------------------------------------# |
---|
| 18 | # |
---|
| 19 | # Current revisions: |
---|
| 20 | # ------------------ |
---|
| 21 | # |
---|
[1758] | 22 | # |
---|
[1714] | 23 | # Former revisions: |
---|
| 24 | # ----------------- |
---|
[2716] | 25 | # $Id: generate_documentation 3197 2018-08-14 15:10:43Z moh.hefny $ |
---|
| 26 | # Corrected "Former revisions" section |
---|
| 27 | # svn propset keyword |
---|
| 28 | # |
---|
| 29 | # |
---|
[1714] | 30 | # |
---|
[2716] | 31 | # 2696 2017-12-14 17:12:51Z kanani |
---|
| 32 | # Change in file header (GPL part) |
---|
[1758] | 33 | # |
---|
[2716] | 34 | # 1714 knoop |
---|
[1758] | 35 | # Initial revision |
---|
| 36 | # |
---|
[1714] | 37 | #--------------------------------------------------------------------------------# |
---|
| 38 | # generate_documentation - script for generating the PALM code documentation |
---|
| 39 | #--------------------------------------------------------------------------------# |
---|
[3197] | 40 | SOURCE="${BASH_SOURCE[0]}" |
---|
| 41 | while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink |
---|
| 42 | DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" |
---|
| 43 | SOURCE="$(readlink "$SOURCE")" |
---|
| 44 | [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located |
---|
| 45 | done |
---|
| 46 | SCRIPT_LOCATION="$( cd -P "$( dirname "$SOURCE" )" && pwd )" |
---|
[1714] | 47 | |
---|
[3197] | 48 | working_dir=$(readlink -f "${SCRIPT_LOCATION}/../../") |
---|
| 49 | |
---|
[1714] | 50 | echo "Generating PALM source code documentation..." |
---|
| 51 | |
---|
| 52 | |
---|
[3197] | 53 | doc_dir=$working_dir/documentation |
---|
[1715] | 54 | |
---|
[1714] | 55 | # Checking for doxygen |
---|
| 56 | if type -t doxygen; then |
---|
| 57 | |
---|
| 58 | # Removing old documentation |
---|
[1715] | 59 | if [[ -d $doc_dir ]];then |
---|
[1714] | 60 | echo "Remove old documentation" |
---|
[1715] | 61 | rm -r $doc_dir |
---|
[1714] | 62 | fi |
---|
| 63 | # Generating HTML documentation |
---|
| 64 | echo "found doxygen. Continuing..." |
---|
[3197] | 65 | cd $SCRIPT_LOCATION |
---|
[1714] | 66 | doxygen palm2doxygen.config |
---|
| 67 | if [[ $? -ne 0 ]];then |
---|
| 68 | echo "doxygen detected an error." |
---|
| 69 | exit 1 |
---|
| 70 | fi |
---|
[1715] | 71 | cd $doc_dir |
---|
| 72 | doc_dir=$(pwd) |
---|
[1714] | 73 | ln -s $(pwd)/html/index.html PALM_doc.html |
---|
| 74 | echo "HTML source code documentation generated." |
---|
| 75 | |
---|
| 76 | # Checking for pdflatex |
---|
| 77 | if type -t pdflatex; then |
---|
| 78 | |
---|
| 79 | # Generating PDF documentation |
---|
[1715] | 80 | cd $doc_dir/latex |
---|
[1714] | 81 | make pdf |
---|
[1715] | 82 | cd $doc_dir |
---|
[1714] | 83 | ln -s $(pwd)/latex/refman.pdf PALM_doc.pdf |
---|
| 84 | echo "PDF source code documentation generated." |
---|
| 85 | |
---|
| 86 | else |
---|
| 87 | echo "ERROR: pdflatex not found." |
---|
| 88 | echo "Skipping PDF documentation generation. Terminating!" |
---|
| 89 | exit 1 |
---|
| 90 | fi |
---|
| 91 | else |
---|
| 92 | echo "ERROR: doxygen not found." |
---|
| 93 | echo "Skipping PALM documentation generation. Terminating!" |
---|
| 94 | exit 1 |
---|
| 95 | fi |
---|
| 96 | |
---|
[1715] | 97 | echo "The PALM source code documentation is located in: $doc_dir" |
---|
[3197] | 98 | echo "Done." |
---|