Skip to content

Commit 3305690

Browse files
committed
docs: update DocC documentation to reflect current features and implementation
1 parent b213905 commit 3305690

File tree

2 files changed

+81
-76
lines changed

2 files changed

+81
-76
lines changed
Lines changed: 68 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
# Getting Started with SwiftDevKit
22

3-
This guide helps you get started with string and date conversion features in SwiftDevKit.
3+
Learn how to use SwiftDevKit's powerful features for text processing, time utilities, and data conversion.
44

55
## Overview
66

7-
SwiftDevKit provides simple and type-safe ways to convert values to and from strings, including specialized support for date formatting with thread safety.
7+
SwiftDevKit provides a comprehensive set of tools for common development tasks, including string manipulation, time handling, and various data conversion utilities.
88

99
## Requirements
1010

11-
- iOS 16.0+ / macOS 13.0+ / tvOS 16.0+ / watchOS 9.0+
11+
- iOS 13.0+ / macOS 10.15+ / tvOS 13.0+ / watchOS 6.0+
12+
- Xcode 16.0+
1213
- Swift 5.9+
1314

1415
## Basic Setup
@@ -17,106 +18,105 @@ Add SwiftDevKit to your project using Swift Package Manager:
1718

1819
```swift
1920
dependencies: [
20-
.package(url: "https://github.com/yourusername/SwiftDevKit.git", from: "1.0.0")
21+
.package(url: "https://github.com/owdax/SwiftDevKit.git", from: "1.0.0")
2122
]
2223
```
2324

24-
## Using String Conversion
25+
## Text Processing
2526

26-
### Built-in Types
27-
28-
SwiftDevKit extends common numeric types with string conversion capabilities:
27+
### String Transformations
2928

3029
```swift
31-
let number = 42
32-
let string = try await number.toString() // "42"
33-
let backToNumber = try await Int.fromString("42") // 42
30+
let text = "hello world example"
31+
let camelCase = text.toCamelCase() // "helloWorldExample"
32+
let snakeCase = text.toSnakeCase() // "hello_world_example"
33+
let kebabCase = text.toKebabCase() // "hello-world-example"
34+
35+
// Smart truncation
36+
let longText = "This is a very long text that needs truncation"
37+
let truncated = longText.truncate(length: 20) // "This is a very lon..."
38+
39+
// Whitespace handling
40+
let messy = " too many spaces "
41+
let clean = messy.removeExcessWhitespace() // "too many spaces"
3442
```
3543

36-
### Custom Types
37-
38-
Make your types string-convertible by conforming to `StringConvertible`:
44+
### String Extraction
3945

4046
```swift
41-
struct User: StringConvertible {
42-
let id: Int
43-
44-
func toString() async throws -> String {
45-
return String(id)
46-
}
47-
48-
static func fromString(_ string: String) async throws -> Self {
49-
guard let id = Int(string) else {
50-
throw StringConversionError.invalidInput(string)
51-
}
52-
return User(id: id)
53-
}
54-
}
47+
let text = "Contact us at support@example.com or visit https://example.com"
48+
let emails = text.extractEmails() // ["support@example.com"]
49+
let urls = text.extractURLs() // ["https://example.com"]
50+
51+
let post = "Check out #swiftdev and @swift_dev for updates!"
52+
let hashtags = post.extractHashtags() // ["swiftdev"]
53+
let mentions = post.extractMentions() // ["swift_dev"]
5554
```
5655

57-
## Date Conversion
56+
## Time Utilities
5857

59-
SwiftDevKit provides thread-safe date formatting with common predefined formats:
58+
### TimeZone Management
6059

6160
```swift
62-
// Using ISO8601
63-
let date = Date()
64-
let iso8601 = try await date.toISO8601() // "2025-01-16T15:30:00Z"
65-
let parsedDate = try await Date.fromISO8601(iso8601)
66-
67-
// Using custom formats
68-
let shortDate = try await date.toString(format: DateFormat.shortDate) // "01/16/2025"
69-
let httpDate = try await date.toHTTPDate() // "Wed, 16 Jan 2025 15:30:00 GMT"
61+
// Get current time in different zones
62+
let time = TimeZoneUtilities.currentTime(in: "America/New_York")
63+
let offset = TimeZoneUtilities.offsetHours(for: "Europe/London")
64+
65+
// Convert between zones
66+
let converted = TimeZoneUtilities.convert(date: Date(),
67+
from: "UTC",
68+
to: "Asia/Tokyo")
7069
```
7170

72-
### Predefined Date Formats
71+
## Color Conversion
7372

74-
SwiftDevKit includes commonly used date formats:
75-
- `DateFormat.iso8601` - Standard format for APIs
76-
- `DateFormat.http` - For HTTP headers
77-
- `DateFormat.shortDate` - Compact display format
78-
- `DateFormat.longDate` - Human-readable format
79-
- `DateFormat.dateTime` - Combined date and time
80-
- And more...
73+
```swift
74+
// Convert between color formats
75+
let rgb = RGBColor(r: 255, g: 128, b: 0)
76+
let hex = rgb.toHex() // "#FF8000"
77+
let hsl = rgb.toHSL() // HSLColor(h: 30, s: 100, l: 50)
78+
79+
// Parse colors
80+
let color = try ColorConversion.from(hex: "#FF8000")
81+
let rgbComponents = color.rgbComponents
82+
```
83+
84+
## Number Formatting
8185

82-
### Thread Safety
86+
```swift
87+
let number = 1234567.89
88+
let formatted = number.format(style: .currency,
89+
locale: Locale(identifier: "en_US"))
90+
// "$1,234,567.89"
8391

84-
All date conversion operations are thread-safe and can be called concurrently from multiple tasks. The framework uses an actor-based formatter cache to ensure optimal performance while maintaining thread safety.
92+
let scientific = number.format(style: .scientific)
93+
// "1.23E6"
94+
```
8595

8696
## Error Handling
8797

8898
Handle conversion errors appropriately:
8999

90100
```swift
91101
do {
92-
let value = try await Int.fromString("not a number")
93-
} catch let error as StringConversionError {
94-
switch error {
95-
case .invalidInput(let value):
96-
print("Invalid input: \(value)")
97-
}
102+
let color = try ColorConversion.from(hex: "invalid")
103+
} catch let error as ColorConversionError {
104+
print("Invalid color format: \(error.localizedDescription)")
98105
}
99106

100107
do {
101-
let date = try await Date.fromString("invalid", format: DateFormat.iso8601)
102-
} catch let error as DateConversionError {
103-
switch error {
104-
case .invalidFormat(let value):
105-
print("Invalid date format: \(value)")
106-
case .invalidComponents:
107-
print("Invalid date components")
108-
case .invalidFormatString(let format):
109-
print("Invalid format string: \(format)")
110-
case .custom(let message):
111-
print(message)
112-
}
108+
let time = try TimeZoneUtilities.convert(date: Date(),
109+
from: "Invalid/Zone",
110+
to: "UTC")
111+
} catch let error as TimeZoneError {
112+
print("Time zone error: \(error.localizedDescription)")
113113
}
114114
```
115115

116116
## Next Steps
117117

118-
- Explore the API documentation for more details
118+
- Explore the API documentation for detailed information
119119
- Check out example projects in the repository
120120
- Join our community discussions
121121

122-
For more information, visit the [SwiftDevKit Documentation](https://github.com/yourusername/SwiftDevKit).
122+
For more information, visit the [SwiftDevKit Documentation](https://github.com/owdax/SwiftDevKit).

Sources/SwiftDevKit/Documentation.docc/SwiftDevKit.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ SwiftDevKit aims to be your go-to toolkit for common development tasks, offering
88

99
### Key Features
1010

11-
- Data Conversion Tools
12-
- Cryptography Utilities
13-
- Text Processing
14-
- Development Helpers
15-
- Platform Utilities
11+
- Text Processing and String Manipulation
12+
- Time and TimeZone Utilities
13+
- Color Conversion Tools
14+
- Number Formatting
15+
- Date Conversion
1616

1717
## Topics
1818

@@ -21,11 +21,16 @@ SwiftDevKit aims to be your go-to toolkit for common development tasks, offering
2121
- <doc:GettingStarted>
2222
- <doc:Installation>
2323

24-
### Categories
24+
### Core Features
2525

26-
- ``DataConversion``
27-
- ``Cryptography``
2826
- ``TextProcessing``
27+
- ``TimeUtilities``
28+
- ``Conversion``
29+
- ``NumberFormatting``
30+
31+
### Coming Soon
32+
33+
- ``Cryptography``
2934
- ``DevHelpers``
3035
- ``PlatformUtils``
3136

0 commit comments

Comments
 (0)