-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
I looked a bit and I could not find it, but I wonder if there is a possibility to determine if any of the definitions of the click commands changed since last time we run the check.
This woudl be extremely useful for generating documentation automatically as part of pre-commit/CI workflow. We are doing that in Apache Airflow, resulting in embedded SVG images like this : https://github.com/apache/airflow/blob/main/BREEZE.rst#installation
Currently the (small) problem we have is that we always try to regenerate those SVG images in CI and we fail pre-commit if the generated images are different. This allows us to make sure that we have not forgotten to regenerate and SVG image when any parameter changes. And it works moslty fine (we've made sure that terminal size is always the same when we generate the help so re-geenerated images are the same). The problem is when output format of the SVG changes (as it happened in rich 12.4.0 for example) - because then the generated SVG images will be slightly different. We do not really want to pin rich and upgrade it manually as this is just a development tool in this case, but this is what we ended up for now.
The simple solution to that would be to get some kind of unique hash that would only change if any of the parameters, their help, type etc. changes - and otherwise being stable. Then we could implement such workflow (automatically):
- Check if current hash of all options/commands/flags has not changed from the last one committed together with images. Skip the rest if it did not.
- Generate images only if hash is different
- Store the changed hash
- Commit both - generate SVG and hash together
This way we could actually only run the SVG generation if we know any of the options changed (the problem currently is that we generate it every time any of the "dev" python code changes which is quite excessive - but since click annotations are part of the code, that's simplest.
Is there such a feature already available and I missed it ? Or if not - do the maintainers think it's a good idea? I am willing to contribute a PR for that - I might be able to analyse the code and find out how to do and maybe need a little guidance, but I would love to know if that seems like a good idea.