Closed prcr closed 4 years ago
I see that mkdocs-monorepo-plugin
copies the contents of multiple docs/
dirs into a temporary docs_/
directory at the MkDocs event on_config()
.
mkdocs-git-revision-date-localized-plugin
uses the event on_page_markdown()
, and then specifically the page.file.abs_src_path
attribute of a page in order to run git log
on the file location. If the file is copied to a temp folder the git info is lost, and the git log
fails.
One possible solution might be to use symlinks to the temporary docs_/
folder instead of copying files. That way hopefully the abs_src_path
remains intact. So replace:
with:
copytree(source_dir, dest_dir, symlinks=True)
I haven't tested this yet, but I am willing to give it a try and provide a PR?
Edit: Another possible solution could be to save during on_config()
for each file the source location in a dictionary of the Plugin class. Then use on_pre_page()
to "alter the Page instance", in effect replacing the abs_src_path
attribute with the original source.
@timvink That sounds like an interesting approach and definitely has pros compared to how we do it today of constructing a new docs/
directory in the /tmp
temporary filesystem. Looking forward to seeing what your approach is and happy to provide feedback :)
Cool, will pick this up somewhere in next week!
The symlink approach didn't work, but I got it working with the second idea. Opened https://github.com/spotify/mkdocs-monorepo-plugin/pull/13, let's discuss details there!
Hello,
I was trying to use the MkDocs plugin timvink/mkdocs-git-revision-date-localized-plugin in my project but it always fails with:
I was able to pinpoint the issue to the fact that I'm using mkdocs-monorepo-plugin as well. It seems that the plugin copies the *.md files to a temporary directory before building them, and this way the other plugin cannot use
git log
to find out the last updated date of the Markdown files.