如何修复Sphinx“警告:自动模块的无效签名”错误

时间:2019-08-30 11:15:00

标签: python python-sphinx autodoc

我目前正在编写一些代码,并不断收到以下警告/错误(这是多个示例):

  

警告:自动模块的签名无效   ('components.component-1.orc_component_1.app)警告:不知道   导入哪个模块进行自动记录   'components.component-1.orc_component_1.app'(尝试放置“模块”   或文档中的“ currentmodule”指令,或给出明确的   模块名称)

我尝试更改点“。”在文件中使用正斜杠“ /”进行转发,从而设置了组件的路径,没有任何运气。

下面,我草绘了该项目的简化表示形式以及如何构建sphinx文档:

.
|-- README.rst
|-- components
|   |-- component-1
|   |   |-- README.rst
|   |   |-- orc_component_1
|   |   |   |-- app.py
|   |   |   |-- services.py
|   |   |   `-- utils.py
|   |-- component-2
|   |   |-- README.rst
|   |   |-- orc_component_2
|   |   |   |-- app.py
|   |   |   |-- services.py
|   |   |   `-- utils.py
|-- docs
|   |-- Makefile
|   |-- build
|   |   |-- doctrees
|   |   `-- html
|   |-- make.bat
|   `-- source
|       |-- _static
|       |-- _templates
|       |-- components.rst
|       |-- conf.py
|       |-- index.rst
|       |-- readme_components.rst

... and so on

在conf.py中,sys.path设置为:

import os
import sys
sys.path.insert(0, os.path.abspath('../..'))

index.rst:

Welcome!
========


.. toctree::
   :maxdepth: 2
   :caption: Modules:


components
readme-components


Indices and tables
==================


* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

readme_components:

.. include:: ../../README.rst

.. include:: ../../component-1/README.rst

.. include:: ../../component-2/README.rst

组件(仅是我们要记录的组件)

component-1
===========


.. automodule:: components.component-1.orc_component_1.app
   :members:


.. automodule:: components.component-1.orc_component_1.services
   :members:


.. automodule:: components.component-1.orc_component_1.utils
   :members:


component-2
===========


.. and so on

我认为这与子目录名称中的“-”有关,不确定。由于有多个人在处理-并且使用代码,因此我无法更改目录名称。

您知道是否有一种方法可以解决此错误并仍然记录脚本吗?还是狮身人面像中有一些设置可以更改以适应这种情况?

谢谢

最好的祝福,比尔吉特

0 个答案:

没有答案