pdoc icon indicating copy to clipboard operation
pdoc copied to clipboard

pdoc3 programmatic-usage example

Open abubelinha opened this issue 2 years ago • 0 comments

I am not a fluent Python programmer. I mostly use standalone .py scripts, which sometimes call functions from other .py scripts. But they are not structured into modules, projects or whatever. I wonder if I still could use pdoc3 to generate .html doc files for some selected .py scripts in this context.

Do you have an example of how to use pdoc3 as a library for this purpose? I have an script which works perfectly when using original pdoc package, but couldn't make it run with pdoc3.

Expected Behavior

Make pdoc3 produce html documentation for a bunch of .py files, the same way original pdoc package does.

Actual Behavior

My simple pdoc-based script fails. I need to adapt it. I looked the programmatic-usage info in pdoc3 documentation but I find it over-complicated compared to the original pdoc programmatic usage example. Can't understand all these Context(), link_inheritance(), html(), text() ... please tell me how to use them to adapt the following script to pdoc3:

Steps to Reproduce

  1. pip install pdoc3
  2. run this script:
# create_pdoc.py
import pdoc
from pathlib import Path
myscripts = ["./myscript.py", "./path2/myscript.py", "./myscript3.py"]
pdoc.pdoc(*myscripts, output_directory=Path("./_mypdoc3"))
  1. Result
c:\Python38\python create_pdoc.py
Traceback (most recent call last):
  File "create_pdoc.py", line 4, in <module>
    pdoc.pdoc(*myscripts, output_directory=Path("./_mypdoc3"))
AttributeError: module 'pdoc' has no attribute 'pdoc'
  1. Changed last line from pdoc.pdoc(...) to pdoc(...), and got this result:
Traceback (most recent call last):
  File "create_pdoc.py", line 4, in <module>
    pdoc(*myscripts, output_directory=Path("./_mypdoc3"))
TypeError: 'module' object is not callable

Additional info

  • pdoc version: pdoc.exe 0.10.0

abubelinha avatar Dec 29 '21 20:12 abubelinha