我正在尝试使用sphinx构建我的API文档,但是在构建它时出现此错误
使用命令sphinx-build -b html -d _build/doctrees . _build/html
Erorr日志:
$ make docs
rm -f docs/markovipy.rst
rm -f docs/modules.rst
sphinx-apidoc -o docs/ markovipy
Creating file docs/markovipy.rst.
Creating file docs/modules.rst.
/Library/Developer/CommandLineTools/usr/bin/make -C docs clean
rm -rf _build/*
/Library/Developer/CommandLineTools/usr/bin/make -C docs html
sphinx-build -b html -d _build/doctrees . _build/html
Running Sphinx v1.4.8
making output directory...
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 9 source files that are out of date
updating environment: 9 added, 0 changed, 0 removed
reading sources... [100%] usage
/Users/user/development/projects/markovipy/docs/index.rst:6: WARNING: toctree contains reference to nonexisting document 'authorshistory'
/Users/user/development/projects/markovipy/markovipy/utils.py:docstring of markovipy.utils.get_word_list:7: ERROR: Unknown target name: "a-za-z0-9".
../README.rst:None: WARNING: nonlocal image URI found: https://img.shields.io/pypi/v/markovipy.svg
../README.rst:None: WARNING: nonlocal image URI found: https://img.shields.io/travis/prodicus/markovipy.svg
../README.rst:None: WARNING: nonlocal image URI found: https://readthedocs.org/projects/markovipy/badge/?version=latest
../README.rst:None: WARNING: nonlocal image URI found: https://pyup.io/repos/github/prodicus/markovipy/shield.svg
looking for now-outdated files... none found
pickling environment... done
checking consistency... /Users/user/development/projects/markovipy/docs/authors.rst:: WARNING: document isn't included in any toctree
/Users/user/development/projects/markovipy/docs/history.rst:: WARNING: document isn't included in any toctree
/Users/user/development/projects/markovipy/docs/modules.rst:: WARNING: document isn't included in any toctree
done
preparing documents... done
writing output... [ 88%] readme
Exception occurred:
File "/Users/user/.virtualenvs/py3/lib/python3.6/site-packages/docutils/writers/_html_base.py", line 671, in depart_document
assert not self.context, 'len(context) = %s' % len(self.context)
AssertionError: len(context) = 3
The full traceback has been saved in /var/folders/sw/nsjcqtxs1yldt7y1gsqkfnw00000gn/T/sphinx-err-sz5bisnz.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.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
make[1]: *** [html] Error 1
make: *** [docs] Error 2
错误记录将其写入
# Sphinx version: 1.4.8
# Python version: 3.6.0 (CPython)
# Docutils version: 0.13.1 release
# Jinja2 version: 2.9.6
# Last messages:
# preparing documents...
# done
# writing output... [ 11%] authors
# writing output... [ 22%] contributing
# writing output... [ 33%] history
# writing output... [ 44%] index
# writing output... [ 55%] installation
# writing output... [ 66%] markovipy
# writing output... [ 77%] modules
# writing output... [ 88%] readme
# Loaded extensions:
# sphinx.ext.autodoc (1.4.8) from /Users/user/.virtualenvs/py3/lib/python3.6/site-packages/sphinx/ext/autodoc.py
# sphinx.ext.viewcode (1.4.8) from /Users/user/.virtualenvs/py3/lib/python3.6/site-packages/sphinx/ext/viewcode.py
# alabaster (0.7.10) from /Users/user/.virtualenvs/py3/lib/python3.6/site-packages/alabaster/__init__.py
Traceback (most recent call last):
File "/Users/user/.virtualenvs/py3/lib/python3.6/site-packages/sphinx/cmdline.py", line 244, in main
app.build(opts.force_all, filenames)
File "/Users/user/.virtualenvs/py3/lib/python3.6/site-packages/sphinx/application.py", line 297, in build
self.builder.build_update()
File "/Users/user/.virtualenvs/py3/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 251, in build_update
'out of date' % len(to_build))
File "/Users/user/.virtualenvs/py3/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 322, in build
self.write(docnames, list(updated_docnames), method)
File "/Users/user/.virtualenvs/py3/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 360, in write
self._write_serial(sorted(docnames), warnings)
File "/Users/user/.virtualenvs/py3/lib/python3.6/site-packages/sphinx/builders/__init__.py", line 368, in _write_serial
self.write_doc(docname, doctree)
File "/Users/user/.virtualenvs/py3/lib/python3.6/site-packages/sphinx/builders/html.py", line 448, in write_doc
self.docwriter.write(doctree, destination)
File "/Users/user/.virtualenvs/py3/lib/python3.6/site-packages/docutils/writers/__init__.py", line 80, in write
self.translate()
File "/Users/user/.virtualenvs/py3/lib/python3.6/site-packages/sphinx/writers/html.py", line 47, in translate
self.document.walkabout(visitor)
File "/Users/user/.virtualenvs/py3/lib/python3.6/site-packages/docutils/nodes.py", line 187, in walkabout
visitor.dispatch_departure(self)
File "/Users/user/.virtualenvs/py3/lib/python3.6/site-packages/docutils/nodes.py", line 1895, in dispatch_departure
return method(node)
File "/Users/user/.virtualenvs/py3/lib/python3.6/site-packages/docutils/writers/_html_base.py", line 671, in depart_document
assert not self.context, 'len(context) = %s' % len(self.context)
AssertionError: len(context) = 3
我用于conf.py
sphinx
文件
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import os
cwd = os.getcwd()
project_root = os.path.dirname(cwd)
sys.path.insert(0, project_root)
import markovipy
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode']
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix of source filenames.
source_suffix = '.rst'
master_doc = 'index'
# General information about the project.
project = u'markovipy'
copyright = u"2017, Tasdik Rahman"
version = markovipy.__version__
# The full version, including alpha/beta/rc tags.
release = markovipy.__version__
exclude_patterns = ['_build']
pygments_style = 'sphinx'
html_theme = 'default'
html_static_path = ['_static']
htmlhelp_basename = 'markovipydoc'
# -- Options for LaTeX output ------------------------------------------
latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#'papersize': 'letterpaper',
# The font size ('10pt', '11pt' or '12pt').
#'pointsize': '10pt',
# Additional stuff for the LaTeX preamble.
#'preamble': '',
}
latex_documents = [
('index', 'markovipy.tex',
u'markovipy Documentation',
u'Tasdik Rahman', 'manual'),
]
man_pages = [
('index', 'markovipy',
u'markovipy Documentation',
[u'Tasdik Rahman'], 1)
]
texinfo_documents = [
('index', 'markovipy',
u'markovipy Documentation',
u'Tasdik Rahman',
'markovipy',
'One line description of project.',
'Miscellaneous'),
]
有问题的存储库https://github.com/prodicus/markovipy/tree/master/docs
答案 0 :(得分:0)
使用Sphinx==1.4.8
升级到Sphinx==1.5.5