From 09795308ab5db573f01ea3a4da57d71ddf8ab911 Mon Sep 17 00:00:00 2001 From: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com> Date: Mon, 1 Nov 2021 11:26:40 -0500 Subject: [PATCH] Added code quality checks to contributing.md (#121) --- docs/contributing.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/docs/contributing.md b/docs/contributing.md index 6272489da..ba157292b 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -15,6 +15,35 @@ You generally only need to submit a CLA once, so if you've already submitted one (even if it was for a different project), you probably don't need to do it again. +## Code Quality Checks + +All notebooks in this project are checked for formatting and style, to ensure a +consistent experience. To test notebooks prior to submitting a pull request, +you can follow these steps. + +From a command-line terminal (e.g. from Vertex Workbench or locally), install +the code analysis tools: +```shell +pip install -U nbqa black flake8 isort pyupgrade git+https://github.com/tensorflow/docs +``` + +Then, set an environment variable for your notebook (or directory): +```shell +export notebook="your-notebook.ipynb" +``` + +Finally, run this code block to check for errors. Each step will attempt to +automatically fix any issues. If the fixes can't be performed automatically, +then you will need to manually address them before submitting your PR. +```shell +nbqa black "$notebook" +nbqa pyupgrade "$notebook" +nbqa isort "$notebook" +python3 -m tensorflow_docs.tools.nbfmt --remove_outputs "$notebook" +nbqa flake8 "$notebook" --extend-ignore=W391,E501,F821,E402,F404,W503,E203,E722,W293,W291 +``` + + ## Code Reviews All submissions, including submissions by project members, require review. We