question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Inconsistent module names when specifying multiple paths

See original GitHub issue

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_

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:17 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
mhilscommented, Jan 5, 2022

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. 😃

0reactions
abubelinhacommented, Jan 9, 2022

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:

{% for submodule in all_modules %}
    <li><a href="{{ submodule.replace(".","/") }}.html">{{ submodule }}</a></li>
    {# How can get a list of submodule members here? #}
{% endfor %}

Tried {% for children in submodule %}, {% for children in submodule.own_members %} … but didn’t work (I guess submodule contains just a string from the all_modules list passed to render.html_index(all_modules)).

Any hints?

Read more comments on GitHub >

github_iconTop Results From Across the Web

python import path: packages with the same name in different ...
I've asked about this in an earlier question, see import python modules with the same name, but the internal details are still unclear...
Read more >
Path and module system changes - The Rust Edition Guide
In Rust 2018, paths in use declarations and in other code work the same way, both in the top-level module and in any...
Read more >
How to fix "The following module is missing from the file ...
Restore the module and actually disable and uninstall it (recommended if possible): First, restore the module to its original location in the file...
Read more >
modulefile — Modules documentation
If more than one modulefile are specified, then this list acts as a Boolean AND operation, which means all specified modulefiles are required....
Read more >
Usage - Buf docs - Buf.build
Any directories added to this list are completely skipped and excluded in the ... a buf.yaml (called a module in Buf parlance), and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found