Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

live reload when serving locally #60

Open
cs01 opened this issue May 2, 2019 · 3 comments

Comments

2 participants
@cs01
Copy link
Contributor

commented May 2, 2019

running

pdoc --http :8001 PACKAGE 

serves the docs locally, but if any changes are made, the server needs to be manually killed and restarted, and the webpage needs to be reloaded.

The PyPI package livereload is built to watch files and reload the web client if a source file changes. This is common in other popular tools such as mkdocs and create-react-app. mkdocs implementation can be used as a guide: https://github.com/mkdocs/mkdocs/blob/master/mkdocs/commands/serve.py.

@kernc

This comment has been minimized.

Copy link
Contributor

commented May 2, 2019

While the web page needs to be refreshed manually, the server doesn't (shouldn't) require to be shut down and restarted as module reloading is in place.

pdoc/pdoc/__init__.py

Lines 169 to 175 in f5b4a54

if inspect.ismodule(module):
if module.__name__.startswith(__name__):
# If this is pdoc itself, return without reloading.
# Otherwise most `isinstance(..., pdoc.Doc)` calls won't
# work correctly.
return module
return importlib.reload(module)

If there's a bug somewhere, the import_module() mechanism is being improved as we speak.

@cs01

This comment has been minimized.

Copy link
Contributor Author

commented May 2, 2019

Ah I was editing docs for pdoc itself, hence the server wasn't reloading. Still the client-side reload is a nice feature. What do you think?

@kernc

This comment has been minimized.

Copy link
Contributor

commented May 2, 2019

If something can be done in about three lines of WebSocket JS API and maybe twice that on the Python end without heavy extra dependencies, absolutely love to see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.