Skip to content

Commit

Permalink
Make: Formatting Swift code
Browse files Browse the repository at this point in the history
  • Loading branch information
ashvardanian committed Apr 11, 2024
1 parent 00bd84c commit f6faf4c
Show file tree
Hide file tree
Showing 6 changed files with 222 additions and 124 deletions.
13 changes: 13 additions & 0 deletions .swift-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"lineLength": 120,
"indentation": {
"spaces": 4
},
"maximumBlankLines": 1,
"respectsExistingLineBreaks": true,
"lineBreakBeforeControlFlowKeywords": true,
"lineBreakBeforeEachArgument": true,
"multiElementCollectionTrailingCommas": true,
"spacesAroundRangeFormationOperators": true
}
18 changes: 17 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# Contributing to UForm

We welcome contributions to UForm!

## Python

Before submitting any changes, please make sure that the tests pass.

```sh
Expand All @@ -13,4 +16,17 @@ pip install -e ".[torch,onnx]" # For PyTorch and ONNX Python tests

pytest python/scripts/ -s -x -Wd -v
pytest python/scripts/ -s -x -Wd -v -k onnx # To run only ONNX tests without loading Torch
```
```

## Swift

Swift formatting is enforced with `swift-format` default utility from Apple.
To install and run it on all the files in the project, use the following command:

```bash
brew install swift-format
swift-format . -i -r
```

The style is controlled by the `.swift-format` JSON file in the root of the repository.
As there is no standard for Swift formatting, even Apple's own `swift-format` tool and Xcode differ in their formatting rules, and available settings.
2 changes: 1 addition & 1 deletion Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/ashvardanian/swift-transformers",
"state" : {
"revision" : "4060e8ff7c959b89afa7f672cb0a479e87add284"
"revision" : "9ef46a51eca46978b62773f8887926dfe72b0ab4"
}
}
],
Expand Down
15 changes: 9 additions & 6 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ let package = Package(
name: "UForm",
platforms: [
// Linux doesn't have to be explicitly listed
.iOS(.v16), // For iOS, version 13 and later
.tvOS(.v16), // For tvOS, version 13 and later
.macOS(.v13), // For macOS, version 10.15 (Catalina) and later
.watchOS(.v6) // For watchOS, version 6 and later
.iOS(.v16), // For iOS, version 13 and later
.tvOS(.v16), // For tvOS, version 13 and later
.macOS(.v13), // For macOS, version 10.15 (Catalina) and later
.watchOS(.v6), // For watchOS, version 6 and later
],
products: [
.library(
Expand All @@ -17,7 +17,10 @@ let package = Package(
)
],
dependencies: [
.package(url: "https://github.com/ashvardanian/swift-transformers", revision: "4060e8ff7c959b89afa7f672cb0a479e87add284")
.package(
url: "https://github.com/ashvardanian/swift-transformers",
revision: "9ef46a51eca46978b62773f8887926dfe72b0ab4"
)
],
targets: [
.target(
Expand All @@ -33,6 +36,6 @@ let package = Package(
dependencies: ["UForm"],
path: "swift",
sources: ["EmbeddingsTests.swift"]
)
),
]
)
Loading

0 comments on commit f6faf4c

Please sign in to comment.