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
InvalidGitRepositoryError
during build when including auto-generated files
#101
Comments
Exclude supports globbing, do you know the directory ? So you want to use --strict.. would a new option not to raise any warnings help? |
No, I don't know the directory. It has a random identifier that changes on every run of
I believe it would be best not to raise a warning in this case. The behavior has to be requested explicitly by setting What do you think about it? If you agree to remove the warning, I'll be happy to prepare a pull request. |
Not sure if you're aware, but checkout mkdocstrings if you haven't already. Another thought. What does your But that's unlikely to work, considering the event tree: I still think the proper way is to exclude certain files and/or directories from this plugin. This is the logic currently used: mkdocs-git-revision-date-localized-plugin/mkdocs_git_revision_date_localized_plugin/plugin.py Lines 167 to 169 in ad11dd0
It might be that these generated files do not have a A more obvious route might to add a PR to new_f.generated_by_gen_files = True Then we can build support for Thoughts? |
I use
I tried all possible positions before posting this issue. The error is always the same regardless of where I place I'll try what you've proposed above later today or tomorrow. |
I've opened two PRs that will address this issue. Waiting for the PR to |
I would like to reopen this topic. We should either adopt the Checking if a file is located inside the project: import os
def is_in_project(self, file: File, config: MkDocsConfig):
path = os.path.dirname(config.config_file_path)
return file.abs_src_path.startswith(path) What do you think? I don't expect MkDocs adopting this in the near future. |
It would make sense: if we can't find the file, then don't attempt to use git. But using the config_file_path to determine the directory is also hacky; there are too many edge cases. Top of mind, some things that could happen:
I could spend more time looking for examples and corresponding reasons why, to see if these hold, but I currently don't trust the location of the config enough to infer location of other files. MkDocs to adopting a |
Thanks for taking the time to investigate and the work on the PR! I understand that explicit is always better than implicit, and adding the respective field would also allow other plugins to adjust more easily. |
I tried to use
mkdocs-git-revision-date-localized-plugin
together with [mkdocs-gen-files] to auto-generate references from Python doc strings. During the build, I encountered the following error message:followed by a
git.exc.InvalidGitRepositoryError
.The fundamental problem is that
mkdocs-gen-files
stores its output in temporary files outside the project's repository. Hence,git-revision-date-localized
cannot find a repository and produces the error.On the other hand, it is possible to silence the error by setting
fallback_to_build_date: true
in mkdocs.yaml, such that the auto-generated pages are marked with the build date. This, however, turns the errors for each file into warnings, and thus it is impossible to usemkdocs
in--strict
mode.Also, the
exclude
option does not work in this case since the names of the temporary files are unknown before build time.I currently don't have a proper solution since it is obviously not straightforward to map auto-generated temporary files to the corresponding code files.
The text was updated successfully, but these errors were encountered: