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

时间:2014-09-05 08:14:43

标签: python python-sphinx

我有以下两个类:

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.

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

1 个答案:

答案 0 :(得分:1)

Python打包依赖于目录树。因此,根据您的工作,标准是一个包含两个“子包”的包, test1 test2 。每个子包都包含一个模块, Test1 Test2

您必须将一个名为 __ 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/

没有*符号。