Skip to content

Commit

Permalink
Fix types and compatibility with MkDocs 1.6
Browse files Browse the repository at this point in the history
  • Loading branch information
oprypin committed Apr 27, 2024
1 parent 6fd0fe0 commit 7baa032
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion mkdocs_gen_files/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def _get_file(self, name: str, new: bool = False) -> str:
use_directory_urls=self.config.use_directory_urls,
)
new_f.generated_by = "mkdocs-gen-files" # type: ignore[attr-defined]
assert new_f.abs_src_path is not None
normname = pathlib.PurePath(name).as_posix()

if new or normname not in self._files:
Expand All @@ -62,7 +63,10 @@ def _get_file(self, name: str, new: bool = False) -> str:
os.makedirs(os.path.dirname(new_f.abs_src_path), exist_ok=True)
self._files[normname] = new_f
self.edit_paths.setdefault(normname, None)
shutil.copyfile(f.abs_src_path, new_f.abs_src_path)
if f.abs_src_path:
shutil.copyfile(f.abs_src_path, new_f.abs_src_path)
else: # MkDocs 1.6+
pathlib.Path(new_f.abs_src_path).write_bytes(f.content_bytes)
return new_f.abs_src_path

return f.abs_src_path
Expand Down

0 comments on commit 7baa032

Please sign in to comment.