简体   繁体   中英

sphinx-apidoc does not find all python files

I have the following two classes:

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

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

.

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

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

These classes are stored in different folders which is shown below:

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

I tried to run sphinx-apidoc, but it only finds Test1.rst with the following command:

$ 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.

If I remove * it finds nothing:

$ 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.

How is it possible to call sphinx-apidoc that it finds Test1.py and Test2.py?

Python packaging depends on directories tree. So from what you've done, standard is a package with two "subpackages", test1 and test2 . Each subpackage contains a module, either Test1 or Test2 .

You must add an (possibly) empty file called __init__.py to each directory containing a package and run

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/

without the * sign.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM