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
add pre-commit-hook configuration to this repo #2932
Conversation
My first reaction is against it :/ |
good question. I didn't think of that. I will try and test |
The user can simply define Here is an example: - repo: https://github.com/Cube707/mkdocs
rev: 878df16
hooks:
- id: mkdocs-build
additional_dependencies:
- mkdocs-plugin-progress |
Co-authored-by: Álvaro Mondéjar <mondejar1994@gmail.com>
Just wanted to say this would be very helpful for me. 🙏 |
Can |
@pawamoy yes, in fact all keys can be overriden by the user if needed. The |
require_serial: true | ||
pass_filenames: false | ||
types_or: [markdown, yaml] | ||
files: ((^|/)mkdocs\.ya?ml$)|(^docs/) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the files
field should be just removed as said previously you can change the docs directory and configuration file path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But based on what @Cube707 explained, this value is just a default value which makes sense in most cases. Users can change it in their projects if needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes what @pawamoy said. But also the files
field is responsible for limiting what files trigger a mkdoc build
and if removed it will run for changes to any file. As mkdoc is quite expencive to run it should defnetly be limited in when it runs.
An argument could be made here to match no files at all by default, making it that it must be run manually (via pre-commit run mkdocs-build
) or the user must provide/overide the file patterns
Thanks for the explanation @Cube707. I wonder something though: is that reasonable from pre-commit to ask third-party projects to host this configuration themselves? Isn't there some kind of central repository for such tool configurations? It's a bit unfair to put the maintenance burden on third-party tools which might not be interested in pre-commit at all, even if that maintenance is very low. Just asking for myself: I have projects that could be used through pre-commit, but I wouldn't like having to maintain a |
no, you are defnetly only supposed to host a hooks file on a project if you explicitly choose to support pre-commit. There are options for a pre-commit-user to interact with a tool that has decided againts supporting pre-commit directly. (like I said, the hooks file is just a set of defaults, if its not there, all pre-commit users have to figure out these settings by themselfs and might do it incorectly) having the hooks file as part of a project makes it much more likely that it gets updated should the tools change in a way that requires an updated and avoids breaking downstream users CI-pipelines. But there are mirrows of bigger repos that add the So bottom line: we must decide here if pre-commit support is desired or not and if not, the PR will be closed and the |
Pre commits are to validate and fix some errors in the code and from one perspective, this could be useful if you thread docs as part of the code. On the other hand, For me, a useful pre-commit hook would be the one that runs the build process, and block commit when any WARN/ERROR/CRITICAL is seen in an output when |
I don't know if this feature interest you, so its a draft for now. I also didn't add documentation for now unitll I have feedback if this is desirable:
I implemented a
pre-commit
hook for this repository (see her for more info). This allows users to easiely integrate themkdocs build
command into their workflow. It will run on any commit that has changes to relevant files (mkdocs.yml
or any markdown file insodedocs/
) and will stop the commit if the build process fails.It also makes it easy to have invalid PRs fail the ci-workflow with a single simple workflow, instead of having to create a extra step manually to run
mkdocs
.All a user needs to to is to install
pre-commit
(most likly already the case) and add this to hispre-commit-config.yaml
:if this feature is accabtabel, this is to be discussed:
docs/deploying-your-docs.md#pre-commit
?)