Inconsistent module names when specifying multiple paths
See original GitHub issueI 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_
Issue Analytics
- State:
- Created 2 years ago
- Comments:17 (8 by maintainers)
Top GitHub 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
indirectoryA
, pdoc will treat that directory as a module, so a file namedfoo.py
will bedirectoryA.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. 😃I played a bit with jinja2 templates (first time in my life).
As for showing the module name in top of left tree, I could solve it myself adding
<h4>{{ module.fullname }}</h4>
somewhere around line 750 of my module.html.jinja2 (my version may already be outdated because line numbers do not match).Not as lucky showing the modules tree in my module index, I guess I should create a loop inside these lines of index.html.jinja2:
Tried
{% for children in submodule %}
,{% for children in submodule.own_members %}
… but didn’t work (I guesssubmodule
contains just a string from theall_modules
list passed torender.html_index(all_modules)
).Any hints?