readthedocs.org icon indicating copy to clipboard operation
readthedocs.org copied to clipboard

Add blacken-docs to pre-commit hooks (and blacken docs)

Open benjaoming opened this issue 3 years ago • 7 comments

While waiting for pre-commit hooks and Black to be added (and indeed run for the entire code base to be blackened), we can test out this pre-commit hook:

https://github.com/asottile/blacken-docs

To fix the issue:

  • Add the hook to the pre-commit config over in https://github.com/readthedocs/common/blob/main/pre-commit-config.yaml
  • Run blacken-docs on all files (but please don't run all hooks on all files)

benjaoming avatar Aug 16 '22 08:08 benjaoming

Hi I am starting my open source journey! Would love to be able to contribute on this.

Can you assign me this issue?

ArhyaSaha avatar Aug 21 '22 16:08 ArhyaSaha

- repo: https://github.com/asottile/blacken-docs rev: v1.12.1 hooks: - id: blacken-docs additional_dependencies: [black==22.6.0]

Also, will adding this over in https://github.com/readthedocs/common/blob/main/pre-commit-config.yaml solve the issue?

ArhyaSaha avatar Aug 21 '22 17:08 ArhyaSaha

Hi @ArhyaSaha - great choice to start the journey :)

This issue should ideally be solved in the two steps outlined above. I would recommend opening up a PR on the common repo and then link it to a PR on the readthedocs.org repo (this one) that shows the results of running --all-files (should only affect docs/ of course).

One more thing: The common repository is shared as a git submodule by several repositories (hence the name). I think that you can assume that documentation always lives in a docs/ folder.. in case it's possible to limit the scope of the hook to just one folder, which will make it run faster and avoid unintended effects on other locations in a repository.

benjaoming avatar Aug 21 '22 18:08 benjaoming

Hi @benjaoming. I tried setting up my environment as mentioned in the docs. I am not able to build docker image for the servers as it gives me an error when I run the given command. The error might be because I am on a windows platform. Is there any other way i can set up my local environment for this issue?

ArhyaSaha avatar Aug 24 '22 17:08 ArhyaSaha

Hi @ArhyaSaha - you strictly speaking won't need this environment to contribute this change. It is only affecting docs/, so you should be able to change the pre-commit configuration and run that without ever running Read the Docs itself...

benjaoming avatar Aug 24 '22 21:08 benjaoming

@benjaoming So i cloned the readthedocs.org repo and installed the requirements from the common submodule. Then i added the lines in .pre-commit-config.yaml and it gives me an error.

An error has occurred: InvalidConfigError: ==> File .pre-commit-config.yaml =====> Expected a Config map but got a str

Please guide me on how to solve this issue.

ArhyaSaha avatar Aug 25 '22 09:08 ArhyaSaha

You'd have to figure that one out by carefully reading your config file and comparing it to what pre-commit expects.

benjaoming avatar Aug 26 '22 13:08 benjaoming

Hi @benjaoming, Taking this up.

dojutsu-user avatar Oct 18 '22 15:10 dojutsu-user

Hi @benjaoming While the team is reviewing the PRs, is it possible to redirect me to some other issue?

dojutsu-user avatar Oct 19 '22 17:10 dojutsu-user

@benjaoming Can you also help me with hacktoberfest-accepted badges on the PRs.

dojutsu-user avatar Oct 20 '22 06:10 dojutsu-user

Yes, I think that we can add a "hacktoberfest-accepted" label and that should be enough :+1: https://blog.shahednasser.com/hacktoberfest-2022-everything-you-need-to-know-to-participate/

benjaoming avatar Oct 20 '22 08:10 benjaoming