4

I want to generate sphinx autodoc documentation from scripts in nested folder structure :

└── programs
    └── general_name
        └── another_folder
            ├── script1.py
            └── script2.py

For some reason script1.py and script2.py is not displayed with autodocs, I'm getting I can see just script name:

programs.general_name.another_folder package

¶Submodules

programs.general_name.another_folder.script1 module
programs.general_name.another_folder.script2 module

Full folder structure:

../
├── docs
│   ├── _build
│   │   ├── doctrees
│   │   │   ├── environment.pickle
│   │   │   ├── index.doctree
│   │   │   └── rst
│   │   └── html
│   │       ├── genindex.html
│   │       ├── index.html
│   │       ├── objects.inv
│   │       ├── rst
│   │       ├── search.html
│   │       ├── searchindex.js
│   │       ├── _sources
│   │       └── _static
│   ├── conf.py
│   ├── index.rst
│   ├── make.bat
│   ├── Makefile
│   ├── rst
│   │   ├── modules.rst
│   │   ├── programs.general_name.another_folder.rst
│   │   ├── programs.general_name.rst
│   │   └── programs.rst
│   ├── _static
│   └── _templates
└── programs
    └── general_name
        └── another_folder
            ├── script1.py
            └── script2.py

I'm running this command:

/docs $ sphinx-apidoc -f -o rst/ ../programs/ && make html

Also I tried:

$ sphinx-apidoc -f -o rst/ ../programs/general_name/another_folder/ && make html

But script1 module and script2 module are empty in generating html files.

Solution:

Found what was causing the problem - dash symbol "-". another_folder was actually named get_requests_from_server-10

After renaming folder to get_requests_from_server_10, auto-docks started to work

Nir Vana
  • 387
  • 3
  • 9

1 Answers1

3

According to the docs for sphinx-apidoc:

sphinx-apidoc is a tool for automatic generation of Sphinx sources that, using the autodoc extension, document a whole package in the style of other automatic API documentation tools.

sourcedir must point to a Python package.

(emphasis added)

According to this SO Answer:

Any Python file is a module, its name being the file's base name without the .py extension. A package is a collection of Python modules: while a module is a single Python file, a package is a directory of Python modules containing an additional __init__.py file, to distinguish a package from a directory that just happens to contain a bunch of Python scripts.

First add an empty __init__.py to each sourcedir, and see if that resolves the issue.

Steve Piercy
  • 13,693
  • 1
  • 44
  • 57