Skip to content

Commit

Permalink
Rename .styleguide configs to .wpiformat to match tool name
Browse files Browse the repository at this point in the history
  • Loading branch information
calcmogul committed Aug 3, 2023
1 parent 6eed30a commit 9dc3e34
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ jobs:
rm -rf branch-test
mkdir branch-test && cd branch-test && git init
git checkout -b master
touch .styleguide
git add .styleguide && git commit -q -m "Initial commit"
touch .wpiformat
git add .wpiformat && git commit -q -m "Initial commit"
wpiformat
# Verify wpiformat reports success if "main" exists
Expand All @@ -99,8 +99,8 @@ jobs:
rm -rf branch-test
mkdir branch-test && cd branch-test && git init
git checkout -b main
touch .styleguide
git add .styleguide && git commit -q -m "Initial commit"
touch .wpiformat
git add .wpiformat && git commit -q -m "Initial commit"
wpiformat
- name: Delete branch-test folder
Expand Down
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions wpiformat/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ On Linux/OSX, execute::
Project Setup
*************

To use these tools with a new project, copy `.styleguide`_, and `.styleguide-license`_ from the examples folder into the project and create a new ``.clang-format`` file based on the desired C/C++ style.
To use these tools with a new project, copy `.wpiformat`_, and `.wpiformat-license`_ from the examples folder into the project and create a new ``.clang-format`` file based on the desired C/C++ style.

Note: Since wpiformat already handles include ordering, it is recommended to use ``SortIncludes: false`` in ``.clang-format``.

.styleguide
-----------
.wpiformat
----------

wpiformat checks the current directory for the ``.styleguide`` file. If one doesn't exist, all parent directories are tried as well. See the ``.styleguide`` file in the docs/examples directory for all possible groups.
wpiformat checks the current directory for the ``.wpiformat`` file. If one doesn't exist, all parent directories are tried as well. See the ``.wpiformat`` file in the docs/examples directory for all possible groups.

This file contains groups of file name regular expressions. There are two groups of regexes which prevent tasks (i.e., formatters and linters) from running on matching files:

Expand All @@ -54,12 +54,12 @@ The regex for C system headers produces false positives on headers from "other l

``NOLINT`` can be appended in a comment to a header include to prevent wpiformat's header include sorter from modifying it and to maintain its relative ordering with other header includes. This will, in effect, treat it as a barrier across which no header includes will be moved. Header includes on each side of the barrier will still be sorted as normal.

.styleguide-license
-------------------
.wpiformat-license
------------------

This file contains the license header template. It should contain ``Copyright (c)`` followed by the company name and the string ``{year}``. See the ``.styleguide-license`` file in the docs/examples directory.
This file contains the license header template. It should contain ``Copyright (c)`` followed by the company name and the string ``{year}``. See the ``.wpiformat-license`` file in the docs/examples directory.

wpiformat checks the currently processed file's directory for a ``.styleguide`` file first and traverses up the directory tree if one isn't found. This allows templates which are closer to the processed file to override a project's main template.
wpiformat checks the currently processed file's directory for a ``.wpiformat`` file first and traverses up the directory tree if one isn't found. This allows templates which are closer to the processed file to override a project's main template.

The license header is always at the beginning of the file and ends after two newlines. If there isn't one, or it doesn't contain the required copyright contents, wpiformat inserts a new one containing the current year.

Expand Down
File renamed without changes.
File renamed without changes.
8 changes: 4 additions & 4 deletions wpiformat/wpiformat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def proc_pipeline(name):
Keyword arguments:
name -- file name string
"""
config_file = Config(os.path.dirname(name), ".styleguide")
config_file = Config(os.path.dirname(name), ".wpiformat")
if verbose1 or verbose2:
with print_lock:
print("Processing", name)
Expand Down Expand Up @@ -128,7 +128,7 @@ def proc_standalone(name):
Keyword arguments:
name -- file name string
"""
config_file = Config(os.path.dirname(name), ".styleguide")
config_file = Config(os.path.dirname(name), ".wpiformat")
if verbose2:
with print_lock:
print("Processing", name)
Expand Down Expand Up @@ -178,7 +178,7 @@ def proc_batch(files):
for subtask in task_pipeline:
work = []
for name in files:
config_file = Config(os.path.dirname(name), ".styleguide")
config_file = Config(os.path.dirname(name), ".wpiformat")
if subtask.should_process_file(config_file, name):
work.append(name)

Expand Down Expand Up @@ -443,7 +443,7 @@ def main():
# Don't run tasks on modifiable or generated files
work = []
for name in files:
config_file = Config(os.path.dirname(name), ".styleguide")
config_file = Config(os.path.dirname(name), ".wpiformat")

if config_file.is_modifiable_file(name):
continue
Expand Down
2 changes: 1 addition & 1 deletion wpiformat/wpiformat/licenseupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def run_pipeline(self, config_file, name, lines):
linesep = super().get_linesep(lines)

_, license_template = Config.read_file(
os.path.dirname(os.path.abspath(name)), ".styleguide-license"
os.path.dirname(os.path.abspath(name)), ".wpiformat-license"
)

# Get year when file was most recently modified in Git history
Expand Down
6 changes: 3 additions & 3 deletions wpiformat/wpiformat/lint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def should_process_file(config_file, name):

@staticmethod
def run_batch(config_file, names):
# Handle running in either the root or styleguide directories
# Handle running in either the root or wpiformat directories
cpplintPrefix = ""
if os.getcwd().rpartition(os.sep)[2] != "styleguide":
cpplintPrefix = "styleguide/"
if os.getcwd().rpartition(os.sep)[2] != "wpiformat":
cpplintPrefix = "wpiformat/"

# Prepare arguments to cpplint.py
saved_argv = sys.argv
Expand Down
2 changes: 1 addition & 1 deletion wpiformat/wpiformat/test/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


def test_config():
config_file = Config(os.path.abspath(os.getcwd()), ".styleguide")
config_file = Config(os.path.abspath(os.getcwd()), ".wpiformat")
assert config_file.is_modifiable_file(
"." + os.sep + "wpiformat" + os.sep + "javaguidelink.png"
)
Expand Down
10 changes: 5 additions & 5 deletions wpiformat/wpiformat/test/test_licenseupdate.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,20 @@ def test_licenseupdate():
)

# Ensure excluded files won't be processed
config_file = Config(os.path.abspath(os.getcwd()), ".styleguide")
config_file = Config(os.path.abspath(os.getcwd()), ".wpiformat")
assert not task.should_process_file(config_file, "./Excluded.h")

# Create git repo to test license years for commits
with OpenTemporaryDirectory():
subprocess.run(["git", "init", "-q"])

# Add base files
with open(".styleguide-license", "w") as file:
with open(".wpiformat-license", "w") as file:
file.write("// Copyright (c) {year}")
with open(".styleguide", "w") as file:
with open(".wpiformat", "w") as file:
file.write("cppSrcFileInclude {\n" + r"\.cpp$")
subprocess.run(["git", "add", ".styleguide-license"])
subprocess.run(["git", "add", ".styleguide"])
subprocess.run(["git", "add", ".wpiformat-license"])
subprocess.run(["git", "add", ".wpiformat"])
subprocess.run(["git", "commit", "-q", "-m", '"Initial commit"'])

# Add file with commit date of last year and range through this year
Expand Down
2 changes: 1 addition & 1 deletion wpiformat/wpiformat/test/test_tasktest.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def run(self, output_type):
"""
assert len(self.inputs) == len(self.outputs)

config_file = Config(os.path.abspath(os.getcwd()), ".styleguide")
config_file = Config(os.path.abspath(os.getcwd()), ".wpiformat")

for i in range(len(self.inputs)):
if self.task.should_process_file(config_file, self.inputs[i][0]):
Expand Down

0 comments on commit 9dc3e34

Please sign in to comment.