Skip to content
Snippets Groups Projects
Commit 34644d28 authored by Stephan Hageboeck's avatar Stephan Hageboeck Committed by Javier Lopez-Gomez
Browse files

[Doxygen] Streamline doxygen collaboration diagrams.

- Doxygen was creating one svg for every class, showing in which library it resides. This created
  6000 svgs, which were mostly identical. Now, only ~100 are created for every library in ROOTSYS/lib/,
  and the relevant webpages link to those.
  This speeds up the "listlibs" step of the doxygen process signficantly.
- Add parallel processing for collaboration diagrams of class webpages.
- Remove scanning of rootmap files. It doesn't work, any more. TCling needs
  a fix for ROOT-10900, so gInterpreter->GetClassSharedLib() will always
  return the right thing.
- Further, parallelise the modification of class webpages.
parent aac60a6e
No related branches found
No related tags found
No related merge requests found
.PHONY: filter folders mathjax js images doxygen
.PHONY: filter folders mathjax js images doxygen replaceCollaborationDiagrams
NJOB ?= $(shell nproc)
PYTHON_EXECUTABLE ?= python3
......@@ -55,7 +55,6 @@ doxygen: filter pyzdoc
./makehtmlfooter.sh > htmlfooter.html
./makeinput.sh
doxygen
./listlibs.sh
gzip $(DOXYGEN_IMAGE_PATH)/ROOT.tag
gzip $(DOXYGEN_IMAGE_PATH)/ROOT.qch
rm -rf files c1* *.ps *.eps *.png *.jpg *.tex *.svg *.pdf *.root *.xpm *.out *.dat *.dtd *.dot *.txt *.csv *.log *.rs
......
......@@ -13,38 +13,12 @@ void libs(TString classname)
if (i>0) classname.Remove(i,classname.Length()-i);
libname = gInterpreter->GetClassSharedLibs(classname.Data());
// Library was not found, try to find it from a template in $ROOTSYS/lib/*.rootmap
if (!libname) {
gSystem->Exec(Form("grep %s $ROOTSYS/lib/*.rootmap | grep -m 1 map:class | sed -e 's/^.*class //' > classname.txt",classname.Data()));
FILE *f = fopen("classname.txt", "r");
char c[160];
char *str = fgets(c,160,f);
fclose(f);
remove("classname.txt");
if (!str) {
printf("%s cannot be found in any of the .rootmap files\n", classname.Data());
remove("libslist.dot");
return;
}
TString cname = c;
cname.Remove(cname.Length()-1, 1);
libname = gInterpreter->GetClassSharedLibs(cname.Data());
if (!libname) {
printf("Cannot find library for the class %s\n",cname.Data());
return;
}
}
if (!libname)
return;
// Print the library name in a external file
TString mainlib = libname;
mainlib.ReplaceAll(" ","");
mainlib.ReplaceAll(".so","");
FILE *f = fopen("mainlib.dot", "w");
fprintf(f," mainlib [label=%s];\n",mainlib.Data());
fclose(f);
// List of libraries used by libname via ldd on linux and otool on Mac
gSystem->Exec(Form("$DOXYGEN_LDD $ROOTSYS/lib/%s | grep -v %s > libslist.dot",libname,libname));
printf("mainlib=%s", libname);
}
#!/bin/sh
# Finding the system we are running
export DOXYGEN_LDD="ldd"
OS=`uname`
case "$OS" in
"Linux") export DOXYGEN_LDD="ldd"
;;
"Darwin")export DOXYGEN_LDD="otool -L"
;;
esac
# Transform collaboration diagram into list of libraries
echo '#!/bin/sh' > listofclass.sh
echo '' >> listofclass.sh
grep -s "Collaboration diagram for" $DOXYGEN_OUTPUT_DIRECTORY/html/class*.html | sed -e "s/.html:.*$//" | sed -e "s/^.*html\/class/\.\/makelibs.sh /" >> listofclass.sh
chmod +x ./listofclass.sh
./listofclass.sh
#!/bin/bash
# Scan libraries in ROOTSYS, and create a collaboration diagram for each. Put those in the
# doxygen html directory to be picked up by the class overview pages.
HTMLPATH=$DOXYGEN_OUTPUT_DIRECTORY/html
DOXYGEN_LDD=${DOXYGEN_LDD:=ldd}
dotFile=$(mktemp /tmp/libraries_XXXX.dot)
test -d "$HTMLPATH" || { echo "HTMLPATH '$HTMLPATH' not found."; exit 1; }
test -d "$ROOTSYS" || { echo "ROOTSYS not set"; exit 1; }
for libname in ${ROOTSYS}/lib/lib[A-Z]*.so; do
libsList=$(${DOXYGEN_LDD} ${libname} | grep -v ${libname})
libname=${libname%.so}
libname=${libname##*/}
# Picture name containing the "coll graph"
PICNAME="${HTMLPATH}/${libname}__coll__graph.svg"
libsList=$(echo "$libsList" | sed -e "s/\.so.*$/\";/" | grep -v "\.dylib" | grep 'lib[A-Z]' |
sed -e "s/\(.*\)\(lib.*;\)$/ mainlib->\"\2/")
# Generate the dot file describing the graph for libraries
cat <<EOF > ${dotFile}
digraph G {
rankdir=TB;
node [shape=box, fontname=Arial];
mainlib [label="${libname}"];
${libsList}
mainlib [shape=box, fillcolor="#ABACBA", style=filled];
}
EOF
# Generate the SVG image of the graph
dot -Tsvg ${dotFile} -o $PICNAME
done
#!/bin/bash
# Replace the original collaboration diagram in the doxygen webpages by the diagram of used libraries.
HTMLPATH=$DOXYGEN_OUTPUT_DIRECTORY/html
DOXYGEN_LDD=${DOXYGEN_LDD:=ldd}
WORKFILE=$HTMLPATH/class${1}.html
if [ ! -d "$HTMLPATH" -o ! -f "$WORKFILE" ]; then
echo "File $WORKFILE doesn't exist. Need DOXYGEN_OUTPUT_DIRECTORY exported."
exit 1
fi
# Find the libraries for the class $1
root -l -b -q "libs.C+(\"$1\")"
# No dot file, the class was not found. Remove the collaboration graph
if [[ ! -f libslist.dot ]] ; then
sed -i'.back' -e 's/^Collaboration diagram for.*$/<\/div>/g' $HTMLPATH/class$1.html
sed -i'.back' '/__coll__graph.svg/I,+2 d' $HTMLPATH/class$1.html
sed -i'.back' -e 's/<hr\/>The documentation for/<\/div><hr\/>The documentation for/g' $HTMLPATH/class$1.html
rm $HTMLPATH/class$1.html.back
libname=$(root -l -b -q "libs.C+g(\"$1\")" | grep 'mainlib=')
# The class was not found. Remove the collaboration graph
if [ -z "${libname}" ]; then
echo "WARNING modifyClassWebpage.sh: libs.C could not get library of class $1 from ROOT interpreter. Removing its collaboration diagram."
sed -i'.back' -e 's/^Collaboration diagram for.*$/<\/div>/g' $WORKFILE
sed -i'.back' '/__coll__graph.svg/I,+2 d' $WORKFILE
sed -i'.back' -e 's/<hr\/>The documentation for/<\/div><hr\/>The documentation for/g' $WORKFILE
rm $WORKFILE.back
exit
fi
sed -i'.back' -e 's/Collaboration diagram for /Libraries for /g' $HTMLPATH/class$1.html
rm $HTMLPATH/class$1.html.back
libname=${libname#mainlib=}
libname=${libname%.so}
# Picture name containing the "coll graph"
PICNAME=$HTMLPATH/"class"$1"__coll__graph.svg"
sed -i'.back' -e "s/\.so.*$/\";/" libslist.dot
rm libslist.dot.back
PICNAME="$HTMLPATH/${libname}__coll__graph.svg"
# Generate the dot file describing the graph for libraries
echo "digraph G {" > libraries.dot
echo " rankdir=LR;" >> libraries.dot
echo " node [shape=box, fontname=Arial];" >> libraries.dot
cat mainlib.dot >> libraries.dot;
cat libslist.dot | grep -v "\.dylib" \
| grep lib[A-Z] | sed -e "s/\(.*\)\(lib.*;\)$/ mainlib->\"\2/" \
>> libraries.dot
echo " mainlib [shape=box, fillcolor=\"#ABACBA\", style=filled];" >> libraries.dot
echo "}" >> libraries.dot
test -f "${PICNAME}" || { echo "Error: file $PICNAME not found."; exit 1; }
# Generate the SVG image of the graph
dot -Tsvg libraries.dot -o $PICNAME
sed -i'.back' -e 's/Collaboration diagram for /Libraries for /g' $WORKFILE
sed -i'.back' -e "s/class${1}__coll__graph.svg/${PICNAME##*/}/" $WORKFILE
# Make sure the picture size in the html file the same as the svg
PICSIZE=`grep "svg width" $PICNAME | sed -e "s/<svg //"`
sed -i'.back' -e "s/\(^.*src\)\(.*__coll__graph.svg\"\)\( width.*\">\)\(.*$\)/<div class=\"center\"><img src\2 $PICSIZE><\/div>/" $HTMLPATH/class$1.html
rm $HTMLPATH/class$1.html.back
sed -i'.back' -e "s/\(^.*src\)\(.*__coll__graph.svg\"\)\( width.*\">\)\(.*$\)/<div class=\"center\"><img src\2 $PICSIZE><\/div>/" $WORKFILE
rm $WORKFILE.back
#!/bin/sh
# Modify all class overview pages of doxygen that have a "Collaboration diagram".
# This diagram is replaced by the list of libraries that this class uses.
# Finding the system we are running
export DOXYGEN_LDD="ldd"
listOfClasses=$(mktemp /tmp/listOfClasses_XXXXXX.txt)
OS=`uname`
case "$OS" in
"Linux") export DOXYGEN_LDD="ldd"
;;
"Darwin")export DOXYGEN_LDD="otool -L"
;;
esac
case "$1" in
-j*)
NJOB=${1#-j}
;;
esac
if [ ! -d "$DOXYGEN_OUTPUT_DIRECTORY" ]; then
echo "Need to export DOXYGEN_OUTPUT_DIRECTORY"
exit 1
fi
# Transform collaboration diagram into list of libraries
grep -sl "Collaboration diagram for" $DOXYGEN_OUTPUT_DIRECTORY/html/class*.html | sed -E "s/^.*html\/class([^[:space:]]+)\.html.*$/\1/" > ${listOfClasses}
if [ ! -s "${listOfClasses}" ]; then
echo "No class found to modify"
exit 0
fi
xargs -L 1 -P ${NJOB:-1} ./modifyClassWebpage.sh < ${listOfClasses}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment