mkdocs-git-authors-plugin
mkdocs-git-authors-plugin copied to clipboard
Getting git author for mkdocstrings source files
Hi, I am using mkdocstrings to generate the documentation for the projects source. On-top I use mkdocs-gen-files and mkdocs-literate-nav plugins to auto generate the navigation for the documentation as described in the mkdocstrings documentation https://mkdocstrings.github.io/recipes/.
Unfortunately the git-authors plugin uses the generated file instead of the sources file to get the author. (This applies also to the mkdocs-git-revision-date-localized-plugin)
Is there any possibility to change the path on the fly to point to the source code files for the generated files?
Thanks for your help AND for this and the other wonderful plug-ins and your work.
Daniel
Hi Daniel,
Tricky topic, getting git info right when using generated files, that are based on a source file. If I somehow have more time, I want to solve all these problems in a new mkdocs-git-info-plugin
. For now though, here's the an overview of the issue:
This plugin uses file.abs_src_path
:
https://github.com/timvink/mkdocs-git-authors-plugin/blob/5c1d8b056dd7c302413674fec605d06403c5a2de/mkdocs_git_authors_plugin/plugin.py#L113-L115
mkdocs-gen-files-plugin
seems to overwrite that attribute:
https://github.com/oprypin/mkdocs-gen-files/blob/b02016c315e25017f5678e190d98f53c64c99446/mkdocs_gen_files/editor.py#L58-L63
It's kind of similar to the problem I had with mkdocs-monorepo-plugin
, where the same attribute had to be updated (https://github.com/backstage/mkdocs-monorepo-plugin/pull/13), but this time the abs_src_path
is probably correct.
Perhaps a better way is to add in mkdocs-gen-files-plugin
(and other similar plugins that generate files) an additional attribute sourcefile_abs_src_path
, and in git-related plugins use that attribute if available.
In your case, there's an additional problem: you're only interested in the authors of that wrote the lines in the docstring, not any of the other python bits.
So I don't expect to solve this problem anything soon, but will leave this issue open.