diff --git a/src/griffe/loader.py b/src/griffe/loader.py index 4a32ae0e..c72b1a03 100644 --- a/src/griffe/loader.py +++ b/src/griffe/loader.py @@ -181,7 +181,13 @@ async def load_module( module_name, module_path = self._module_name_and_path(module, search_paths) return await self._load_module_path(module_name, module_path, submodules=submodules) - async def _load_module_path(self, module_name: str, module_path: Path, submodules: bool = True) -> Module: + async def _load_module_path( + self, + module_name: str, + module_path: Path, + submodules: bool = True, + parent: Module | None = None, + ) -> Module: logger.debug(f"Loading path {module_path}") code = await read_async(module_path) lines_collection[module_path] = code.splitlines(keepends=False) @@ -190,6 +196,7 @@ async def _load_module_path(self, module_name: str, module_path: Path, submodule filepath=module_path, code=code, extensions=self.extensions, + parent=parent, docstring_parser=self.docstring_parser, docstring_options=self.docstring_options, ) @@ -212,7 +219,9 @@ async def _load_submodule(self, module: Module, subparts: NamePartsType, subpath except KeyError: logger.debug(f"Skipping (not importable) {subpath}") else: - member_parent[subparts[-1]] = await self._load_module_path(subparts[-1], subpath, submodules=False) + member_parent[subparts[-1]] = await self._load_module_path( + subparts[-1], subpath, submodules=False, parent=member_parent + ) def _module_depth(name_parts_and_path: NamePartsAndPathType) -> int: