{"id":20810066,"url":"https://github.com/schwa/swiftformats","last_synced_at":"2025-08-03T16:34:26.742Z","repository":{"id":65639244,"uuid":"595335346","full_name":"schwa/SwiftFormats","owner":"schwa","description":"SwiftFormats","archived":false,"fork":false,"pushed_at":"2025-01-07T03:11:18.000Z","size":139,"stargazers_count":48,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-07T08:12:30.873Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/schwa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-30T21:47:01.000Z","updated_at":"2025-01-07T03:11:21.000Z","dependencies_parsed_at":"2024-03-28T19:44:35.259Z","dependency_job_id":"968124d3-e1f3-4fd2-b506-9fa21e5600cd","html_url":"https://github.com/schwa/SwiftFormats","commit_stats":{"total_commits":34,"total_committers":3,"mean_commits":"11.333333333333334","dds":"0.32352941176470584","last_synced_commit":"7251a27749d3e1bdc498670346498a01acbe4d13"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schwa%2FSwiftFormats","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schwa%2FSwiftFormats/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schwa%2FSwiftFormats/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/schwa%2FSwiftFormats/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/schwa","download_url":"https://codeload.github.com/schwa/SwiftFormats/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252839296,"owners_count":21812090,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-17T20:19:25.161Z","updated_at":"2025-05-07T08:12:36.297Z","avatar_url":"https://github.com/schwa.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SwiftFormats\n\nMore `FormatStyle` implementation for more types.\n\n## Description\n\nThis package provides more `FormatStyle` implementations for various types. Many types also provide `parserStrategy` implementations for parsing strings into the type where appropriate.\n\nIt also provides extensions for String and string interpolation to make it easier to format values.\n\n## Types\n\n\u003c!-- TODO: Big table. Break it down. --\u003e\n\n| Name | In (1)                   | Out (2)  | Format (3)            | Parser (4) | Accessor (5)  | Notes                                |\n|------|--------------------------|----------|-----------------------|------------|---------------|--------------------------------------|\n|      | `BinaryFloatingPoint`    | `String` | Angles                | Yes        | `angle`       | Radians, degrees, etc                |\n|      | `BinaryFloatingPoint`    | `String` | Degree Minute Seconds | No         | `dmsNotation` |                                      |\n|      | `CGPoint`                | `String` | List (6)              | Yes        | `point`       |                                      |\n|      | `ClosedRange`            | `String` | `X ... Y`             | Yes        | No            |                                      |\n|      | `CLLocationCoordinate2D` | `String` | List                  | No         | `coordinates` |                                      |\n|      | `BinaryFloatingPoint`    | `String` | Latitude              | No         | `latitude`    | Including hemisphere                 |\n|      | `BinaryFloatingPoint`    | `String` | Longitude             | No         | `longitude`   | Including hemisphere                 |\n|      | `Any`                    | `String` | Description           | No         | `describing`  | Uses `String(describing:)`           |\n|      | `Any`                    | `String` | Dump                  | No         | `dumped`      | Uses `dump()`                        |\n|      | `DataProtocol`           | `String` | Hex-dumped            | No         | `hexdumped`   |                                      |\n|      | `Codable`                | `String` | JSON                  | Yes        | `json`        | Uses `JSONEncoder` and `JSONDecoder` |\n|      | `SIMD3\u003cFloat\u003e`           | `String` | List or mapping       | Yes        | `vector`      |                                      |\n|      | SIMD matrix types        | `String` | List                  | Yes        | `matrix`      |                                      |\n|      | `BinaryInteger`          | `String` | Radixed format        | No         | Various       | Binary, Octal, Hex representations   |\n\n\n### Notes\n\n1: Type provided as `FormatInput` in the `FormatStyle` implementation.\n2: Type provided as `FormatOutput` in the `FormatStyle` implementation.\n3: Format of the output.\n4: Whether the `FormatStyle` implementation provides a corresponding `ParserStrategy`.\n5: Whether a convenience property is provided to access style on `FormatStyle`.\n6: Formats the input as a comma-separated list.\n\n## Examples\n\n### String interpolation\n\n```swift\nlet number = 123.456\nlet formatted = \"The number is \\(number, .number)\"\n// formatted == \"The number is 123.456\"\n```\n\n### CoreGraphics\n\n```swift\nlet point = CGPoint(x: 1.234, y: 5.678)\nlet formatted = point.formatted(.decimal(places: 2))\n// formatted == \"(1.23, 5.68)\"\n```\n\n## Future Plans\n\nThe initial priority is to expose formats and parsers for more SIMD/CG types. Some common helper format styles will be added (e.g. \"field\" parser - see TODO).\n\n### TODOs\n\n- [ ] Find and handle all the TODOs\n- [ ] Clean up the parser init methods. Foundation parsers do not have public .init() methods and are only created via corresponding FormatStyles. Follow this. This will be API breaking.\n- [ ] Add more `.formatted()` and `.formatted(_ style:)` functions where appropriate\n    - [ ] Track this in tabel\n- [ ] Add sugar for parsing (does a standard library equivalent to `.formatted()` exist?)\n- [ ] Investigate attribute strings and other non-string `FormatOutput` types\n- [ ] More CoreGraphics types\n- [ ] Yet another CGColor to web colour converter\n- [ ] Do all SIMD types in a sane way\n- [ ] Make a \"field\" type generic format, e.g. represent CGPoint as `x: 1.234, y: 5.678` (use for SIMD and other CG types)\n- [ ] A parser for angle would be nice but `Measurement\u003cAngle\u003e` has no parser we can base it off.\n- [ ] Investigate a \"Parsable\" and \"Formattable\" protocol that provides a .formatted() etc functions.\n- [ ] Add support for SwiftUI.Angle - how do we differentiate between two different Angle formatters?\n- [ ] Add support for Spatial.framework types\n- [ ] Make quaternion and vector parsers more accepting of styles.\n- [ ] Make quaternion parser treat angles as angle foramts (i.e. with °)\n- [X] Make angle parser not care and parse rad or ° correctly.\n- [ ] Test 'radian' vs 'radians' vs localized.\n- [ ] In general parsers need to be configured less and accept more formats.\n- [ ] Real docc documentation.\n- [ ] Fuzz parsers and see what fun will ensue.\n\n## Resources\n\n### Apple\n\n- \u003chttps://developer.apple.com/documentation/foundation/formatstyle\u003e\n- \u003chttps://developer.apple.com/documentation/foundation/parseableformatstyle\u003e\n- \u003chttps://developer.apple.com/documentation/foundation/floatingpointformatstyle\u003e\n\n### Other\n\n- \u003chttps://fuckingformatstyle.com\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschwa%2Fswiftformats","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fschwa%2Fswiftformats","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fschwa%2Fswiftformats/lists"}