首页 > 解决方案 > 使用 Sphinx 生成文档时缺少类 make latexpdf

问题描述

我正在使用 Sphinx 在 python 中生成文档。虽然make html工作得很好,但我遇到了问题make latexpdf.tex文件生成不完整。它缺少一些描述,这些描述包含在 html 中。我看不出问题出在哪里?例如,Calendar 类不显示在 Latex 中:

乳胶 [1]:https ://i.stack.imgur.com/XVJYg.png HTML [2]:https ://i.stack.imgur.com/4daHV.png

conf.py正在使用:

import os
import sys
sys.path.insert(0, os.path.abspath('../../src'))
sys.setrecursionlimit(1500)
project = '..'
copyright = '..'
author = '..'
release = '2.0'
extensions = ['rinoh.frontend.sphinx', 'sphinx.ext.autodoc']
exclude_patterns = []
html_theme = 'alabaster'
html_static_path = ['_static']

dialogs.rst

GUI Dialogs
===========
Login
------
.. automodule:: dialogs.login
   :members:
   :undoc-members:
   :show-inheritance:
Calendar
--------
.. automodule:: dialogs.calendar
   :members:
   :undoc-members:
   :show-inheritance:

更新使用时会出现几个警告make latexpdf。我不知道他们是否是原因。对于日历模块和任何其他模块,警告如下:

WARNING: Explicit markup ends without a blank line; unexpected unindent.
WARNING: autodoc: failed to import module 'calendar' from module 'dialogs'; the following exception was raised:
 File "c:\users\user\pycharmprojects\gui\venv\lib\site-packages\sphinx\ext\autodoc\importer.py", line 70, in import_module
    return importlib.import_module(modname)
...
    data_loaded = threading.Event()
NameError: name 'threading' is not defined

看起来它无法识别该threading库。

标签: pythonlatexpython-sphinxautodoc

解决方案


您需要遵循错误的建议并添加空格和空行。还要确保下划线与其标题的长度相匹配。

为了便于阅读,我喜欢在下一节之前添加两个空行,但只需要一个。节标题后也不需要有空行,但我还是更喜欢它的可读性。

GUI Dialogs
===========


Login
-----

.. automodule:: dialogs.login
   :members:
   :undoc-members:
   :show-inheritance:


Calendar
--------

.. automodule:: dialogs.calendar
   :members:
   :undoc-members:
   :show-inheritance:

推荐阅读