这是我第一次尝试狮身人面像,所以我正在遵循本指南:https://daler.github.io/sphinxdoc-test/includeme.html。使用this Makefile投放make html
失败,Error 1
显示警告DeprecationWarning: 'U' mode is deprecated
。
以下是sphinx日志文件的完整回溯:
# Sphinx version: 1.4.9
# Python version: 3.5.2 (CPython)
# Docutils version: 0.12 release
# Jinja2 version: 2.8
# Last messages:
# Running Sphinx v1.4.9
# loading pickled environment...
# done
# building [mo]: targets for 0 po files that are out of date
# building [html]: targets for 2 source files that are out of date
# updating environment:
# 0 added, 2 changed, 0 removed
# reading sources... [ 50%] mainGUI
# reading sources... [100%] modules
# Loaded extensions:
# sphinx.ext.autodoc (1.4.9) from /usr/local/lib/python3.5/dist-packages/sphinx/ext/autodoc.py
# alabaster (0.7.9) from /home/federico/.local/lib/python3.5/site-packages/alabaster/__init__.py
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/sphinx/cmdline.py", line 244, in main
app.build(opts.force_all, filenames)
File "/usr/local/lib/python3.5/dist-packages/sphinx/application.py", line 297, in build
self.builder.build_update()
File "/usr/local/lib/python3.5/dist-packages/sphinx/builders/__init__.py", line 251, in build_update
'out of date' % len(to_build))
File "/usr/local/lib/python3.5/dist-packages/sphinx/builders/__init__.py", line 265, in build
self.doctreedir, self.app))
File "/usr/local/lib/python3.5/dist-packages/sphinx/environment.py", line 569, in update
self._read_serial(docnames, app)
File "/usr/local/lib/python3.5/dist-packages/sphinx/environment.py", line 589, in _read_serial
self.read_doc(docname, app)
File "/usr/local/lib/python3.5/dist-packages/sphinx/environment.py", line 738, in read_doc
encoding=self.config.source_encoding)
File "/usr/local/lib/python3.5/dist-packages/sphinx/io.py", line 107, in __init__
FileInput.__init__(self, *args, **kwds)
File "/home/federico/.local/lib/python3.5/site-packages/docutils/io.py", line 236, in __init__
self.source = open(source_path, mode, **kwargs)
DeprecationWarning: 'U' mode is deprecated
sphinx不会加载代码中嵌入的文档。
我一直在读,项目的结构可能是负责任的,但看起来我的还可以:
project/
docs/
Makefile
source/
conf.py
index.rst
modules.rst
project/
__init__.py
foo/
__init__.py
modA.py
modB.py
bar/
__init__.py
modC.py
modD.py
在例如modA.py中我输入如下代码:
import project.foo.modB
某些文件的相关位:
conf.py:
...
sys.path.insert(0, os.path.abspath('../..'))
...
index.rst:
.. toctree::
:maxdepth: 2
modules
modules.rst:
Modules
*******
Foo
===
.. automodule:: project.foo.modA
:members:
我在这里缺少什么?导入在解释器中正常工作:
import os
import sys
sys.path.append(os.path.join('/home', 'federico', 'project'))
import project.foo.modB