zaqar/tools/doc/generate_autodoc_index.sh
Victoria Martínez de la Cruz 99d49dd358 Adds the API reference to the devs guide
This fix adds the detailed API reference to the developers guide
as it's done in major projects in the stack.

It also fix Sphinx warning and errors and adds a .rst files
generator to easily update the api reference in the future.

Plus, it includes an index for API, modules and search.

Co-Authored-By: Flavio Percoco <fpercoco@redhat.com>

Change-Id: If42121c9e8e852785cb2db3aa5d6895223b9d604
2014-09-08 13:50:10 -03:00

46 lines
1020 B
Bash
Executable File

#!/bin/sh
SOURCEDIR=../../doc/source/api
if [ ! -d ${SOURCEDIR} ] ; then
mkdir -p ${SOURCEDIR}
fi
for x in `./find_autodoc_modules.sh`;
do
echo "Generating ${SOURCEDIR}/${x}.rst"
echo "${SOURCEDIR}/${x}.rst" >> .autogenerated
heading="The :mod:\`${x}\` module"
# Figure out how long the heading is
# and make sure to emit that many '=' under
# it to avoid heading format errors
# in Sphinx.
heading_len=$(echo "$heading" | wc -c)
underline=$(head -c $heading_len < /dev/zero | tr '\0' '=')
( cat <<EOF
${heading}
${underline}
.. automodule:: ${x}
:members:
:undoc-members:
:show-inheritance:
EOF
) > ${SOURCEDIR}/${x}.rst
done
if [ ! -f ${SOURCEDIR}/autoindex.rst ] ; then
cat > ${SOURCEDIR}/autoindex.rst <<EOF
.. toctree::
:maxdepth: 1
EOF
for f in `cat .autogenerated | sort` ; do
relative=`echo ${f} | sed -e 's$^'${SOURCEDIR}'/$$'`
echo " ${relative}" >> ${SOURCEDIR}/autoindex.rst
done
echo ${SOURCEDIR}/autoindex.rst >> .autogenerated
fi