diff --git a/docs/ContributionGuidelines.md b/docs/ContributionGuidelines.md index c18a2825..91f8bbb9 100644 --- a/docs/ContributionGuidelines.md +++ b/docs/ContributionGuidelines.md @@ -58,6 +58,7 @@ Your guide must follow this structure: - Use concise and user-friendly language. - Ensure all code examples are complete, tested, and follow the engine’s coding conventions. - PRs must be documented in the /Documentation folder, with guides in markdown format. +- Make sure your code follows the [formatting guidelines](Formatting.md). --- Thank you for contributing to the Untold Engine! Following these guidelines will ensure that your work aligns with the project's goals and provides value to users. diff --git a/docs/Formatting.md b/docs/Formatting.md new file mode 100644 index 00000000..68b50d81 --- /dev/null +++ b/docs/Formatting.md @@ -0,0 +1,48 @@ +# Formatting and Linting + +To maintain a consistent code style across the Untold Engine repo, we use [SwiftFormat](https://github.com/nicklockwood/SwiftFormat). SwiftFormat is a code formatter for Swift that helps enforce Swift style conventions and keep the codebase clean. + +### Installing SwiftFormat + +The simplest way to install SwiftFormat is through the command line. + +1. Install SwiftFormat Using Homebrew: Open the terminal and run the following command: + +```bash +brew install swiftformat +``` +2. Verify Installation: After installation, verify that SwiftFormat is installed correctly by running: + +```bash +swiftformat --version +``` +This should print the installed version of SwiftFormat. + +### Using SwiftFormat + +Format a Single File + +To format a specific Swift file: + +1. Open the terminal and navigate to your project directory. + +2. Run the following command: + +```bash +swiftformat path/to/YourFile.swift +``` +This will format YourFile.swift according to the default rules. + +### Format Multiple Files + +To format all Swift files in your project: + +1. Navigate to your project directory in the terminal. + +2. Run the following command: + +```bash +swiftformat . +``` + +This will recursively format all Swift files in the current directory and its subdirectories.