1 | #!/bin/bash |
---|
2 | #--------------------------------------------------------------------------------# |
---|
3 | # This file is part of the PALM model system. |
---|
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 | # |
---|
16 | # Copyright 1997-2021 Leibniz Universitaet Hannover |
---|
17 | #--------------------------------------------------------------------------------# |
---|
18 | # |
---|
19 | # Current revisions: |
---|
20 | # ------------------ |
---|
21 | # |
---|
22 | # |
---|
23 | # Former revisions: |
---|
24 | # ----------------- |
---|
25 | # $Id: generate_documentation 4843 2021-01-15 15:22:11Z moh.hefny $ |
---|
26 | # Corrected "Former revisions" section |
---|
27 | # svn propset keyword |
---|
28 | # |
---|
29 | # |
---|
30 | # |
---|
31 | # 2696 2017-12-14 17:12:51Z kanani |
---|
32 | # Change in file header (GPL part) |
---|
33 | # |
---|
34 | # 1714 knoop |
---|
35 | # Initial revision |
---|
36 | # |
---|
37 | #--------------------------------------------------------------------------------# |
---|
38 | # generate_documentation - script for generating the PALM code documentation |
---|
39 | #--------------------------------------------------------------------------------# |
---|
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 )" |
---|
47 | |
---|
48 | working_dir=$(readlink -f "${SCRIPT_LOCATION}/../../") |
---|
49 | |
---|
50 | echo "Generating PALM source code documentation..." |
---|
51 | |
---|
52 | |
---|
53 | doc_dir=$working_dir/documentation |
---|
54 | |
---|
55 | # Checking for doxygen |
---|
56 | if type -t doxygen; then |
---|
57 | |
---|
58 | # Removing old documentation |
---|
59 | if [[ -d $doc_dir ]];then |
---|
60 | echo "Remove old documentation" |
---|
61 | rm -r $doc_dir |
---|
62 | fi |
---|
63 | # Generating HTML documentation |
---|
64 | echo "found doxygen. Continuing..." |
---|
65 | cd $SCRIPT_LOCATION |
---|
66 | doxygen palm2doxygen.config |
---|
67 | if [[ $? -ne 0 ]];then |
---|
68 | echo "doxygen detected an error." |
---|
69 | exit 1 |
---|
70 | fi |
---|
71 | cd $doc_dir |
---|
72 | doc_dir=$(pwd) |
---|
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 |
---|
80 | cd $doc_dir/latex |
---|
81 | make pdf |
---|
82 | cd $doc_dir |
---|
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 | |
---|
97 | echo "The PALM source code documentation is located in: $doc_dir" |
---|
98 | echo "Done." |
---|