首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >sphinx-apidoc并不能找到所有python文件。

sphinx-apidoc并不能找到所有python文件。
EN

Stack Overflow用户
提问于 2014-09-05 08:14:43
回答 1查看 2.4K关注 0票数 3

我有以下两门课:

代码语言:javascript
复制
class Test1():
    """Test1()"""

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

代码语言:javascript
复制
class Test2():
    """Test2()"""

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

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

代码语言:javascript
复制
$ tree -A
.
├── docs
│   ├── _build
│   ├── conf.py
│   ├── index.rst
│   ├── make.bat
│   ├── Makefile
│   ├── _static
│   ├── _templates
│   └── Test1.rst
└── src
    └── standard
        ├── test1
        │   └── Test1.py
        └── test2
            └── Test2.py

我试图运行sphinx,但是它只使用以下命令找到了Test1.rst:

代码语言:javascript
复制
$ 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.

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

代码语言:javascript
复制
$ 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来找到Test1.py和Test2.py?

EN

回答 1

Stack Overflow用户

发布于 2014-09-05 09:09:28

Python打包依赖于目录树。因此,从您所做的工作来看,标准是一个包含两个“子包”( test1和test2 )的包。每个子包都包含一个模块,要么是Test1,要么是Test2。

必须将名为__init__.py的(可能)空文件添加到包含包的每个目录中,然后运行

代码语言:javascript
复制
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/

没有*标志。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25681394

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档