Skip to content

Commit 8407d93

Browse files
committed
refactor: Skip files not found, log warning (don't crash)
Issue-23: #23
1 parent 71c7df2 commit 8407d93

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/mkdocs_llmstxt/_internal/plugin.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,9 @@ def on_post_build(self, *, config: MkDocsConfig, **kwargs: Any) -> None: # noqa
173173
for section_name, page_uris in self._sections.items():
174174
markdown += f"## {section_name}\n\n"
175175
for page_uri, desc in page_uris.items():
176+
if page_uri not in self._md_pages:
177+
_logger.warning(f"Page URI '{page_uri}' not found in the generated pages. Skipping.")
178+
continue
176179
page_title, path_md, md_url, content = self._md_pages[page_uri]
177180
path_md.write_text(content, encoding="utf8")
178181
_logger.debug(f"Generated MD file to {path_md}")
@@ -185,7 +188,7 @@ def on_post_build(self, *, config: MkDocsConfig, **kwargs: Any) -> None: # noqa
185188
if self.config.full_output is not None:
186189
full_output_file = Path(config.site_dir).joinpath(self.config.full_output)
187190
for section_name, page_uris in self._sections.items():
188-
list_content = "\n".join(self._md_pages[page_uri].content for page_uri in page_uris)
191+
list_content = "\n".join(self._md_pages[page_uri].content for page_uri in page_uris if page_uri in self._md_pages)
189192
full_markdown += f"# {section_name}\n\n{list_content}"
190193
full_output_file.write_text(full_markdown, encoding="utf8")
191194
_logger.debug(f"Generated file /{self.config.full_output}.txt")

0 commit comments

Comments
 (0)