Hog Hog2026.2-1
make_doxygen.tcl
Go to the documentation of this file.
1 #!/usr/bin/env tclsh
2 # Copyright 2018-2026 The University of Birmingham
3 # Copyright 2018-2026 Max-Planck-Institute for Physics
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 
17 # @file
18 # Create the doxygen documentation
19 
20 #parsing command options
21 if {[catch {package require cmdline} ERROR]} {
22  puts "$ERROR\n If you are running this script on tclsh, you can fix this by installing 'tcllib'"
23  return
24 }
25 set parameters {
26 }
27 
28 set usage "USAGE: $::argv0"
29 
30 source ./Hog/Tcl/hog.tcl
31 set tcl_path [file dirname [info script]]
32 set repo_path [file normalize $tcl_path/../../..]
33 cd $tcl_path
34 cd $repo_path
35 
36 if {[catch {array set options [cmdline::getoptions ::argv $parameters $usage]}] || $::argc != 0} {
37  Msg Info [cmdline::usage $parameters $usage]
38  cd $repo_path
39  exit 1
40 }
41 
42 lassign [GetVer .] version commit
43 set version [HexVersionToString $version]
44 Msg Info "Creating doxygen documentation for tag $version"
45 
46 
47 # Run doxygen
48 set doxygen_conf "./doxygen/doxygen.conf"
49 if {[file exists $doxygen_conf] == 0} {
50  # Using Default hog template
51  set doxygen_conf "./Hog/Templates/doxygen.conf"
52  Msg Info "Running doxygen with ./Hog/Templates/doxygen.conf..."
53 } else {
54  Msg Info "Running doxygen with $doxygen_conf..."
55 }
56 
57 if {[DoxygenVersion 1.8.13]} {
58  if {![DoxygenVersion 1.9.1]} {
59  Msg Warning "It seems that you are using Doxygen version [Execute doxygen --version]. We recommend Doxygen version 1.9.1 or higher"
60  }
61  set conffile [open $doxygen_conf r+]
62  #replacing PROJECT_NUMBER with current version if existing, otherwise adding it
63  set buf_tmp ""
64  set VERSION_SET False
65  set conf_read [read $conffile]
66  foreach line [split $conf_read \n] {
67  if {[string match "#*" [string trim $line]]} {
68  append buf_tmp "\n$line"
69  } elseif {[string first "PROJECT_NUMBER" $line] != -1} {
70  set VERSION_SET True
71  append buf_tmp "\nPROJECT_NUMBER = $version"
72  } else {
73  append buf_tmp "\n$line"
74  }
75  }
76  if {!$VERSION_SET} {
77  append buf_tmp "\nPROJECT_NUMBER = $version"
78  }
79  close $conffile
80  #removing first endline
81  set buf_tmp [string range $buf_tmp 1 end]
82 
83  set doxygen_conf_out ".doxygen.conf"
84  set outfile [open $doxygen_conf_out w+]
85  puts -nonewline $outfile $buf_tmp
86  close $outfile
87 
88  Execute doxygen $doxygen_conf_out
89  file delete $doxygen_conf_out
90 } else {
91  cd $repo_path
92  Msg Error "Cannot find Doxygen version 1.8.13 or higher"
93 }
94 
95 cd $repo_path