gpt4 book ai didi

python - sphinx-apidoc 找不到所有 python 文件

转载 作者:行者123 更新时间:2023-11-28 18:41:20 42 4
gpt4 key购买 nike

我有以下两个类:

class Test1():
"""Test1()"""

def fn_test1():
"""fn_test1 """
print "Hello1"

.

class Test2():
"""Test2()"""

def fn_test2():
"""fn_test2 """
print "Hello2"

这些类存储在不同的文件夹中,如下所示:

$ tree -A
.
├── docs
│ ├── _build
│ ├── conf.py
│ ├── index.rst
│ ├── make.bat
│ ├── Makefile
│ ├── _static
│ ├── _templates
│ └── Test1.rst
└── src
└── standard
├── test1
│ └── Test1.py
└── test2
└── Test2.py

我尝试运行 sphinx-apidoc,但它只能通过以下命令找到 Test1.rst:

$ sphinx-apidoc -f -A "Author" -H "Test project" -V "version 1.0" -R "release 2014" -F -d 4 -e -P -o docs /home/u/tmp/sphinx/src/standard/*
Creating file docs/Test1.rst.
Creating file docs/conf.py.
Creating file docs/index.rst.
Creating file docs/Makefile.
Creating file docs/make.bat.

如果我删除 * 它什么也找不到:

$ sphinx-apidoc -f -A "Author" -H "Test project" -V "version 1.0" -R "release 2014" -F -d 4 -e -P -o docs /home/u/tmp/sphinx/src/standard/
Creating file docs/conf.py.
Creating file docs/index.rst.
Creating file docs/Makefile.
Creating file docs/make.bat.

如何调用它找到 Test1.py 和 Test2.py 的 sphinx-apidoc?

最佳答案

Python 打包依赖于目录树。所以根据您所做的,standard 是一个包含两个“子包”的包,test1test2。每个子包都包含一个模块,Test1Test2

您必须向每个包含包的目录添加一个(可能)名为__init__.py 的空文件并运行

sphinx-apidoc -f -A "Author" -H "Test project" -V "version 1.0" -R "release 2014" -F -d 4 -e -P -o docs /home/u/tmp/sphinx/src/standard/

没有*号。

关于python - sphinx-apidoc 找不到所有 python 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25681394/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com