Я пытался собрать документацию для проекта Python, используя Sphinx с темой rtd , и обнаружил следующую ошибку:
make_toctree() got an unexpected keyword argument 'titles_only'
Насколько я могу судить, эта ошибка не сообщается / не описывается в сети (пока).Документация была построена правильно около шести месяцев назад, и в конфигурации проекта не было никаких изменений, что говорит мне о том, что эта ошибка происходит из-за python и sphinx, а не из самого проекта.
У меня естьпопытался удалить и переустановить sphinx и тему rtd, как из synaptic, так и из pip --user
, (и попытался установить только один из них / активный в данный момент времени), и ошибка, похоже, сохраняется.
Кажется, что titles_only
должно быть допустимым ключевым словом для передачи в библиотеку sphinx, так что это говорит о том, что, возможно, было какое-то изменение API, которое нарушило тему rtd?
Я потратил пару часов сейчас, пытаясь перестроить документацию, и у меня не хватает времени, чтобы углубиться в это, поэтому я решил спросить Stackoverflow на случай, если кто-то еще столкнулся с этими знал исправление.
edit: номера версий пакетов могут быть полезны
sphinx-rtd-theme==0.1.9
sphinxcontrib-fulltoc==1.2.0
edit: эти команды используются для составления документации
sphinx-apidoc -fe -o . ./$PROJECTNAME
make SPHINXOPTS='-W' clean html
make-файл
# Minimal makefile for Sphinx documentation
#
# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = Neurotools
SOURCEDIR = .
BUILDDIR = _build
# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
.PHONY: help Makefile
# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
Этому файлу конфигурации sphinx несколько лет, и я не уверен на 100%, какие изменения были внесены в историю проекта.Я (надеюсь) удалил идентифицирующую информацию из содержания:
# -- General configuration ------------------------------------------------
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
'sphinx.ext.napoleon',
]
# special code to handle different versions of sphinx gracefully
import sys, os
assert 'sphinx' in sys.modules
mathjax_path="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"
sys.path.insert(0,os.path.abspath("./PROJECTNAMEPATH/"))
mod = __import__('sphinx')
potential_version_variable_names = ['__version__','__VERSION__','VERSION','version','version_info']
loaded_version = None
if loaded_version is None:
for vname in potential_version_variable_names:
if vname in mod.__dict__:
# try to find version information,
# just hope and pray it's a string if it exists
# take only the first line if multiple lines exist
loaded_version = mod.__dict__[vname]
break
if loaded_version is None:
try:
loaded_version = pkg_resources.get_distribution(package).version
except:
pass
if loaded_version is None:
if package in installed_via_pip:
p = installed_via_pip[package]
if p.has_version:
loaded_version = p.version
if loaded_version is None:
sys.stdout.write('\tNo sphinx version information found.')
else:
loaded_version = loaded_version.split('\n')[0]
loaded_version = tuple(map(int,loaded_version.split('.')))
sys.stdout.write('\tSphinx version '+str(loaded_version)+'\n')
if loaded_version>=(1,4):
extensions += [
'sphinxcontrib.fulltoc',
'sphinx.ext.githubpages',]
sys.stdout.write('\tAdding github pages module\n')
else:
sys.stdout.write('\tPlease update Sphinx to use the github pages module\n')
# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
# The master toctree document.
master_doc = 'index'
# General information about the project.
project = u'PROJECTNAME'
copyright = u'2017, AUTHORS'
author = u'AUTHORS'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = u'2'
# The full version, including alpha/beta/rc tags.
release = u'2'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This patterns also effect to html_static_path and html_extra_path
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store','extract_doc.py']
# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True
# -- Options for HTML output ----------------------------------------------
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
#html_theme = 'alabaster'
html_theme = "sphinx_rtd_theme"
# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
# -- Options for HTMLHelp output ------------------------------------------
# Output file base name for HTML help builder.
htmlhelp_basename = 'PROJECTNAME'
# -- 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 figure (float) alignment
#
# 'figure_align': 'htbp',
}
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'PROJECTNAME.tex', u'PROJECTNAME Documentation',
u'AUTHORS', 'manual'),
]
# -- Options for manual page output ---------------------------------------
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'PROJECTNAME', u'PROJECTNAME Documentation',
[author], 1)
]
# -- Options for Texinfo output -------------------------------------------
# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'PROJECTNAME', u'PROJECTNAME Documentation',
author, 'PROJECTNAME', 'One line description of project.',
'Miscellaneous'),
]
# -- Options for Epub output ----------------------------------------------
# Bibliographic Dublin Core info.
epub_title = project
epub_author = author
epub_publisher = author
epub_copyright = copyright
# A list of files that should not be packed into the epub file.
epub_exclude_files = ['search.html']
####### FURHTHER CUSTOMIZATION ########
html_sidebars = { '**': ['globaltoc.html', 'relations.html', 'sourcelink.html', 'searchbox.html'], }
html_theme_options = {'navigation_depth': 5,}
extensions += ['sphinx.ext.autosummary',]
autodoc_default_flags = ['members']
autosummary_gerenerate = True
exclude_patterns = ['_auto/*']
autodoc_member_order = 'bysource'