Skip to content

Commit

Permalink
FIX: import_module() reloads submods recursively to work with --http …
Browse files Browse the repository at this point in the history
…and __all__ (#300)
  • Loading branch information
Lucas-C authored Jan 11, 2021
1 parent 1dbb782 commit 72e41db
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pdoc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ def _module_path(module):
# `isinstance(..., pdoc.Doc)` calls won't work correctly.
if reload and not module.__name__.startswith(__name__):
module = importlib.reload(module)
# We recursively reload all submodules, in case __all_ is used - cf. issue #264
for mod_key, mod in list(sys.modules.items()):
if mod_key.startswith(module.__name__):
importlib.reload(mod)
return module


Expand Down
2 changes: 1 addition & 1 deletion pdoc/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ def html(self):
"""
return pdoc.html(self.import_path_from_req_url,
reload=True, http_server=True, external_links=True,
skip_errors=args.skip_errors,
skip_errors=self.args.skip_errors,
**self.template_config)

def resolve_ext(self, import_path):
Expand Down

0 comments on commit 72e41db

Please sign in to comment.