sphinx-build が失敗しました - autodoc がモジュールをインポート/検索できません 質問する

sphinx-build が失敗しました - autodoc がモジュールをインポート/検索できません 質問する

Sphinx を使い始めようとしているのですが、問題が絶え間なく続いているようです。

指示:docs/sphinx-quickstart

すべての質問に答えると、すべて正常に動作します。

指示:docs/ls

すべて正常に見えます。結果:build Makefile source

指示:sphinx-build -d build/doctrees source build/html

動作するようです。index.html ファイルを開いて、必要な「シェル」を確認することができました。

実際のソース コードをフォルダーとして配置しようとすると、source問題が発生します。

指示:sphinx-build -d build/doctrees ../ys_utils build/html

結果:

Making output directory...
Running Sphinx v1.1.3
loading pickled environment... not yet created
No builder selected, using default: html
loading intersphinx inventory from http://docs.python.org/objects.inv...
building [html]: targets for 1 source files that are out of date
updating environment: 1 added, 0 changed, 0 removed
Traceback (most recent call last):                                                                                               
  File "/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
ImportError: No module named ys_utils
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
ImportError: No module named ys_utils.test_validate_ut
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
ImportError: No module named ys_utils.git_utils
Traceback (most recent call last):
  File "/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/ext/autodoc.py", line 321, in import_object
    __import__(self.modname)
ImportError: No module named setup.setup

/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:4: WARNING: autodoc can't import/find module 'ys_utils', it reported error: "No module named ys_utils", please check your spelling and sys.path
/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:10: WARNING: autodoc can't import/find module 'ys_utils.test_validate_ut', it reported error: "No module named ys_utils.test_validate_ut", please check your spelling and sys.path
/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:12: WARNING: don't know which module to import for autodocumenting u'UnitTests' (try placing a "module" or "currentmodule" directive in the document, or giving an explicit module name)
/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:18: WARNING: autodoc can't import/find module 'ys_utils.git_utils', it reported error: "No module named ys_utils.git_utils", please check your spelling and sys.path
/home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:24: WARNING: autodoc can't import/find module 'setup.setup', it reported error: "No module named setup.setup", please check your spelling and sys.path
WARNING: master file /home/ricomoss/workspace/nextgen/ys_utils/index.rst not found
looking for now-outdated files... none found
pickling environment... done
checking consistency... /home/ricomoss/workspace/nextgen/ys_utils/ys_utils.rst:: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [ 50%] index                                                                                                   
Exception occurred:
  File "/usr/local/lib/python2.6/dist-packages/Sphinx-1.1.3-py2.6.egg/sphinx/environment.py", line 1213, in get_doctree
    f = open(doctree_filename, 'rb')
IOError: [Errno 2] No such file or directory: '/home/ricomoss/workspace/nextgen/docs/build/doctrees/index.doctree'
The full traceback has been saved in /tmp/sphinx-err-jjJ7gM.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
Either send bugs to the mailing list at <http://groups.google.com/group/sphinx-dev/>,
or report them in the tracker at <http://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!

何が問題なのでしょうか、どうすれば修正できるのでしょうか?

編集:

これを処理するために Makefile を使用できるようにしたいと思います。現在、プロジェクトには 2 つのフォルダーがあります。

nextgen/ls

docs ys_utils

使用するすべてのモジュールnextgen/docs/Makefileの HTML を生成する必要があります。ys_utils

ベストアンサー1

Autodoc はモジュールを見つけることができません。モジュールは に存在しませんsys.path

sys.pathのにモジュールへのパスを含める必要がありますconf.py。 の先頭conf.py( のインポートの直後) を見ると、適応できるステートメントsysがあります。sys.path.insert()

ちなみに、MakefileSphinxで作成されたものを使ってドキュメントを作成することもできます。

make

オプションを表示します。

以前に何か問題が発生した場合は、以下を試してください。

make clean

実行する前にmake html

おすすめ記事