Skip to content

Commit 6dcb20c

Browse files
committed
better doxygen before final iteration
1 parent 4bb3fd5 commit 6dcb20c

5 files changed

Lines changed: 3066 additions & 47 deletions

File tree

ci/create_doxygen.sh

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#!/usr/bin/env zsh
2+
# File: ci/create_doxygen.sh
3+
#
24
# Purpose:
3-
# - Generate an up-to-date base Doxyfile from `doxygen -g` (cached per doxygen version)
4-
# - Sanitize that base deterministically on every run (fixes template multi-line lists)
5-
# - Emit a tiny per-module Doxyfile that @INCLUDEs that sanitized base
5+
# - Generate a fresh base Doxyfile from `doxygen -g` on every run (NO .cache usage)
6+
# - Sanitize that base deterministically (fixes template multi-line lists)
7+
# - Emit a per-module Doxyfile that INLINES the sanitized base + module overrides
68
#
79
# Usage:
810
# ./ci/create_doxygen.sh <module_name>
@@ -15,14 +17,9 @@ die() { print -u2 -- "ERROR: $*"; exit 2; }
1517
mod="$1"
1618

1719
script_dir="${0:A:h}"
18-
cache_dir="$script_dir/doxygen/.cache"
19-
mkdir -p "$cache_dir"
20-
21-
base_pure="$cache_dir/Doxyfile.pure"
22-
base_file="$cache_dir/Doxyfile.base"
23-
ver_file="$cache_dir/doxygen.version"
2420

25-
doxver="$(doxygen --version)"
21+
doxver="$(doxygen --version 2>/dev/null || true)"
22+
[[ -n "$doxver" ]] || die "doxygen not found in PATH"
2623

2724
# Portable in-place sed (BSD/macOS vs GNU)
2825
inplace_sed() {
@@ -35,30 +32,33 @@ inplace_sed() {
3532
fi
3633
}
3734

38-
3935
# Replace a doxygen list key that may be written as a multi-line block:
4036
# KEY = *.a \
4137
# *.b \
4238
# with a single-line canonical:
4339
# KEY = value
4440
#
45-
# We remove the KEY line and its following "indented *..." continuation lines,
46-
# then append the canonical KEY line. Appending is semantically fine for doxygen.
41+
# Strategy:
42+
# - Remove KEY line and continuation lines that follow it
43+
# - Append canonical KEY line at end (Doxygen accepts last-one-wins)
4744
replace_doxy_list_key_single_line() {
4845
local file="$1"
4946
local key="$2"
5047
local value="$3"
5148

5249
# Remove existing KEY line + template continuation lines that follow it.
50+
# Continuations from `doxygen -g` are often indented and may start with "*.ext".
5351
awk -v key="^"key"[[:space:]]*=" '
5452
BEGIN{skip=0}
55-
$0 ~ key { skip=1; next } # drop the KEY = ... line
56-
skip && $0 ~ /^[[:space:]]+\*/ { next } # drop indented "*.ext \" lines
57-
skip { skip=0 } # first non-continuation after block
53+
$0 ~ key { skip=1; next } # drop the KEY = ... line
54+
skip && $0 ~ /^[[:space:]]+\*/ { next } # drop indented "*..." lines
55+
skip && $0 ~ /^[[:space:]]+\*\.[^[:space:]]/ { next } # (extra defensive)
56+
skip && $0 ~ /^[[:space:]]+[^#[:space:]].*\\$/ { next } # drop generic "\" continuation lines
57+
skip { skip=0 } # first non-continuation after block
5858
{ print }
5959
' "$file" > "$file.tmp" && mv "$file.tmp" "$file"
6060

61-
# Defensive: remove any stray KEY lines that might still exist (shouldn't).
61+
# Defensive: remove any stray KEY lines that might still exist.
6262
if grep -qE "^${key}[[:space:]]*=" "$file"; then
6363
inplace_sed "/^${key}[[:space:]]*=/d" "$file"
6464
fi
@@ -88,7 +88,6 @@ sanitize_base() {
8888
inplace_sed 's|^QUIET[[:space:]]*=.*|QUIET = YES|g' "$f"
8989
inplace_sed 's|^WARNINGS[[:space:]]*=.*|WARNINGS = YES|g' "$f"
9090

91-
9291
replace_doxy_list_key_single_line "$f" "FILE_PATTERNS" \
9392
"*.h *.hh *.hpp *.hxx *.c *.cc *.cpp *.cxx *.C *.H"
9493

@@ -106,34 +105,29 @@ sanitize_base() {
106105
inplace_sed '/^HTML_OUTPUT[[:space:]]*=/d' "$f"
107106
inplace_sed '/^GENERATE_TAGFILE[[:space:]]*=/d' "$f"
108107
inplace_sed '/^TAGFILES[[:space:]]*=/d' "$f"
109-
}
110108

111-
# ---- (re)generate base if missing or doxygen version changed ----
112-
need_regen=0
113-
if [[ ! -f "$base_pure" || ! -f "$base_file" || ! -f "$ver_file" ]]; then
114-
need_regen=1
115-
elif [[ "$(cat "$ver_file")" != "$doxver" ]]; then
116-
need_regen=1
117-
fi
109+
# Defensive: remove any stray lines that start with "*" (cause: broken multi-line list blocks)
110+
inplace_sed '/^[[:space:]]*\*/d' "$f"
111+
}
118112

119-
if (( need_regen )); then
120-
print -- " [create_doxygen] Generating base for doxygen $doxver"
121-
doxygen -g "$base_pure" >/dev/null 2>&1
122-
cp -f "$base_pure" "$base_file"
123-
print -- "$doxver" > "$ver_file"
124-
fi
113+
# ---- Generate fresh base every run (no .cache usage) ----
114+
tmp_pure="$(mktemp "${TMPDIR:-/tmp}/Doxyfile.pure.XXXXXX")"
115+
tmp_base="$(mktemp "${TMPDIR:-/tmp}/Doxyfile.base.XXXXXX")"
116+
cleanup() { rm -f -- "$tmp_pure" "$tmp_base"; }
117+
trap cleanup EXIT
125118

126-
# Always sanitize (fixes stale/broken cache contents too)
127-
[[ -f "$base_file" ]] || die "Missing base file '$base_file'"
128-
sanitize_base "$base_file"
119+
print -- " [create_doxygen] Generating base for doxygen $doxver"
120+
doxygen -g "$tmp_pure" >/dev/null 2>&1
121+
cp -f "$tmp_pure" "$tmp_base"
129122

130-
# Emit tiny module Doxyfile that includes the generated base.
131-
# Use absolute path so it works regardless of where the module lives.
132-
base_abs="$base_file"
123+
sanitize_base "$tmp_base"
133124

134-
cat > Doxyfile <<EOF
135-
@INCLUDE = $base_abs
125+
# Emit a module Doxyfile by inlining the sanitized base, then overriding.
126+
{
127+
cat "$tmp_base"
128+
cat <<EOF
136129
130+
# ---- module overrides ----
137131
PROJECT_NAME = "$mod"
138132
INPUT = .
139133
OUTPUT_DIRECTORY = ../pages
@@ -143,6 +137,7 @@ HTML_EXTRA_STYLESHEET = mydoxygen.css
143137
144138
# TAGFILES is injected by ci/doxygen.sh in pass 2
145139
EOF
140+
} > Doxyfile
146141

147142
# Optional: keep local copy for debugging/inspection
148143
cp -f Doxyfile DoxyfilePure 2>/dev/null || true

ci/doxygen.sh

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#!/usr/bin/env zsh
2+
# File: ci/doxygen.sh
3+
#
24
# Purpose: build doxygen docs per module with cross-references (2-pass: TAGs then HTML)
35

46
set -euo pipefail
@@ -12,8 +14,6 @@ doc_modules=(
1214
script_dir="${0:A:h}"
1315
pages_dir="pages"
1416

15-
16-
1717
usage() {
1818
cat <<'EOF'
1919
Usage:
@@ -115,7 +115,14 @@ for m in $modules_to_build; do
115115
"$script_dir/create_doxygen.sh" "$m"
116116
[[ -f Doxyfile ]] || die "Missing Doxyfile in '$moddir'"
117117

118-
inplace_sed 's|^GENERATE_HTML[[:space:]]*=.*|GENERATE_HTML = NO|g' Doxyfile
118+
# Ensure TAG pass doesn't emit HTML
119+
if grep -qE '^GENERATE_HTML[[:space:]]*=' Doxyfile; then
120+
inplace_sed 's|^GENERATE_HTML[[:space:]]*=.*|GENERATE_HTML = NO|g' Doxyfile
121+
else
122+
print -- 'GENERATE_HTML = NO' >> Doxyfile
123+
fi
124+
125+
# Ensure TAGFILES isn't present in pass 1
119126
inplace_sed '/^TAGFILES\b/d' Doxyfile
120127

121128
doxygen Doxyfile
@@ -137,7 +144,14 @@ for m in $modules_to_build; do
137144
"$script_dir/create_doxygen.sh" "$m"
138145
[[ -f Doxyfile ]] || die "Missing Doxyfile in '$moddir'"
139146

140-
inplace_sed 's|^GENERATE_HTML[[:space:]]*=.*|GENERATE_HTML = YES|g' Doxyfile
147+
# Ensure HTML is enabled in pass 2
148+
if grep -qE '^GENERATE_HTML[[:space:]]*=' Doxyfile; then
149+
inplace_sed 's|^GENERATE_HTML[[:space:]]*=.*|GENERATE_HTML = YES|g' Doxyfile
150+
else
151+
print -- 'GENERATE_HTML = YES' >> Doxyfile
152+
fi
153+
154+
# Remove any existing TAGFILES lines before injecting ours
141155
inplace_sed '/^TAGFILES\b/d' Doxyfile
142156

143157
for other in $doc_modules; do
@@ -151,7 +165,7 @@ for m in $modules_to_build; do
151165

152166
popd >/dev/null
153167

154-
cp -f "$css_src" "$pages_dir/$m/mydoxygen.css" 2>/dev/null || true
168+
cp -f "$css_src" "$pages_dir/$m/mydoxygen.css" 2>/dev/null || true
155169
[[ -f "$pages_dir/$m/index.html" ]] || die "HTML not produced for $m ($pages_dir/$m/index.html missing)"
156170
echo
157171
done

gdata/gdataDoxy.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/**
22
* \mainpage GData Library
33
*
4-
* \tableofcontents
54
*
65
* \section intro_sec Introduction
76
* The GData library provides classes and utilities to accumulate simulated “true” information

gdata/meson.build

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
sub_dir_name = meson.current_source_dir().split('/').get(-1)
2+
internal_deps = ['goptions', 'guts', 'gtouchable', 'ghit']
3+
4+
example_event_source = files('examples/event_example.cc')
5+
example_frame_source = files('examples/gframe_example.cc')
6+
example_run_source = files('examples/run_example.cc')
7+
8+
verbosities = ['-verbosity.gevent_data=2',
9+
'-debug.gevent_data=true',
10+
'-verbosity.event_header=2',
11+
'-debug.event_header=true',
12+
'-verbosity.true_data=2',
13+
'-debug.true_data=true',
14+
'-verbosity.digitized_data=2',
15+
'-debug.digitized_data=true',
16+
'-verbosity.gtouchable=2',
17+
'-debug.gtouchable=true'
18+
]
19+
20+
verbosities_run = ['-verbosity.grun_data=2',
21+
'-debug.grun_data=true',
22+
]
23+
24+
25+
LD += {
26+
'name' : sub_dir_name,
27+
'sources' : files(
28+
'gDigitizedData.cc',
29+
'gTrueInfoData.cc',
30+
'run/gRunDataCollection.cc',
31+
'event/gEventDataCollection.cc'
32+
),
33+
'headers' : files(
34+
'gdataConventions.h',
35+
'gDigitizedData.h',
36+
'gDataCollection.h',
37+
'gTrueInfoData.h',
38+
'run/gRunHeader.h',
39+
'run/gRunDataCollection.h',
40+
'event/gEventHeader.h',
41+
'event/gEventDataCollection.h',
42+
'frame/gIntegralPayload.h',
43+
'frame/gFrameHeader.h',
44+
'frame/gFrameDataCollection.h'
45+
),
46+
'additional_includes' : ['gdata', 'gdata/event', 'gdata/run'],
47+
48+
'dependencies' : [yaml_cpp_dep, clhep_deps, geant4_core_deps],
49+
'internal_dependencies' : internal_deps,
50+
51+
'examples' : {
52+
'test_gdata_event' : [example_event_source, ''],
53+
'test_gdata_event_verbose' : [example_event_source, verbosities],
54+
'test_gdata_gframe' : [example_frame_source, ''],
55+
'test_gdata_gframe_verbose' : [example_frame_source, verbosities],
56+
'test_gdata_run_event' : [example_run_source, ''],
57+
'test_gdata_run_verbose' : [example_run_source, verbosities + verbosities_run] }
58+
}

0 commit comments

Comments
 (0)