Skip to content

Commit 4bb3fd5

Browse files
committed
partial better doxygen
1 parent 0139601 commit 4bb3fd5

8 files changed

Lines changed: 582 additions & 4523 deletions

File tree

ci/create_doxygen.sh

Lines changed: 148 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,89 +1,148 @@
1-
#!/bin/zsh
2-
3-
4-
# Purpose: creates a doxyfile using the doxygen -g command to get the latest doxygen goodies)
5-
# The replace each line with the ones shown below
6-
7-
echo " Creating System Doxyfile "
8-
doxygen -g &> /dev/null
9-
10-
cp Doxyfile DoxyfilePure
11-
class=$1
12-
13-
14-
# painfully, manually doing these, but we HAVE TO
15-
# Note: keep STRIP_CODE_COMMENTS (refers just to doxygen comments) and SOURCE_TOOLTIPS to yes to make browing more readable
16-
sed -i "s/PROJECT_NAME = \"My Project\"/PROJECT_NAME = \"$class\"/g" Doxyfile
17-
sed -i 's/REPEAT_BRIEF = YES/REPEAT_BRIEF = NO/g' Doxyfile
18-
sed -i 's/OPTIMIZE_OUTPUT_FOR_C = NO/OPTIMIZE_OUTPUT_FOR_C = YES/g' Doxyfile
19-
sed -i 's/BUILTIN_STL_SUPPORT = NO/BUILTIN_STL_SUPPORT = YES/g' Doxyfile
20-
#sed -i 's/SHOW_INCLUDE_FILES = YES/SHOW_INCLUDE_FILES = NO/g' Doxyfile
21-
#sed -i 's/SHOW_FILES = YES/SHOW_FILES = NO/g' Doxyfile
22-
sed -i 's/EXTRACT_ALL = NO/EXTRACT_ALL = YES/g' Doxyfile
23-
sed -i 's/SOURCE_BROWSER = NO/SOURCE_BROWSER = YES/g' Doxyfile
24-
sed -i 's/RECURSIVE = NO/RECURSIVE = YES/g' Doxyfile
25-
sed -i 's/HTML_COLORSTYLE_HUE = 220/HTML_COLORSTYLE_HUE = 200/g' Doxyfile
26-
sed -i 's/HTML_COLORSTYLE_SAT = 100/HTML_COLORSTYLE_SAT = 240/g' Doxyfile
27-
sed -i 's/HTML_COLORSTYLE_GAMMA = 80/HTML_COLORSTYLE_GAMMA = 190/g' Doxyfile
28-
sed -i 's/HTML_DYNAMIC_MENUS = YES/HTML_DYNAMIC_MENUS = YES/g' Doxyfile
29-
sed -i 's/GENERATE_TREEVIEW = NO/GENERATE_TREEVIEW = YES/g' Doxyfile
30-
sed -i 's/FORMULA_FONTSIZE = 10/FORMULA_FONTSIZE = 14/g' Doxyfile
31-
sed -i 's/DOT_FONTNAME = Helvetica/DOT_FONTNAME = Avenir/g' Doxyfile
32-
sed -i 's/DOT_FONTSIZE = 10/DOT_FONTSIZE = 16/g' Doxyfile
33-
sed -i 's/TEMPLATE_RELATIONS = NO/TEMPLATE_RELATIONS = YES/g' Doxyfile
34-
sed -i 's/GENERATE_LATEX = YES/GENERATE_LATEX = NO/g' Doxyfile
35-
sed -i 's/HAVE_DOT = NO/HAVE_DOT = YES/g' Doxyfile
36-
sed -i 's/UML_LOOK = NO/UML_LOOK = YES/g' Doxyfile
37-
sed -i 's/EXCLUDE =/EXCLUDE = README.md .git/g' Doxyfile
38-
sed -i 's/QUIET = NO/QUIET = YES/g' Doxyfile
39-
sed -i 's/HIDE_FRIEND_COMPOUNDS = NO/HIDE_FRIEND_COMPOUNDS = YES/g' Doxyfile
40-
sed -i "s/HTML_EXTRA_STYLESHEET =/HTML_EXTRA_STYLESHEET = ..\/mydoxygen.css/g" Doxyfile
41-
sed -i 's/PREDEFINED =/PREDEFINED = DOXYGEN_SHOULD_SKIP_THIS/g' Doxyfile
42-
43-
44-
# painfully removing the individual patterns
45-
sed -i '/*.hpp \\/d' Doxyfile
46-
sed -i '/*.java \\/d' Doxyfile
47-
sed -i '/*.ii \\/d' Doxyfile
48-
sed -i '/*.ixx \\/d' Doxyfile
49-
sed -i '/*.ipp \\/d' Doxyfile
50-
sed -i '/*.i++ \\/d' Doxyfile
51-
sed -i '/*.inl \\/d' Doxyfile
52-
sed -i '/*.cs \\/d' Doxyfile
53-
sed -i '/*.d \\/d' Doxyfile
54-
sed -i '/*.m \\/d' Doxyfile
55-
sed -i '/*.doc \\/d' Doxyfile
56-
sed -i '/*.txt \\/d' Doxyfile
57-
sed -i '/*.f \\/d' Doxyfile
58-
sed -i '/*.for \\/d' Doxyfile
59-
sed -i '/*.vhd \\/d' Doxyfile
60-
sed -i '/*.ucf \\/d' Doxyfile
61-
sed -i '/*.md \\/d' Doxyfile
62-
sed -i '/*.mm \\/d' Doxyfile
63-
sed -i '/*.dox \\/d' Doxyfile
64-
sed -i '/*.f90 \\/d' Doxyfile
65-
sed -i '/*.f95 \\/d' Doxyfile
66-
sed -i '/*.f03 \\/d' Doxyfile
67-
sed -i '/*.f08 \\/d' Doxyfile
68-
sed -i '/*.markdown \\/d' Doxyfile
69-
sed -i '/*.tcl \\/d' Doxyfile
70-
sed -i '/*.vhdl \\/d' Doxyfile
71-
sed -i '/*.qsf \\/d' Doxyfile
72-
sed -i '/*.php \\/d' Doxyfile
73-
sed -i '/*.php4 \\/d' Doxyfile
74-
sed -i '/*.php5 \\/d' Doxyfile
75-
sed -i '/*.phtml \\/d' Doxyfile
76-
sed -i '/*.idl \\/d' Doxyfile
77-
sed -i '/*.ddl \\/d' Doxyfile
78-
sed -i '/*.odl \\/d' Doxyfile
79-
80-
rm -f Doxyfilebackup
81-
82-
toCheck=(PROJECT_NAME OPTIMIZE_OUTPUT_FOR_C BUILTIN_STL_SUPPORT SHOW_FILES HTML_COLORSTYLE_GAMMA QUIET)
83-
echo " "Doxyfile Main changes:
84-
echo
85-
for l in $toCheck
86-
do
87-
setting=$(grep "$l" Doxyfile | grep -v "#")
88-
echo " - "$setting
89-
done
1+
#!/usr/bin/env zsh
2+
# 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
6+
#
7+
# Usage:
8+
# ./ci/create_doxygen.sh <module_name>
9+
10+
set -euo pipefail
11+
12+
die() { print -u2 -- "ERROR: $*"; exit 2; }
13+
14+
(( $# == 1 )) || die "Usage: $0 <module_name>"
15+
mod="$1"
16+
17+
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"
24+
25+
doxver="$(doxygen --version)"
26+
27+
# Portable in-place sed (BSD/macOS vs GNU)
28+
inplace_sed() {
29+
local expr="$1"
30+
local file="$2"
31+
if sed --version >/dev/null 2>&1; then
32+
sed -i "$expr" "$file"
33+
else
34+
sed -i '' "$expr" "$file"
35+
fi
36+
}
37+
38+
39+
# Replace a doxygen list key that may be written as a multi-line block:
40+
# KEY = *.a \
41+
# *.b \
42+
# with a single-line canonical:
43+
# KEY = value
44+
#
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.
47+
replace_doxy_list_key_single_line() {
48+
local file="$1"
49+
local key="$2"
50+
local value="$3"
51+
52+
# Remove existing KEY line + template continuation lines that follow it.
53+
awk -v key="^"key"[[:space:]]*=" '
54+
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
58+
{ print }
59+
' "$file" > "$file.tmp" && mv "$file.tmp" "$file"
60+
61+
# Defensive: remove any stray KEY lines that might still exist (shouldn't).
62+
if grep -qE "^${key}[[:space:]]*=" "$file"; then
63+
inplace_sed "/^${key}[[:space:]]*=/d" "$file"
64+
fi
65+
66+
print -- "${key} = ${value}" >> "$file"
67+
}
68+
69+
sanitize_base() {
70+
local f="$1"
71+
72+
# ---- normalize base settings (small/stable list) ----
73+
inplace_sed 's|^REPEAT_BRIEF[[:space:]]*=.*|REPEAT_BRIEF = NO|g' "$f"
74+
inplace_sed 's|^OPTIMIZE_OUTPUT_FOR_C[[:space:]]*=.*|OPTIMIZE_OUTPUT_FOR_C = YES|g' "$f"
75+
inplace_sed 's|^BUILTIN_STL_SUPPORT[[:space:]]*=.*|BUILTIN_STL_SUPPORT = YES|g' "$f"
76+
inplace_sed 's|^EXTRACT_ALL[[:space:]]*=.*|EXTRACT_ALL = YES|g' "$f"
77+
inplace_sed 's|^SOURCE_BROWSER[[:space:]]*=.*|SOURCE_BROWSER = YES|g' "$f"
78+
inplace_sed 's|^RECURSIVE[[:space:]]*=.*|RECURSIVE = YES|g' "$f"
79+
inplace_sed 's|^GENERATE_TREEVIEW[[:space:]]*=.*|GENERATE_TREEVIEW = YES|g' "$f"
80+
inplace_sed 's|^FORMULA_FONTSIZE[[:space:]]*=.*|FORMULA_FONTSIZE = 14|g' "$f"
81+
inplace_sed 's|^DOT_FONTNAME[[:space:]]*=.*|DOT_FONTNAME = Avenir|g' "$f"
82+
inplace_sed 's|^DOT_FONTSIZE[[:space:]]*=.*|DOT_FONTSIZE = 16|g' "$f"
83+
inplace_sed 's|^TEMPLATE_RELATIONS[[:space:]]*=.*|TEMPLATE_RELATIONS = YES|g' "$f"
84+
inplace_sed 's|^GENERATE_LATEX[[:space:]]*=.*|GENERATE_LATEX = NO|g' "$f"
85+
inplace_sed 's|^HAVE_DOT[[:space:]]*=.*|HAVE_DOT = YES|g' "$f"
86+
inplace_sed 's|^UML_LOOK[[:space:]]*=.*|UML_LOOK = YES|g' "$f"
87+
inplace_sed 's|^HIDE_FRIEND_COMPOUNDS[[:space:]]*=.*|HIDE_FRIEND_COMPOUNDS = YES|g' "$f"
88+
inplace_sed 's|^QUIET[[:space:]]*=.*|QUIET = YES|g' "$f"
89+
inplace_sed 's|^WARNINGS[[:space:]]*=.*|WARNINGS = YES|g' "$f"
90+
91+
92+
replace_doxy_list_key_single_line "$f" "FILE_PATTERNS" \
93+
"*.h *.hh *.hpp *.hxx *.c *.cc *.cpp *.cxx *.C *.H"
94+
95+
replace_doxy_list_key_single_line "$f" "EXCLUDE_PATTERNS" \
96+
"*/.git/* */build/* */_build/* */cmake-build-*/* *.md *.markdown *.txt *.dox"
97+
98+
# Force stylesheet setting (delete any existing, then append)
99+
inplace_sed '/^HTML_EXTRA_STYLESHEET[[:space:]]*=/d' "$f"
100+
print -- 'HTML_EXTRA_STYLESHEET = mydoxygen.css' >> "$f"
101+
102+
# Clear per-project knobs from the base (these will be set per-module)
103+
inplace_sed '/^PROJECT_NAME[[:space:]]*=/d' "$f"
104+
inplace_sed '/^INPUT[[:space:]]*=/d' "$f"
105+
inplace_sed '/^OUTPUT_DIRECTORY[[:space:]]*=/d' "$f"
106+
inplace_sed '/^HTML_OUTPUT[[:space:]]*=/d' "$f"
107+
inplace_sed '/^GENERATE_TAGFILE[[:space:]]*=/d' "$f"
108+
inplace_sed '/^TAGFILES[[:space:]]*=/d' "$f"
109+
}
110+
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
118+
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
125+
126+
# Always sanitize (fixes stale/broken cache contents too)
127+
[[ -f "$base_file" ]] || die "Missing base file '$base_file'"
128+
sanitize_base "$base_file"
129+
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"
133+
134+
cat > Doxyfile <<EOF
135+
@INCLUDE = $base_abs
136+
137+
PROJECT_NAME = "$mod"
138+
INPUT = .
139+
OUTPUT_DIRECTORY = ../pages
140+
HTML_OUTPUT = $mod
141+
GENERATE_TAGFILE = ../pages/$mod/$mod.tag
142+
HTML_EXTRA_STYLESHEET = mydoxygen.css
143+
144+
# TAGFILES is injected by ci/doxygen.sh in pass 2
145+
EOF
146+
147+
# Optional: keep local copy for debugging/inspection
148+
cp -f Doxyfile DoxyfilePure 2>/dev/null || true

0 commit comments

Comments
 (0)