0

I tried to generate documentation for my python project using pydoc.

My repository looks like this:

main.py
src/
├─ cli.py
├─ ui.py

In the main.py file, I have these imports:

import argparse
import sys
from PyQt5 import QtWidgets

from src.cli import CommandLineTool
from src.ui import UserInterfaceTool

When I tried to generate the documentation using python -m pydoc -w main, it worked but there is no reference to the src.cli and src.ui modules. Here is the modules part in HTML:

<tr><td class="decor pkg-content-decor"><span class="code">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></td><td>&nbsp;</td>
<td class="singlecolumn"><table><tr><td class="multicolumn"><a href="PyQt5.QtWidgets.html">PyQt5.QtWidgets</a><br>
</td><td class="multicolumn"><a href="argparse.html">argparse</a><br>
</td><td class="multicolumn"><a href="sys.html">sys</a><br>
</td><td class="multicolumn"></td></tr></table></td></tr></table>
</body></html>

I generated the docs for src.ui and src.cli using python -m pydoc -w src.ui and python -m pydoc -w src.cli but the result is still the same. Do you know if it's something that is doable with pydoc, or if I maybe missed a parameter or an option somewhere ?

1 Answer 1

0

Add an empty __init__.py to your src folder so pydoc treats it as a package:

main.py
src/
├── __init__.py   # Empty file
├─ cli.py
└─ ui.py

Create it with:

touch src/__init__.py

... or manually in your editor/IDE.

Sign up to request clarification or add additional context in comments.

1 Comment

I just tried it and the result is still the same

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.