pdoc: Inconsistent module names when specifying multiple paths

I have one related question about the html output after running the above script.

# script full path: C:\Dropbox\python\create_pdoc.py
import pdoc
from pathlib import Path
myscripts = ["./myscript.py", "./path2/myscript.py", "./myscript3.py"]
pdoc.pdoc(*myscripts, output_directory=Path("./_mydocs"))

I run this script calling C:\python38\python C:\Dropbox\python\create_pdoc.py The .py scripts to be documented are in the same C:\Dropbox\python\ folder (or children folders, like the script inside path2 subfolder). I don’t think their content is relevant for this question (they just contain a sample function definition followed by a docstring comment: """ my comments """).

As expected, the output (3 html documents + index.html + search.js) is created in C:\Dropbox\python\_mydocs And index.html left menu shows links to the other 3 html docs in same order as they are in myscripts list, like this:

Available Modules

  • Dropbox.python.myscript
  • myscript
  • Dropbox.python.myscript3

What I don’t understand is the reason why the 2nd one (located inside path2) shows no path information, while the 1st and 3rd (located in the same folder as my create_pdoc.py script) show the full path below C: (i.e. Dropbox.python.)

How can I control that? I would have expected one of these results instead:

Available Modules

  • myscript
  • path2.myscript
  • myscript3

Available Modules

  • Dropbox.python.myscript
  • Dropbox.python.path2.myscript
  • Dropbox.python.myscript3

… either all or none scripts preceded by Dropbox.python. path (although I would prefer not to show it)

_Originally posted by @abubelinha in https://github.com/mitmproxy/pdoc/issues/322#issuecomment-1003104131_

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (8 by maintainers)

Most upvoted comments

I think you should read https://docs.python.org/3/tutorial/modules.html, in particular the section on __init__.py. If you place a __init__.py in directoryA, pdoc will treat that directory as a module, so a file named foo.py will be directoryA.foo. So yes, that can be used to resolve naming conflicts. Either way, I would recommend to have everything in a Python packages and not work with scattered script files. 😃