oprypin / mkdocs-gen-files

MkDocs plugin to programmatically generate documentation pages during the build
https://oprypin.github.io/mkdocs-gen-files
MIT License
107 stars 10 forks source link

Path separator mismatch on Windows #3

Closed pawamoy closed 2 years ago

pawamoy commented 2 years ago

Hello @oprypin 🙂 Still enjoying gen-files a lot!

I've just encountered the following issue on Windows (sorry, work...): gen-files warns me about files not existing. It seems it's just a mismatch with path separators using backslashes on one side vs. forward slashes on the other:

self._edit_paths: {
    'reference/package/index.md': 'src\\package\\__init__.py',
    ...
}
# while
page.file.src_path: 'reference\\package\\index.md'

...so this condition is always false:

https://github.com/oprypin/mkdocs-gen-files/blob/baf5a5e2ef0490fb2f9d2962c4edda66675a0a7d/mkdocs_gen_files/plugin.py#L44

I see that you are normalizing the path here:

https://github.com/oprypin/mkdocs-gen-files/blob/baf5a5e2ef0490fb2f9d2962c4edda66675a0a7d/mkdocs_gen_files/editor.py#L70

Maybe separators should not be replaced, or maybe the later comparison should wrap them in Path again or something.

What do you think?

oprypin commented 2 years ago

You're right, editor.py consistently normalizes paths while plugin.py doesn't normalize them. I'll fix that.

https://github.com/oprypin/mkdocs-gen-files/blob/baf5a5e2ef0490fb2f9d2962c4edda66675a0a7d/mkdocs_gen_files/plugin.py#L44-L45

oprypin commented 2 years ago

Check out #4

pawamoy commented 2 years ago

Thanks for the quick fix!