Document two python applications with similar structure using sphinx

88 Views Asked by At

The folder structure looks as follows:

|- ext
|   | - app.py
|   | - extensions.py (creates db instance)
|   | - models/ (containing sqlalchemy models)
|   | - routes/ (containing endpoint-files)
|- services
|   | - app.py
|   | - extensions.py (creates db instance)
|   | - models/ (containing sqlalchemy models)
|   | - routes/ (containing endpoint-files)
|- docs
|   | [sphinx data]

Both flask applications belong to one project, but cannot be merged. Normally i would just extend the path in the sphinx conf.py like this:

sys.path.append(os.path.join(up(up(os.path.dirname(__file__))), "server", "services"))

But when i use this i can only access the methods of either the routes services or ext.

.. automodule:: routes.auth
    :members:
    :undoc-members:

If i only append the path one dir higher like this:

sys.path.append(os.path.join(up(up(os.path.dirname(__file__))), "server"))

and try to import the module like:

.. automodule:: services.routes.auth
    :members:
    :undoc-members:

I get the error

WARNING: autodoc: failed to import module 'auth' from module 'services.routes'; the following exception was raised:
No module named 'extensions'

when trying to build the document.

What would be the proper solution for the issue?

0

There are 0 best solutions below