【问题标题】:Sphinx documentation builds locally successfully with autodoc but when i try to build it on readthedocs all the pages became emptySphinx 文档使用 autodoc 在本地成功构建,但是当我尝试在 readthedocs 上构建它时,所有页面都变空了
【发布时间】:2021-12-19 05:02:06
【问题描述】:

我正在尝试将我已完成的代码文档放在 readthedocs 上,但所有页面都变成了空白。我已经尝试了一整天,我已经观看/阅读了数十篇教程,但没有任何效果。当我在本地进行时,它会正常构建。

目录是这样组织的:

/root:/docs、module1.py、module2.py、module3.py、.readthedocs.yml

根/文档:/_build、/_static、/_templates、conf.py、index.rst、make.bat、Makefile、requirements.txt、module1.rst、module2.rst、module3.rst

我会在下面留下 .readthedocs.yml、conf.py 和 requirements.txt 的代码,让你看看我有没有做错什么。我厌倦了这么多尝试让这件事工作,请帮助我

#readthedocs.yml
version: 2
sphinx:
  configuration: docs/conf.py
formats: all
python:
  version: 3.8
  install:
    - requirements: docs/requirements.txt
#conf.py
import sphinx_rtd_theme
import os
import sys
sys.path.insert(0, os.path.abspath('..'))
project = 'MolOpt'
copyright = '2021, estevaopbs'
author = 'estevaopbs'
extensions = [
    'sphinx.ext.autodoc'
]
templates_path = ['_templates']
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
html_theme = 'sphinx_rtd_theme'
html_static_path = ['_static']
#requirements.txt
sphinx_rtd_theme==1.0.0

【问题讨论】:

标签: python python-sphinx restructuredtext read-the-docs


【解决方案1】:

正如@Steve Piercy 所说,发生这种情况是因为 Sphinx 在尝试导入您的项目时发现了一个异常。你可以在这里看到:

https://readthedocs.org/projects/molopt/builds/15211653/

特别是在/home/docs/checkouts/readthedocs.org/user_builds/molopt/envs/latest/bin/python -m sphinx -T -E -b html -d _build/doctrees -D language=en . _build/html 命令下,

WARNING: autodoc: failed to import module 'MolOpt'; the following exception was raised:
Traceback (most recent call last):
  File "/home/docs/checkouts/readthedocs.org/user_builds/molopt/envs/latest/lib/python3.8/site-packages/sphinx/ext/autodoc/importer.py", line 70, in import_module
    return importlib.import_module(modname)
  File "/home/docs/checkouts/readthedocs.org/user_builds/molopt/envs/latest/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/docs/checkouts/readthedocs.org/user_builds/molopt/checkouts/latest/MolOpt.py", line 2, in <module>
    from genetic import *
  File "/home/docs/checkouts/readthedocs.org/user_builds/molopt/checkouts/latest/genetic.py", line 23, in <module>
    class Chromosome:
  File "/home/docs/checkouts/readthedocs.org/user_builds/molopt/checkouts/latest/genetic.py", line 29, in Chromosome
    def __init__(self, genes: Any = None, fitness: Any = None, strategy: list[Callable[[Chromosome], Genes]] = [],
TypeError: 'ABCMeta' object is not subscriptable

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-10
    • 2022-07-18
    • 2019-11-29
    • 1970-01-01
    • 1970-01-01
    • 2021-10-23
    相关资源
    最近更新 更多