0

I am trying to generate docs but am running into a warning in the command line. I've been searching the site and can't find a working solution for me. I narrowed the cause down to the import in ClassB.

My folder structure is:

folder structure

The __init__.py files have no content.

classA.rst:

classA
======

.. automodule:: app.ClassA
    :members:

classB.rst:

classB
======

.. automodule:: app.ClassB
    :members:

index.rst (toctree only):

.. toctree::
   :maxdepth: 2
   :caption: Contents:

   classA
   classB

conf.py (path only):

sys.path.insert(0, os.path.abspath('../src'))

ClassA.py:

class A:
    def sayNo(self):
        print('NO!')

ClassB.py:

from ClassA import A

class B:
    def sayNoB(self):
        no = A()
        no.sayNo()

The warning from the command line:

WARNING: autodoc: failed to import module 'ClassB' from module 'app'; the following exception was raised:
No module named 'ClassA'
mzjn
  • 48,958
  • 13
  • 128
  • 248
SomeDutchGuy
  • 2,249
  • 4
  • 16
  • 42

1 Answers1

1

As for me you should use relative import - with dot

from .ClassA import A
furas
  • 134,197
  • 12
  • 106
  • 148