Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting git author for mkdocstrings source files #75

Open
dvonessen opened this issue Jun 4, 2023 · 1 comment
Open

Getting git author for mkdocstrings source files #75

dvonessen opened this issue Jun 4, 2023 · 1 comment

Comments

@dvonessen
Copy link

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

@timvink
Copy link
Owner

timvink commented Jun 7, 2023

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:

path = file.abs_src_path
if path.endswith(".md"):
_ = self.repo().page(path)

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 (backstage/mkdocs-monorepo-plugin#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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants