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

localhost:8080 loads forever #339

Open ghost opened 3 years ago

ghost commented 3 years ago

Expected Behavior

Actual Behavior

Steps to Reproduce

1.run pdoc --template-dir .\docs\config\ --http : .\spotdl\ from the root of this repo

Additional info

Local CLI Output

PS D:\Projects\Code\spotdlRedesign> pdoc --template-dir .\docs\config\ .\spotdl\
d:\software\python3-9-1\lib\site-packages\pdoc\cli.py:532: UserWarning: Couldn't read PEP-224 variable docstrings from <Module 'spotdl'>: could not get source code
  modules = [pdoc.Module(module, docfilter=docfilter,
d:\software\python3-9-1\lib\site-packages\pdoc\__init__.py:708: UserWarning: Couldn't read PEP-224 variable docstrings from <Module 'spotdl.defaults'>: could not get source code
  m = Module(import_module(fullname),
Module spotdl
=============

Sub-modules
-----------
* spotdl.defaults
Traceback (most recent call last):
  File "d:\software\python3-9-1\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "d:\software\python3-9-1\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "D:\Software\Python3-9-1\Scripts\pdoc.exe\__main__.py", line 7, in <module>
  File "d:\software\python3-9-1\lib\site-packages\pdoc\cli.py", line 583, in main
    _generate_lunr_search(
  File "d:\software\python3-9-1\lib\site-packages\pdoc\cli.py", line 416, in _generate_lunr_search
    with _open_write_file(path.join(main_path, 'index.js')) as f:
  File "d:\software\python3-9-1\lib\ntpath.py", line 78, in join
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType

When I use the --http : flag, nothing happens, localhost:8080 just loads forever (a very long time)

kernc commented 3 years ago

The traceback above indicates the issue is in these lines: https://github.com/pdoc3/pdoc/blob/c2c13200a630f97e5a7b2cba292b0dc9deb58b53/pdoc/cli.py#L417-L418 However, args.output_dir is only set to default non-None when --html or --http: https://github.com/pdoc3/pdoc/blob/c2c13200a630f97e5a7b2cba292b0dc9deb58b53/pdoc/cli.py#L440-L441 I think the condition here should include --html and --http as adding JavaScript search makes little sense otherwise: https://github.com/pdoc3/pdoc/blob/c2c13200a630f97e5a7b2cba292b0dc9deb58b53/pdoc/cli.py#L582-L585

All of this is likely unrelated to the stalled page load you're seeing with --http :.

ghost commented 3 years ago

I'm not going to lie, I didn't understand one bit of what you said. Unlike you, I don't have an overall understanding of the software structure so your going to have to simplify what your saying.

kernc commented 3 years ago

https://github.com/pdoc3/pdoc/commit/251d61a6e252e92a12c77670f81a8d3d4b325642 should fix the traceback you quoted. Thanks.

--http : stalling would be great to pinpoint. We don't have any infinite loops I think. Might any of the imported packages be waiting for stdin input?

instead loads up the installed version of spotdl

We do a bit of magic to import the specified module. We maybe chdir, then defer to importlib.import_module(): https://github.com/pdoc3/pdoc/blob/251d61a6e252e92a12c77670f81a8d3d4b325642/pdoc/__init__.py#L198-L228

ghost commented 3 years ago

Might any of the imported packages be waiting for stdin input?

Nope. That's come up before, so I checked. I'll retry today