Repository: spark
Updated Branches:
  refs/heads/master 6f05669e4 -> d5573c578


[SPARK-23367][BUILD] Include python document style checking

## What changes were proposed in this pull request?
Includes python document style checking.
- Use sphinx like check, run only if pydocstyle installed on machine/jenkins
- use pydocstyle rather than single file version pep257.py, which  is much 
older and had some known issues
- verify pydocstyle latest 3.0.0  is in use, to ensure latest doc checks are 
getting executed
- ignore (inclusion/exclusion error codes) features and support via tox.ini
- Be non-breaking change and allow updating docstyle to standards at easy pace

## How was this patch tested?
./dev/run-tests

Closes #22425 from rekhajoshm/SPARK-23367-2.

Authored-by: Rekha Joshi <[email protected]>
Signed-off-by: Sean Owen <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/d5573c57
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/d5573c57
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/d5573c57

Branch: refs/heads/master
Commit: d5573c578a1eea9ee04886d9df37c7178e67bb30
Parents: 6f05669
Author: Rekha Joshi <[email protected]>
Authored: Sat Oct 27 08:20:42 2018 -0500
Committer: Sean Owen <[email protected]>
Committed: Sat Oct 27 08:20:42 2018 -0500

----------------------------------------------------------------------
 dev/lint-python | 28 ++++++++++++++++++++++++++++
 dev/tox.ini     |  2 ++
 2 files changed, 30 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/d5573c57/dev/lint-python
----------------------------------------------------------------------
diff --git a/dev/lint-python b/dev/lint-python
index e26bd4b..2e353e1 100755
--- a/dev/lint-python
+++ b/dev/lint-python
@@ -21,9 +21,14 @@ SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )"
 SPARK_ROOT_DIR="$(dirname "$SCRIPT_DIR")"
 # Exclude auto-generated configuration file.
 PATHS_TO_CHECK="$( cd "$SPARK_ROOT_DIR" && find . -name "*.py" )"
+DOC_PATHS_TO_CHECK="$( cd "$SPARK_ROOT_DIR" && find . -name "*.py" | grep -vF 
'functions.py' )"
 PYCODESTYLE_REPORT_PATH="$SPARK_ROOT_DIR/dev/pycodestyle-report.txt"
+PYDOCSTYLE_REPORT_PATH="$SPARK_ROOT_DIR/dev/pydocstyle-report.txt"
 PYLINT_REPORT_PATH="$SPARK_ROOT_DIR/dev/pylint-report.txt"
 PYLINT_INSTALL_INFO="$SPARK_ROOT_DIR/dev/pylint-info.txt"
+PYDOCSTYLEBUILD="pydocstyle"
+EXPECTED_PYDOCSTYLEVERSION="3.0.0"
+PYDOCSTYLEVERSION=$(python -c 'import pkg_resources; 
print(pkg_resources.get_distribution("pydocstyle").version)' 2> /dev/null)
 SPHINXBUILD=${SPHINXBUILD:=sphinx-build}
 SPHINX_REPORT_PATH="$SPARK_ROOT_DIR/dev/sphinx-report.txt"
 
@@ -99,6 +104,29 @@ else
     echo "flake8 checks passed."
 fi
 
+# Check python document style, skip check if pydocstyle is not installed.
+if hash "$PYDOCSTYLEBUILD" 2> /dev/null; then
+    if [[ "$PYDOCSTYLEVERSION" == "$EXPECTED_PYDOCSTYLEVERSION" ]]; then
+        pydocstyle --config=dev/tox.ini $DOC_PATHS_TO_CHECK >> 
"$PYDOCSTYLE_REPORT_PATH"
+        pydocstyle_status="${PIPESTATUS[0]}"
+
+        if [ "$compile_status" -eq 0 -a "$pydocstyle_status" -eq 0 ]; then
+            echo "pydocstyle checks passed."
+            rm "$PYDOCSTYLE_REPORT_PATH"
+        else
+            echo "pydocstyle checks failed."
+            cat "$PYDOCSTYLE_REPORT_PATH"
+            rm "$PYDOCSTYLE_REPORT_PATH"
+            exit 1
+        fi
+
+    else
+        echo "The pydocstyle version needs to be latest 3.0.0. Skipping pydoc 
checks for now"
+    fi
+else
+  echo >&2 "The pydocstyle command was not found. Skipping pydoc checks for 
now"
+fi
+
 # Check that the documentation builds acceptably, skip check if sphinx is not 
installed.
 if hash "$SPHINXBUILD" 2> /dev/null; then
   cd python/docs

http://git-wip-us.apache.org/repos/asf/spark/blob/d5573c57/dev/tox.ini
----------------------------------------------------------------------
diff --git a/dev/tox.ini b/dev/tox.ini
index 6ec223b..11b1b04 100644
--- a/dev/tox.ini
+++ b/dev/tox.ini
@@ -17,3 +17,5 @@
 ignore=E226,E241,E305,E402,E722,E731,E741,W503,W504
 max-line-length=100
 
exclude=cloudpickle.py,heapq3.py,shared.py,python/docs/conf.py,work/*/*.py,python/.eggs/*,dist/*
+[pydocstyle]
+ignore=D100,D101,D102,D103,D104,D105,D106,D107,D200,D201,D202,D203,D204,D205,D206,D207,D208,D209,D210,D211,D212,D213,D214,D215,D300,D301,D302,D400,D401,D402,D403,D404,D405,D406,D407,D408,D409,D410,D411,D412,D413,D414


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to