Logo AND Algorithmique Numérique Distribuée

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