0

Sphinx seems to be ignoring imports in autodoc'ed modules.

doc/conf.py excerpt

import os
import sys
sys.path.insert(0, os.path.abspath('..'))
sys.setrecursionlimit(1500)

doc/code.rst

Auto Generated Documentation
============================

Utils
-----

.. automodule:: myproject.utils
   :members:

myproject/utils/__init__.py

from data import *
from hashing import *
from redis import *
from cookie import *
from route import *

def method_whose_docstring_is_picked_up(string):
    """I'm being autodoc'ed. =)
    """

None of the classes or functions from X import Y are being autodoc'ed. Anything directly in the __init__.py is being picked up just not the imports. I tried explicitly importing each object but that didn't resolve anything.

Chris Cummings
  • 2,007
  • 5
  • 25
  • 39
  • Does it work if you add an `__all__` list? See https://stackoverflow.com/q/30856279/407651 – mzjn Jul 12 '19 at 18:38
  • "An option to automodule is either unknown or has an invalid id value: '__all__' ". Doesn't seem to. – Chris Cummings Jul 15 '19 at 16:19
  • `__all__` is not an option to `automodule`, it is a variable that can be added to `__init__.py` (see https://docs.python.org/2/tutorial/modules.html#importing-from-a-package). – mzjn Jul 15 '19 at 20:49

1 Answers1

0

Turns out this is possible with the imported-members but it will also drag in all std-lib and third-party imports as well, cluttering up your sphinx doc.

Sphinx, using automodule to find submodules

Chris Cummings
  • 2,007
  • 5
  • 25
  • 39