From cca3a781ee6b5934eac9e016486feb9e76d8f2ee Mon Sep 17 00:00:00 2001 From: Olivier Samyn Date: Thu, 17 Oct 2019 09:15:41 +0200 Subject: [PATCH] fix: correct stop condition in sphinx <2.0 and add a stop guard. --- autoapi/mappers/python/parser.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autoapi/mappers/python/parser.py b/autoapi/mappers/python/parser.py index e24bdeb..e5ecb19 100644 --- a/autoapi/mappers/python/parser.py +++ b/autoapi/mappers/python/parser.py @@ -32,7 +32,7 @@ class Parser(object): module_part = os.path.splitext(filename)[0] module_parts = [module_part] module_parts = collections.deque(module_parts) - while condition(directory): + while directory and condition(directory): directory, module_part = os.path.split(directory) if module_part: module_parts.appendleft(module_part) @@ -48,7 +48,9 @@ class Parser(object): ) def parse_file_in_namespace(self, file_path, dir_root): - return self._parse_file(file_path, lambda directory: directory != dir_root) + return self._parse_file( + file_path, lambda directory: os.path.abspath(directory) != dir_root + ) def parse_annassign(self, node): return self.parse_assign(node)