sphinx-build fail - autodoc can't import/find module

前端 未结 8 1709
青春惊慌失措
青春惊慌失措 2020-12-04 15:17

I\'m trying to get started with Sphinx and seem to have relentless problems.

Command: docs/sphinx-quickstart

I answer all the questions and ever

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-04 15:40

    I don't know why (maybe in my case autodoc couldn't install my package), but I always got module-not-found errors until I explicitly included all directories containing modules to the path.

    For the following example folder structure

    project_dir
    |- setup.py
    |- src
    |  |- __init__.py
    |  |- source1.py
    |  |- sub_project
    |     |- __init__.py
    |     |- source2.py 
    |- docs
        |- conf.py
        |- source
        |  |- index.rst
        |- _build       
    

    I included

    for x in os.walk('../../src'):
      sys.path.insert(0, x[0])
    

    to the beginning of conf.py such that all involved directories would be added.

提交回复
热议问题