Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[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 -e
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   set -x
17   rm -rf build/xml source/api/
18   (cd source; doxygen 2>&1; cd ..) | grep -v "is not documented." #   XXXXX Reduce the verbosity for now
19   set +x
20 fi
21
22 if [ "x$1" != 'xlogs' ] && [ -e build/log_categories.rst ] ; then
23   echo "Log categories not extracted: 'logs' was not provided as an argument"
24 else
25   set -x
26   perl ./bin/extract_logs_hierarchy.pl ../ > build/log_categories.rst
27   set +x
28 fi 
29
30 if [ "x$1" != 'xjava' ] && [ -e source/java ] ; then
31   echo "javasphinx not rerun: 'java' was not provided as an argument"
32 else
33   set -x
34   rm -rf source/java
35   
36   # Use that script without installing javasphinx: javasphinx-apidoc --force -o source/java/ ../src/bindings/java/org/simgrid/msg
37   PYTHONPATH=${PYTHONPATH}:source/_ext/javasphinx python3 - --force -o source/java/ ../src/bindings/java/org/simgrid/msg <<EOF
38 import re
39 import sys
40 from javasphinx.apidoc import main
41 if __name__ == '__main__':
42     sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
43     sys.exit(main())
44 EOF
45
46   rm -f source/java/packages.rst # api_generated/source_java_packages.rst
47   rm -f source/java/org/simgrid/msg/package-index.rst # api_generated/source_java_org_simgrid_msg_package-index.rst
48   for f in source/java/org/simgrid/msg/* ; do
49     # Add the package name to the page titles
50     (printf "class org.simgrid.msg."; cat $f )>tmp
51     mv tmp $f
52     sed -i 's/==/========================/' $f # That's the right length knowing that I add 'class org.simgrid.msg.'
53   done
54 #  sed -i 's/^.. java:type:: public class /.. java:type:: public class org.simgrid.msg/' source/java/org/simgrid/msg/*
55   echo "javasphinx relaunched"
56 fi
57
58 PYTHONPATH=../lib:source/_ext/javasphinx sphinx-build -M html source build ${SPHINXOPTS} 2>&1
59
60 set +x
61
62 perl -pe 's/(xlink:href="(?:http|.*\.html))/target="_top" $1/' \
63      source/img/graphical-toc.svg > build/html/graphical-toc.svg
64
65 echo
66 echo "Undocumented examples:"
67 for ex in $( (cd .. ; \
68               find examples/s4u/ -name '*.cpp'; \
69               find examples/c/ -name '*.c'; \
70               find examples/python -name '*.py'; \
71              ) | sort )
72 do
73     if grep -q "example-tab:: $ex" ../examples/README.rst ; then :
74 #        echo "found example-tab:: $ex"
75     elif grep -q "showfile:: $ex" ../examples/README.rst ; then :
76     else
77         echo $ex
78     fi
79 done
80
81 set +e # Don't fail
82 if [ -e /usr/bin/linkchecker ] ; then
83     linkchecker --no-status -o csv --ignore-url='.*\.css$' --ignore-url=build/html/_modules  --ignore-url=public/java/org build/html \
84      | grep -v '^#' \
85      | grep -v 'urlname;parentname;baseref;result;warningstring'
86   echo "done."
87 else
88   echo "Install linkchecker to have it executed when you build the doc."
89 fi
90