nova/doc/generate_autodoc_index.sh
Doug Hellmann 1ea445c377 blueprint sphinx-doc-cleanup
bug 944381

Add logic to generate_autodoc_index.sh to produce rst underlines to match the heading strings.

Change-Id: Ib0f54a45fcc4ab6dfaa593c756682f1a25fdb420
2012-03-01 17:03:01 -05:00

46 lines
1016 B
Bash
Executable File

#!/bin/sh
SOURCEDIR=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.
let 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