pdoc3 / pdoc

:snake: :arrow_right: :scroll: Auto-generate API documentation for Python projects
https://pdoc3.github.io/pdoc/
GNU Affero General Public License v3.0
1.12k stars 145 forks source link

pdoc3 programmatic-usage example #377

Open abubelinha opened 2 years ago

abubelinha commented 2 years ago

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"))
  3. 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'
  4. 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