Browse Source

add `make format` to cover most auto-fixable formatting (#8022)

LB (Ben Johnston) 3 years ago
parent
commit
861a509b32
3 changed files with 11 additions and 1 deletions
  1. 7 0
      Makefile
  2. 2 1
      docs/contributing/html_guidelines.rst
  3. 2 0
      docs/contributing/python_guidelines.rst

+ 7 - 0
Makefile

@@ -29,6 +29,13 @@ lint:
 	npm run lint:format --silent
 	doc8 docs
 
+format:
+	black --target-version py37 .
+	isort .
+	git ls-files '*.html' | xargs djhtml -i
+	npm run format
+	npm run fix:js
+
 test:
 	python runtests.py
 

+ 2 - 1
docs/contributing/html_guidelines.rst

@@ -6,7 +6,8 @@ We use `Django templates <https://docs.djangoproject.com/en/stable/ref/templates
 Linting HTML
 ~~~~~~~~~~~~
 
-We use `jinjalint <https://github.com/motet-a/jinjalint>`_ to lint templates and `djhtml <https://github.com/rtts/djhtml>`_ to format them. If you have installed Wagtail's testing dependencies (``pip install -e .[testing]``), you can check your code by running ``make lint``.
+We use `jinjalint <https://github.com/motet-a/jinjalint>`_ to lint templates and `djhtml <https://github.com/rtts/djhtml>`_ to format them.
+If you have installed Wagtail's testing dependencies (``pip install -e .[testing]``), you can check your code by running ``make lint``, and format your code by running ``make format``.
 
 Principles
 ~~~~~~~~~~

+ 2 - 0
docs/contributing/python_guidelines.rst

@@ -16,6 +16,8 @@ In addition, import lines should be sorted according to `isort <https://pycqa.gi
 If you have installed Wagtail's testing dependencies (``pip install -e '.[testing]'``), you can check your code by
 running ``make lint``.
 
+You can run all Python formatting with ``make format``.
+
 Django compatibility
 ~~~~~~~~~~~~~~~~~~~~