python - Sphinx 文档,自动模块的“缩短路径”
问题描述
我目前有一个看起来像这样的项目,我想使用Sphinx 文档来记录功能。这是它的结构:
+ project
|
+- docs
|
+- app -+- orange -+- routers -+- files (.py)
| |
other apps +- helpers -+- util.py
...
我想记录没有app.orange.routers
.
例如,我有一个名为test.py
in的文件app/orange/routers
,它有一个clear()
函数。我想记录test.clear()
而不是app.orange.routers.test.clear()
.
我试图放入sys.path.insert(0, os.path.abspath('../app/orange/routers'))
,conf.py
文件test.rst
看起来像这样。
Test
====
.. automodule:: test
:members:
:undoc-members:
:show-inheritance:
有些文件可以记录,但其中一些不能,我意识到它们的区别是那些无法记录的文件具有与导入相关的类似代码,例如from .helpers.util import *
,收到的警告如下所示:
WARNING: autodoc: failed to import module 'test'; the following exception was raised:
attempted relative import with no known parent package
我试图将test.rst
文件中的自动模块更改为.. automodule:: app.orange.routers.test
并且它可以工作,但这不是我想要的。
帮助表示赞赏!
解决方案
推荐阅读
- excel - 插入或删除行时更新公式
- javascript - JavaScript,了解为什么 `foreach` 实现比 `for` 慢
- javascript - 循环并拉入一定数量的数据
- python - 在python中复制matlab过滤器
- linux - 同时在 bluez 上使用中央和外围设备
- java - 无法使用带有 Web 应用程序 NetBeans 的 JDBC 连接数据库
- javascript - Drupal 8 Drupal.behaviors 没有 jquery
- java - 如何创建列表
并单击一个抛出 java.lang.IndexOutOfBoundsException 的选项 - javascript - 如何检测/处理低性能设备 Javascript
- python - plyvel 安装在 Windows 上