From e9c3ebc7ada630659f39fe0f9888925f1a191ec8 Mon Sep 17 00:00:00 2001 From: Sergio Oller Moreno Date: Sun, 22 Sep 2024 08:58:01 +0200 Subject: [PATCH 1/2] Fix TypeError when docutils can't provide a line --- src/autodoc2/sphinx/docstring.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/autodoc2/sphinx/docstring.py b/src/autodoc2/sphinx/docstring.py index bd3f39d..4a83f58 100644 --- a/src/autodoc2/sphinx/docstring.py +++ b/src/autodoc2/sphinx/docstring.py @@ -139,7 +139,7 @@ def run(self) -> list[nodes.Node]: ) document.reporter.get_source_and_line = lambda li: ( source_path, - li + source_offset, + li + source_offset if li is not None else None, ) with parsing_context(): parser.parse(item["doc"], document) @@ -214,7 +214,7 @@ def change_source( state.reporter.source = source_path state.reporter.get_source_and_line = lambda li: ( source_path, - li + line_offset, + li + line_offset if li is not None else None, ) yield finally: From 230af905f694411f7ce1bb06472c2cc497215f22 Mon Sep 17 00:00:00 2001 From: Sergio Oller Date: Sat, 28 Sep 2024 10:03:43 +0200 Subject: [PATCH 2/2] Give yield_module what it expects Otherwise I get File "", line 152, in _check_arg_types TypeError: join() argument must be str, bytes, or os.PathLike object, not 'tuple' When I rerun sphinx-build --- src/autodoc2/analysis.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/autodoc2/analysis.py b/src/autodoc2/analysis.py index c0ad35f..e19e5b5 100644 --- a/src/autodoc2/analysis.py +++ b/src/autodoc2/analysis.py @@ -40,7 +40,7 @@ def analyse_module( if not file_path.is_dir(): node = AstroidBuilder().file_build(os.fsdecode(file_path), name) else: - node = build_namespace_package_module(name, file_path.parts) + node = build_namespace_package_module(name, [str(file_path)]) yield from walk_node( node, State(node.name.split(".", 1)[0], [], exclude_external_imports) )