From d0900626da13bcfd23c4fde80957fceb786171f5 Mon Sep 17 00:00:00 2001 From: Tyler Veness Date: Sun, 18 Dec 2016 19:46:20 -0800 Subject: [PATCH] Removed format.py shim (#393) Now that our formatter is a Python package (wpiformat), the format.py shim for invoking it is no longer necessary. styleguide#29 should be merged before this patch. --- .travis.yml | 8 +++----- CONTRIBUTING.md | 2 +- README.md | 6 +++--- styleguide/format.py | 36 ------------------------------------ 4 files changed, 7 insertions(+), 45 deletions(-) delete mode 100755 styleguide/format.py diff --git a/.travis.yml b/.travis.yml index 59b280f293..2c6eeedea1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,8 @@ before_install: - sudo add-apt-repository ppa:wpilib/toolchain -y - sudo apt-get update -q || true - sudo apt-get install frc-toolchain libgazebo7-dev protobuf-compiler libprotobuf-dev python3 clang-format-3.8 -y - +install: + - pip3 install wpiformat before_cache: - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock @@ -17,10 +18,7 @@ cache: - $HOME/.gradle/caches/ - $HOME/.gradle/wrapper/ -before_script: - - git clone git://github.com/wpilibsuite/styleguide $HOME/styleguide - script: - - WPI_FORMAT=$HOME/styleguide python3 styleguide/format.py + - wpiformat - git --no-pager diff --exit-code HEAD # Ensure formatter made no changes - ./gradlew build -PmakeSim diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index dc5e7efadd..6e186a170d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -37,7 +37,7 @@ So you want to contribute your changes back to WPILib. Great! We have a few cont ## Coding Guidelines -WPILib uses modified Google style guides for both C++ and Java, which can be found in the [styleguide repository](https://github.com/wpilibsuite/styleguide). Autoformatters are available for many popular editors at https://github.com/google/styleguide. Running format.py, which is in the styleguide directory, is required for all contributions and is enforced by our continuous integration system. +WPILib uses modified Google style guides for both C++ and Java, which can be found in the [styleguide repository](https://github.com/wpilibsuite/styleguide). Autoformatters are available for many popular editors at https://github.com/google/styleguide. Running wpiformat is required for all contributions and is enforced by our continuous integration system. While the library should be fully formatted according to the styles, additional elements of the style guide were not followed when the library was initially created. All new code should follow the guidelines. If you are looking for some easy ramp-up tasks, finding areas that don't follow the style guide and fixing them is very welcome. diff --git a/README.md b/README.md index 0e61af4f01..937035cf7f 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,13 @@ Using Gradle makes building WPILib very straightforward. It only has a few depen - [ARM Compiler Toolchain](http://first.wpi.edu/FRC/roborio/toolchains/) - Doxygen (Only required if you want to build the C++ documentation) -- [format.py](https://github.com/wpilibsuite/styleguide) +- [wpiformat](https://github.com/wpilibsuite/styleguide) ## Setup Clone the WPILib repository. If the toolchains are not installed, install them, and make sure they are available on the system PATH. -See the [styleguide README](https://github.com/wpilibsuite/styleguide/blob/master/README.md) for format.py setup instructions. +See the [styleguide README](https://github.com/wpilibsuite/styleguide/blob/master/README.md) for wpiformat setup instructions. ## Building @@ -67,7 +67,7 @@ The gradlew wrapper only exists in the root of the main project, so be sure to r There are a few tasks other than `build` available. To see them, run the meta-task `tasks`. This will print a list of all available tasks, with a description of each task. -format.py can be executed in either the styleguide or root directories of the repository via `python3 format.py` or `./format.py`. +wpiformat can be executed anywhere in the repository via `py -3 -m wpiformat` on Windows or `python3 -m wpiformat` on other platforms. ## Publishing diff --git a/styleguide/format.py b/styleguide/format.py deleted file mode 100755 index ed55708de1..0000000000 --- a/styleguide/format.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python3 -"""This script invokes format.py in the wpilibsuite/styleguide repository. - -Set the WPI_FORMAT environment variable to its location on disk before use. For -example: - -WPI_FORMAT="$HOME/styleguide" ./format.py -""" - -import os -import subprocess -import sys - - -def main(): - path = os.environ.get("WPI_FORMAT") - if path == None: - print("Error: WPI_FORMAT environment variable not set") - sys.exit(1) - - try: - # Run main format.py script - args = ["python3", path + "/format.py"] - args.extend(sys.argv[1:]) - proc = subprocess.Popen(args) - sys.exit(proc.wait()) - except FileNotFoundError: - # Run main format.py script on windows - args = ["py", "-3", path + "/format.py"] - args.extend(sys.argv[1:]) - proc = subprocess.Popen(args) - sys.exit(proc.wait()) - - -if __name__ == "__main__": - main()