Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'adrien' into 'master'
[simgrid.git] / docs / Build.sh
1 #! /bin/bash
2 #
3 # Simplistic script to rebuild our documentation with sphinx-build
4
5 # If you are missing some dependencies, try: pip3 install --requirement docs/requirements.txt
6
7 # Python needs to find simgrid on my machine, but not ctest -- sorry for the hack
8 if [ -e /opt/simgrid ] ; then chmod +x /opt/simgrid; fi
9
10 set -ex
11 set -o pipefail
12
13 if [ "x$1" != 'xdoxy' ] && [ -e build/xml ] ; then
14   echo "Doxygen not rerun: 'doxy' was not provided as an argument"
15 else
16   rm -rf build/xml source/api/
17   (cd source; doxygen 2>&1; cd ..) | grep -v "is not documented." #   XXXXX Reduce the verbosity for now
18 fi
19
20 if [ "x$1" != 'xjava' ] && [ -e source/java ] ; then
21   echo "javasphinx not rerun: 'java' was not provided as an argument"
22 else
23   rm -rf source/java
24   
25   # Use that script without installing javasphinx: javasphinx-apidoc --force -o source/java/ ../src/bindings/java/org/simgrid/msg
26   PYTHONPATH=${PYTHONPATH}:source/_ext/javasphinx python3 - --force -o source/java/ ../src/bindings/java/org/simgrid/msg <<EOF
27 import re
28 import sys
29 from javasphinx.apidoc import main
30 if __name__ == '__main__':
31     sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
32     sys.exit(main())
33 EOF
34
35   rm -f source/java/packages.rst # api_generated/source_java_packages.rst
36   rm -f source/java/org/simgrid/msg/package-index.rst # api_generated/source_java_org_simgrid_msg_package-index.rst
37   for f in source/java/org/simgrid/msg/* ; do
38     # Add the package name to the page titles
39     (printf "class org.simgrid.msg."; cat $f )>tmp
40     mv tmp $f
41     sed -i 's/==/========================/' $f # That's the right length knowing that I add 'class org.simgrid.msg.'
42   done
43 #  sed -i 's/^.. java:type:: public class /.. java:type:: public class org.simgrid.msg/' source/java/org/simgrid/msg/*
44   echo "javasphinx relaunched"
45 fi
46
47 PYTHONPATH=../lib:source/_ext/javasphinx sphinx-build -M html source build ${SPHINXOPTS} 2>&1
48
49 set +x
50
51 perl -pe 's/(xlink:href="(?:http|.*\.html))/target="_top" $1/' \
52      source/img/graphical-toc.svg > build/html/graphical-toc.svg
53
54 echo
55 echo "Undocumented examples:"
56 for ex in $( (cd .. ; \
57               find examples/s4u/ -name '*.cpp'; \
58               find examples/c/ -name '*.c'; \
59               find examples/python -name '*.py'; \
60              ) | sort )
61 do
62     if grep -q "example-tab:: $ex" ../examples/README.rst ; then :
63 #        echo "found example-tab:: $ex"
64     elif grep -q "showfile:: $ex" ../examples/README.rst ; then :
65     else
66         echo $ex
67     fi
68 done
69
70 set +e # Don't fail
71 if [ -e /usr/bin/linkchecker ] ; then
72     linkchecker --no-status -o csv --ignore-url='.*\.css$' --ignore-url=build/html/_modules  --ignore-url=public/java/org build/html \
73      | grep -v '^#' \
74      | grep -v 'urlname;parentname;baseref;result;warningstring'
75   echo "done."
76 else
77   echo "Install linkchecker to have it executed when you build the doc."
78 fi
79