timvink / mkdocs-git-revision-date-localized-plugin

MkDocs plugin to add a last updated date to your site pages
https://timvink.github.io/mkdocs-git-revision-date-localized-plugin/index.html
MIT License
208 stars 45 forks source link

Is there a way to turn off warnings? #108

Closed facelessuser closed 1 year ago

facelessuser commented 1 year ago

I have some documentation tests that build the documentation in strict mode to find any issues and then runs a spellchecker on the output afterward. I find it very frustrating that I get these warnings in particular:

WARNING  -  [git-revision-date-localized-plugin] '/Somepath/somefile.md' has no git logs, using current
            timestamp

I've specifically enabled the following to handle the fact that the file has no history yet I still get the warning which fails the build.

plugins:
  - search:
  - git-revision-date-localized:
      fallback_to_build_date: true

I want the tests to be able to pass in a release bundle that does not have git, so I need this warning to be optional if at all possible.

Are the warnings really necessary if I've explicitly told it to fallback to build date? Or can we make such warnings optional?

timvink commented 1 year ago

Hi @facelessuser !

There currently is no way to silence these warnings.. but I agree there should be. More users are using strict mode like you are and want to remove the warnings (#89)

This is the line causing the warning:

https://github.com/timvink/mkdocs-git-revision-date-localized-plugin/blob/7ddc74cb72c55a18d15cabead18a31ef243d490c/mkdocs_git_revision_date_localized_plugin/util.py#L169-L175

Your specific example is not related to the fallback_to_build_date option setting, because git is not failing, it's just that there are not git entries for the file.

I see some options:

1) Change all the warnings to info level, and add a new strict option to this plugin that would log warnings instead of info (and recommends users to use mkdocs --strict to create errors from warnings). 2) Add a new option report_issues_as (need to find a better name) that you can set to "info" instead of a default "warning" .

I prefer the first option. Will try to pick this up somewhere this week!

facelessuser commented 1 year ago

Sounds great! I'm agnostic to how they get silenced as long as it is possible 🙃. I'm fine with option 1.

timvink commented 1 year ago

New release v1.2.0 just pushed to pypi

timvink commented 1 year ago

For future reference, to turn off warnings, you can now in your mkdocs.yml do:

plugins:
  - git-revision-date-localized:
      strict: false