Skip to content

Commit 759564a

Browse files
authored
Merge pull request #1 from iloveitaly/exception-in-code-block
fix: build docs if poorly structured
2 parents 6a63754 + 70a889a commit 759564a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

sphinx_inlinecode/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ def add_code_blocks(file: Path, objects: Dict[str, Any], highlighter: "PythonLex
124124
else:
125125
target = get_target(viewcode_label.parent)
126126

127+
# this can happen if documentation is not structured perfectly
128+
# skipping keys which don't exist allow the documentation to be built even if the structure isn't perfect
129+
if target not in objects:
130+
continue
131+
127132
# Highlight and insert the source code block after the object signature
128133
code_block = get_code_block(target, objects[target], highlighter)
129134
doc_entry.append(code_block)

0 commit comments

Comments
 (0)