Update documentation - increase Doxygen usage
[geeqie.git] / scripts / doxygen-help.sh
1 #!/bin/bash
2
3 #**********************************************************************
4 # Copyright (C) 2021 - The Geeqie Team
5 #
6 # Author: Colin Clark
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along
19 # with this program; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #**********************************************************************
22 ## @file
23 ## @brief Facilitate the integration of the Doxygen html files
24 ## into a code editor.
25 ##  
26 ## doxygen-help.sh <parameter to be searched for>
27 ##  
28 ## The environment variable DOCDIR must be set to point to the
29 ## Doxygen html files location.
30 ##
31 ## The environment variable PROJECT must be set to the value used
32 ## when creating the Doxygen files.
33 ##  
34 ## Set a hot key in the code editor to call this script with
35 ## the highlighted variable or function name as a parameter.
36 ##  
37 ## The file $DOCDIR/$PROJECT.tag contains an index of all documented
38 ## items and is scanned to locate the relevant html section.
39 ##  
40 ## xdg-open is used to call the html browser to display the document.
41 ##  
42 ##  **********************************************************************
43 ##  
44 ## To generate the Doxygen html files set the following
45 ## environment variables:  
46 ## DOCDIR (destination folder)  
47 ## SRCDIR (must point to the level above the source code)  
48 ## PROJECT  
49 ## VERSION
50 ##  
51 ## Then run 'doxygen doxygen.conf'
52 ##
53  
54 if [[ -z "${DOCDIR}" ]]
55 then
56         echo "Environment variable DOCDIR not set"
57         zenity --title="Geeqie" --width=200 --warning --text="Environment variable DOCDIR not set"
58 elif [[ -z "${PROJECT}" ]]
59 then
60         echo "Environment variable PROJECT not set"
61         zenity --title="Geeqie" --width=200 --warning --text="Environment variable PROJECT not set"
62 else
63         url_found=$(awk  -v search_param="$1" -v docdir="$DOCDIR" '
64                 {
65                 if ($1 == "<name>_"search_param"</name>")
66                         {
67                         getline
68                         n=split($1, anchorfile, /[<>]/)
69
70                         getline
71                         n=split($1, anchor, /[<>]/)
72                         struct_result="file://"docdir"/html/" anchorfile[3] "#" anchor[3]
73                         }
74                 else
75                         {
76                         if ($1 == "<name>"search_param"</name>")
77                                 {
78                                 getline
79                                 n=split($1, anchorfile, /[<>]/)
80
81                                 getline
82                                 n=split($1, anchor, /[<>]/)
83                                 function_result="file://"docdir"/html/" anchorfile[3] "#" anchor[3]
84                                 }
85                         }
86                 }
87                 END {
88                         if (struct_result != "")
89                                 {
90                                 print struct_result
91                                 }
92                         else if (function_result != "")
93                                 {
94                                 print function_result
95                                 }
96                         }
97                 ' "$DOCDIR"/"$PROJECT".tag)
98
99         if [[ -z $url_found ]]
100         then
101                 exit 1
102         else
103                 xdg-open "$url_found"
104                 exit 0
105         fi
106 fi