fix python code index page.

The recent change to use a dlib/__init__.py file instead of the dlib.so file directly messed it up.
This commit is contained in:
Davis King 2020-08-13 09:00:27 -04:00
parent 59b44849bd
commit f55a1a51a0
4 changed files with 27 additions and 13 deletions

2
.gitignore vendored
View File

@ -15,4 +15,4 @@ docs/docs/cache/
docs/docs/git-logs.xml docs/docs/git-logs.xml
docs/docs/python/classes.txt docs/docs/python/classes.txt
docs/docs/python/functions.txt docs/docs/python/functions.txt
docs/docs/python/constants.txt

View File

@ -1,32 +1,36 @@
from __future__ import print_function from __future__ import print_function
import dlib import _dlib_pybind11
import inspect import inspect
def print_element(name, fc, ff): def print_element(name, fc, ff, fconstants):
isclass = inspect.isclass(eval(name)) isclass = inspect.isclass(eval(name))
ismodule = inspect.ismodule(eval(name)) ismodule = inspect.ismodule(eval(name))
isroutine = inspect.isroutine(eval(name))
if (isclass): if (isclass):
print("* :class:`{0}`".format(name), file=fc) print("* :class:`{0}`".format(name), file=fc)
elif (not ismodule): elif (isroutine):
print("* :func:`{0}`".format(name), file=ff) print("* :func:`{0}`".format(name), file=ff)
elif (not ismodule):
print("* :const:`{0}`".format(name), file=fconstants)
def make_listing_files(): def make_listing_files():
fc = open('classes.txt', 'w') fc = open('classes.txt', 'w')
ff = open('functions.txt', 'w') ff = open('functions.txt', 'w')
fconstants = open('constants.txt', 'w')
for obj in dir(dlib): for obj in dir(_dlib_pybind11):
if obj[0] == '_': if obj[0] == '_':
continue continue
print_element('dlib.'+obj, fc, ff) print_element('_dlib_pybind11.'+obj, fc, ff, fconstants)
for obj in dir(dlib.cuda): for obj in dir(_dlib_pybind11.cuda):
if obj[0] == '_': if obj[0] == '_':
continue continue
print_element('dlib.cuda.'+obj, fc, ff) print_element('_dlib_pybind11.cuda.'+obj, fc, ff, fconstants)
for obj in dir(dlib.image_dataset_metadata): for obj in dir(_dlib_pybind11.image_dataset_metadata):
if obj[0] == '_': if obj[0] == '_':
continue continue
print_element('dlib.image_dataset_metadata.'+obj, fc, ff) print_element('_dlib_pybind11.image_dataset_metadata.'+obj, fc, ff, fconstants)

View File

@ -20,6 +20,11 @@ Functions
.. include:: functions.txt .. include:: functions.txt
Constants
==============================================
.. include:: constants.txt
Detailed API Listing Detailed API Listing
============================================== ==============================================
@ -27,15 +32,15 @@ Detailed API Listing
.. toctree:: .. toctree::
:maxdepth: 2 :maxdepth: 2
.. automodule:: dlib .. automodule:: _dlib_pybind11
:members: :members:
:undoc-members: :undoc-members:
.. automodule:: dlib.cuda .. automodule:: _dlib_pybind11.cuda
:members: :members:
:undoc-members: :undoc-members:
.. automodule:: dlib.image_dataset_metadata .. automodule:: _dlib_pybind11.image_dataset_metadata
:members: :members:
:undoc-members: :undoc-members:

View File

@ -141,6 +141,11 @@ makedocs ()
cd .. cd ..
python setup.py build || report_failure python setup.py build || report_failure
python setup.py build_sphinx -c docs/docs/python --build-dir docs/sphinx.$$ || report_failure python setup.py build_sphinx -c docs/docs/python --build-dir docs/sphinx.$$ || report_failure
# sphinx will read in the _dlib_pybind11 module and use that to name everything. But that's
# not what we want, so we rename that to dlib everywhere. You would think sphinx would be
# able to deal with the dlib/__init__.py file and this wouldn't be necessary, but that
# doesn't seem to be the case.
find docs/sphinx.$$ -type f | xargs sed -i -e "s/_dlib_pybind11/dlib/g"
cd docs cd docs
cp -r sphinx.$$/html docs/web/python cp -r sphinx.$$/html docs/web/python
mv sphinx.$$/html docs/chm/docs/python mv sphinx.$$/html docs/chm/docs/python