diff --git a/stubdoc/cli.py b/stubdoc/cli.py index 53083cc..61b9e20 100644 --- a/stubdoc/cli.py +++ b/stubdoc/cli.py @@ -6,6 +6,7 @@ from argparse import ArgumentParser from argparse import Namespace import os +import importlib from stubdoc import stubdoc @@ -121,7 +122,7 @@ def _validate_module_path_arg(module_path_arg: Optional[str]) -> None: if not os.path.isfile(module_path_arg): raise ValueError( f'Specified module not found: {module_path_arg}') - if not os.path.splitext(module_path_arg)[1] in ['.py', '.pyd']: + if not any(module_path_arg.endswith(ending) for ending in importlib.machinery.all_suffixes()): raise ValueError( f'A non-python module path specified: {module_path_arg}') diff --git a/stubdoc/stubdoc.py b/stubdoc/stubdoc.py index e2a3adf..5b6f71f 100644 --- a/stubdoc/stubdoc.py +++ b/stubdoc/stubdoc.py @@ -406,7 +406,11 @@ def _read_module(module_path: str) -> ModuleType: file_name: str = os.path.basename(module_path) dir_path: str = module_path.replace(file_name, '', 1) sys.path.append(dir_path) - package_name: str = os.path.splitext(module_path)[0] + package_name: str = None + for ending in importlib.machinery.all_suffixes(): + if module_path.endswith(ending): + package_name = module_path[:-len(ending)] + break package_name = package_name.replace('/', '.') package_name = package_name.replace('\\', '.') while package_name.startswith('.'):