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

pdoc3 doesn't use the latest version of the python file #381

Open
danleonte opened this issue Jan 19, 2022 · 1 comment
Open

pdoc3 doesn't use the latest version of the python file #381

danleonte opened this issue Jan 19, 2022 · 1 comment

Comments

@danleonte
Copy link

danleonte commented Jan 19, 2022

I used pdoc3 do document my python package https://github.com/danleonte/Ambit_Stochastics. In particular, i used to run

```pdoc3 --html ambit_stochastics````

or

```pdoc3 --html ambit_stochastics --force````

When I try to do it now, pdoc doesn't use the python files in the folder, but some older version of that. For example, the code in https://danleonte.github.io/Ambit_Stochastics/trawl.html, which can be viewed via the 'expand code button', is different from the one in the github repo. Further, the latex code doesn't render anymore. I uninstalled and reinstalled pdoc3 and it didn t help.

More interestingly, even after i removed one of the scripts, pdoc3 still generated documentation for that script.

@kernc
Copy link
Member

kernc commented Jan 19, 2022

We defer to importlib.import_module() to import referenced modules:

pdoc/pdoc/__init__.py

Lines 202 to 226 in 4aa70de

@contextmanager
def _module_path(module):
from os.path import abspath, dirname, isfile, isdir, split
path = '_pdoc_dummy_nonexistent'
module_name = inspect.getmodulename(module)
if isdir(module):
path, module = split(abspath(module))
elif isfile(module) and module_name:
path, module = dirname(abspath(module)), module_name
try:
sys.path.insert(0, path)
yield module
finally:
sys.path.remove(path)
if isinstance(module, Module):
module = module.obj
if isinstance(module, str):
with _module_path(module) as module_path:
try:
module = importlib.import_module(module_path)
except Exception as e:
raise ImportError(f'Error importing {module!r}: {e.__class__.__name__}: {e}')
assert inspect.ismodule(module)

Maybe it prefers the pip-installed version of ambit_stochastics, if not the one in the current directory?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants