2014-09-05 168 views
2

我有以下兩類:獅身人面像,apidoc沒有找到所有的Python文件

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 

我試圖運行斯芬克斯-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

Python包裝依賴於目錄樹。所以從你所做的,標準是一個包含兩個「子包」的包,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/ 

無*符號。

+0

我添加了「\ _ \ _ init _ _ _ _ py」和sphinx-apidoc創建的standard.rst,standard.test1.Test1.rst,standard.test1.rst,standard.test2.Test2.rst,standard。 test2.rst。 然而,讓HTML抱怨沒有名爲test1模塊,無模塊命名標準,無模塊命名standard.test1,無模塊命名standard.test1.Test1,無模塊命名standard.test2,無模塊命名standard.test2.Test2, /home/mictadlo/tmp/sphinx/docs/Test1.rst ::警告:文檔不包含在任何toctree – user977828 2014-09-05 10:04:13

+0

當然,您將獲得每個包和模塊的.rst文件,因此您的包中包含3個包和2個模塊。 Test1.rst文件由sphinx-apidoc的* previous *調用生成。要乾淨地開始,請清空您的文檔目錄。 抱怨是一個完全不同的問題。這是因爲你的src目錄不包含在你的路徑中。 – MathieuS 2014-09-05 10:43:13

+0

我認爲它已經工作了,但爲什麼是「模塊內容」空[文檔中](http://i.imgur.com/oUPvkGL.png?1)以及是否有任何的例子如何修改「\ _ \ _init \ _ \ _。py「來製作更好的標題,例如將「標準軟件包」更改爲「測試項目」並將「子軟件包」更改爲「標準軟件包」? – user977828 2014-09-05 12:09:25