Skip to content

Commit 8929f69

Browse files
authored
Merge pull request #5 from sdidla/prepare_509.0.0
Prepare 509.0.0 release
2 parents fe29242 + 85e8f49 commit 8929f69

File tree

14 files changed

+69
-164
lines changed

14 files changed

+69
-164
lines changed

.circleci/config.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,15 @@ jobs:
2727
- run:
2828
name: Generate documentation
2929
command: |
30-
mkdir -p "rendered/docs/HatchParser"
30+
mkdir -p "rendered/docs/Hatch"
3131
swift package \
32-
--allow-writing-to-directory "rendered/docs/HatchParser" \
32+
--allow-writing-to-directory "rendered/docs/Hatch" \
3333
generate-documentation \
3434
--target HatchParser \
3535
--disable-indexing \
3636
--transform-for-static-hosting \
37-
--hosting-base-path "/Hatch/docs/HatchParser/" \
38-
--output-path "rendered/docs/HatchParser"
37+
--hosting-base-path "/Hatch/docs/Hatch/" \
38+
--output-path "rendered/docs/Hatch"
3939
- run:
4040
name: Install dependencies
4141
command: |

.swiftpm/xcode/xcshareddata/xcschemes/Hatch-Package.xcscheme

+10
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,16 @@
8080
ReferencedContainer = "container:">
8181
</BuildableReference>
8282
</TestableReference>
83+
<TestableReference
84+
skipped = "NO">
85+
<BuildableReference
86+
BuildableIdentifier = "primary"
87+
BlueprintIdentifier = "HatchTests"
88+
BuildableName = "HatchTests"
89+
BlueprintName = "HatchTests"
90+
ReferencedContainer = "container:">
91+
</BuildableReference>
92+
</TestableReference>
8393
</Testables>
8494
</TestAction>
8595
<LaunchAction

.swiftpm/xcode/xcshareddata/xcschemes/HatchParser.xcscheme

-88
This file was deleted.

Package.swift

+4-18
Original file line numberDiff line numberDiff line change
@@ -9,35 +9,21 @@ let package = Package(
99
platforms: [.iOS(.v13), .macOS(.v10_15)],
1010
products: [
1111
.executable(name: "HatchExample", targets: ["HatchExample"]),
12-
.library(name: "HatchParser", targets: ["HatchParser"]),
13-
.library(name: "HatchBuilder", targets: ["HatchBuilder"]),
12+
.library(name: "Hatch", targets: ["Hatch"]),
1413
],
1514
dependencies: [
1615
.package(name: "swift-syntax", url: "https://github.com/apple/swift-syntax.git", from: "509.0.0")
1716
],
1817
targets: [
19-
.executableTarget(
20-
name: "HatchExample",
21-
dependencies: [
22-
.target(name: "HatchParser"),
23-
.target(name: "HatchBuilder")
24-
]
25-
),
18+
.executableTarget(name: "HatchExample", dependencies: [.target(name: "Hatch")]),
2619
.target(
27-
name: "HatchParser",
20+
name: "Hatch",
2821
dependencies: [
2922
.product(name: "SwiftSyntax", package: "swift-syntax"),
3023
.product(name: "SwiftParser", package: "swift-syntax")
3124
]
3225
),
33-
.target(
34-
name: "HatchBuilder"
35-
),
36-
37-
.testTarget(
38-
name: "HatchParserTests",
39-
dependencies: ["HatchParser"]
40-
)
26+
.testTarget(name: "HatchTests", dependencies: ["Hatch"])
4127
]
4228
)
4329

README.md

+23-20
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,28 @@
33

44
# Hatch
55

6-
Generate Swift using Swift.
7-
8-
This package contains two modules:
9-
- `HatchParser` Provides a simple, extensible parser to to get a hierarchical list of symbols from swift code using [SwiftSyntax](https://github.com/apple/swift-syntax)
10-
- `HatchBuilder` Provides a string concatenating `resultBuidler` so expressions can be interspersed with strings
6+
A simple, extensible parser to to get a hierarchical list of symbols from swift code using [SwiftSyntax](https://github.com/apple/swift-syntax)
117

128
## Documentation
139

14-
- [`HatchParser`](https://sdidla.github.io/Hatch/docs/HatchParser/documentation/hatchparser/)
15-
10+
- [Hatch Documentation](https://sdidla.github.io/Hatch/docs/Hatch/documentation/hatch/)
11+
12+
## Usage
13+
14+
When using Swift Package Manager, add the following to your package dependencies in the `Package.swift` file:
15+
16+
```swift
17+
.package(url: "https://github.com/sdidla/Hatch.git", from: "<#latest swift-syntax tag#>")
18+
```
19+
1620
## Releases
1721

1822
Hatch [releases](https://github.com/sdidla/Hatch/releases/) correspond to releases of [SwiftSyntax](https://github.com/apple/swift-syntax)
1923

2024
## Example
2125

2226
```swift
23-
import HatchParser
27+
import Hatch
2428

2529
let source: String = <some swift code>
2630
let symbols = SymbolParser.parse(source: source)
@@ -55,49 +59,48 @@ Output:
5559

5660
```
5761
▿ 3 elements
58-
HatchParser.Struct
62+
Hatch.Struct
5963
- name: "A1"
6064
▿ children: 3 elements
61-
HatchParser.Struct
65+
Hatch.Struct
6266
- name: "BC"
6367
▿ children: 3 elements
64-
HatchParser.Struct
68+
Hatch.Struct
6569
- name: "C1"
6670
- children: 0 elements
6771
- inheritedTypes: 0 elements
68-
HatchParser.Struct
72+
Hatch.Struct
6973
- name: "C2"
7074
- children: 0 elements
7175
- inheritedTypes: 0 elements
72-
HatchParser.Struct
76+
Hatch.Struct
7377
- name: "C3"
7478
- children: 0 elements
7579
- inheritedTypes: 0 elements
7680
- inheritedTypes: 0 elements
77-
HatchParser.Struct
81+
Hatch.Struct
7882
- name: "BD"
7983
▿ children: 2 elements
80-
HatchParser.Struct
84+
Hatch.Struct
8185
- name: "D1"
8286
- children: 0 elements
8387
- inheritedTypes: 0 elements
84-
HatchParser.Struct
88+
Hatch.Struct
8589
- name: "D2"
8690
- children: 0 elements
8791
- inheritedTypes: 0 elements
8892
- inheritedTypes: 0 elements
89-
HatchParser.Struct
93+
Hatch.Struct
9094
- name: "BX"
9195
- children: 0 elements
9296
- inheritedTypes: 0 elements
9397
- inheritedTypes: 0 elements
94-
HatchParser.Struct
98+
Hatch.Struct
9599
- name: "A2"
96100
- children: 0 elements
97101
- inheritedTypes: 0 elements
98-
HatchParser.Enum
102+
Hatch.Enum
99103
- name: "MyEnum"
100104
- children: 0 elements
101105
- inheritedTypes: 0 elements
102-
103106
```

Sources/HatchParser/Documentation.docc/HatchParser.md Sources/Hatch/Documentation.docc/Hatch.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
# ``HatchParser``
1+
# ``Hatch``
22

3-
HatchParser is a simple, extensible symbol parser based on `SwiftSyntax`
3+
Hatch is a simple, extensible symbol parser based on `SwiftSyntax`
44

55
## Usage
66

77
Extracting symbols from a string or contents of a file using ``SymbolParser/parse(source:)``
88

99
```swift
10-
import HatchParser
10+
import Hatch
1111

1212
let path = "~/Repositories/myProject"
1313
let directoryURL = URL(fileURLWithPath: path)
@@ -22,7 +22,7 @@ let allSymbols = try FileManager.default
2222
dump(allSymbols)
2323
```
2424

25-
You can use swift standard library methods to `filter`, `map`, `compactMap` etc. `HatchParser` provides an additional method on a collection of symbols called ``Symbol/flattened()`` that returns a flat array of symbols derived from the symbol tree while preserving the subtree
25+
You can use swift standard library methods to `filter`, `map`, `compactMap` etc. `Hatch` provides an additional method on a collection of symbols called ``Symbol/flattened()`` that returns a flat array of symbols derived from the symbol tree while preserving the subtree
2626

2727
For example, to extract all the enum case elements from a specific enum, you can do:
2828

File renamed without changes.

Sources/HatchBuilder/CodeBuilder.swift Sources/Hatch/StringBuilder.swift

+22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,27 @@
11
import Foundation
22

3+
/// Provides string concatenation support to make it easier to generate swift code
4+
///
5+
/// Example:
6+
/// ```swift
7+
/// @StringBuilder var myFile: String {
8+
/// """
9+
/// switch symbol {
10+
/// """
11+
///
12+
/// for symbol in symbolNames {
13+
/// """
14+
/// case \(symbol)
15+
/// """
16+
/// }
17+
///
18+
/// """
19+
/// }
20+
/// """
21+
/// }
22+
///
23+
/// try myFile.write(toFile: "myFile.swift", atomically: true, encoding: .utf8)
24+
/// ```
325
@resultBuilder public struct StringBuilder {
426
static public func buildBlock(_ components: String?...) -> String? {
527
return components.compactMap { $0 }.joined(separator: "\n")
File renamed without changes.
File renamed without changes.

Sources/HatchBuilder/Documentation.docc/HatchBuilder.md

-27
This file was deleted.

Sources/HatchExample/HatchExample.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import Foundation
2-
import HatchParser
3-
import HatchBuilder
42
import SwiftSyntax
3+
import Hatch
54

65
@main
76
public struct ExampleApp {

Tests/HatchParserTests/SymbolVisitorTests.swift Tests/HatchTests/SymbolVisitorTests.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import XCTest
2-
@testable import HatchParser
2+
@testable import Hatch
33

44
final class SymbolVisitorTests: XCTestCase {
55

0 commit comments

Comments
 (0)