Skip to content

Commit 9472a81

Browse files
author
SamYin Kim
committed
Update TSPL to 6.1
1 parent 2c399f8 commit 9472a81

34 files changed

+531
-282
lines changed

contributing.md

Lines changed: 105 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,108 @@
1515

1616
如果修改过程中我的库有了更新,请重复6、7、8步。
1717

18-
修改之后,首先push到你的库,然后登录GitHub,在你的库的首页可以看到一个 `pull request` 按钮,点击它,填写一些说明信息,然后提交即可。
18+
修改之后,首先push到你的库,然后登录GitHub,在你的库的首页可以看到一个 `pull request` 按钮,点击它,填写一些说明信息,然后提交即可。
19+
20+
# Contributing to *The Swift Programming Language* book
21+
22+
By submitting a pull request,
23+
you represent that you have the right to license your contribution
24+
to Apple and the community,
25+
and agree by submitting the patch
26+
that your contributions are licensed under
27+
the [Swift license](https://swift.org/LICENSE.txt).
28+
29+
For small changes,
30+
like typo fixes and revisions within a few paragraphs,
31+
the discussion of those changes is usually small enough
32+
to be part of the pull request.
33+
For large changes,
34+
like new chapters and sections,
35+
start a thread in the [Swift forums][forum]
36+
to discuss your approach and identify possible issues
37+
before you invest a lot of time in writing.
38+
In general,
39+
the amount of discussion around a change before making a pull request
40+
corresponds to the size of that change.
41+
42+
Content in this book follows [Apple Style Guide][asg]
43+
and [this book’s style guide][tspl-style].
44+
45+
[asg]: https://help.apple.com/applestyleguide/
46+
[forum]: https://forums.swift.org/c/swift-documentation/92
47+
[tspl-style]: /Style.md
48+
49+
## Working on a feature branch
50+
51+
If this is your first contribution,
52+
start by making a fork of the Git repository.
53+
54+
In your fork,
55+
make a new branch starting at `main`
56+
with a brief, descriptive name.
57+
Branch names are ephemeral:
58+
When a pull request is merged,
59+
the merge commit doesn’t include name of your feature branch.
60+
61+
If you need to incorporate changes from `main` or resolve a merge conflict,
62+
merge `main` into your feature branch.
63+
Before creating a pull request,
64+
you can instead rebase your feature branch onto `main` if you prefer,
65+
but don't rebase commits that are part of a pull request.
66+
67+
## Writing commit messages
68+
69+
Use the Git commit message to communicate with other contributors —
70+
both the people working on the project now
71+
who are reviewing your changes,
72+
and people who join the project in the future
73+
who will need to understand what you changed and why.
74+
75+
Every commit starts with a one-sentence summary.
76+
The summary usually fits in 50 characters,
77+
but it's ok to exceed that amount occasionally
78+
if rewriting for brevity would make it too hard to read.
79+
If it's hard to write a good summary,
80+
try breaking your changes into multiple smaller commits.
81+
82+
If you can't explain the commit entirely in its summary,
83+
skip one line and add additional information.
84+
This additional information includes information like
85+
the reasons for the change,
86+
the approach you took when making it,
87+
alternatives you considered,
88+
and a summary of what you changed.
89+
Hard wrap these lines at 72 characters
90+
and leave a blank line between paragraphs.
91+
The body of a commit is plain text,
92+
not markdown like the content of the book.
93+
94+
Following these formatting conventions in your commit
95+
makes it easier to read
96+
in places like the output from `git` and notification emails.
97+
Most text editors can help you write a commit message
98+
by marking lines that are too long
99+
and hard wrapping text automatically.
100+
101+
## Submitting a pull request
102+
103+
Use the following steps when creating a new pull request:
104+
105+
1. Test that your changes build locally by running `docc preview TSPL.docc`.
106+
2. Create a pull request in this repository.
107+
3. Write a brief message in the pull request to introduce your work in context.
108+
109+
Within a few days,
110+
someone will assign reviewers and start a build in CI.
111+
112+
During the review of the pull request,
113+
add new commits on your branch to incorporate feedback,
114+
but don’t rebase or force push.
115+
Rewriting the branch's history
116+
makes it hard for reviewers to see
117+
what changed since the last time they reviewed your changes.
118+
If there are merge conflicts,
119+
merge `main` into your branch or use the GitHub web UI
120+
to resolve the conflicts when accepting the pull request.
121+
122+
After a pull request is merged, delete the feature branch.

swift-6.docc/GuidedTour/GuidedTour.md

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
<!--
2-
要翻译的文件:https://github.com/SwiftGGTeam/the-swift-programming-language-in-chinese/blob/swift-6-beta-translation/swift-6.docc/GuidedTour/GuidedTour.md
3-
Swift 文档源文件地址:https://docs.swift.org/swift-book/documentation/the-swift-programming-language/guidedtour
4-
翻译估计用时:⭐️⭐️⭐️⭐️⭐️
5-
-->
6-
71
# A Swift Tour
82

93
Explore the features and syntax of Swift.
@@ -261,7 +255,7 @@ occupations["Jayne"] = "Public Relations"
261255
```swifttest
262256
-> var fruits = ["strawberries", "limes", "tangerines"]
263257
-> fruits[1] = "grapes"
264-
---
258+
265259
-> var occupations = [
266260
"Malcolm": "Captain",
267261
"Kaylee": "Mechanic",
@@ -323,7 +317,7 @@ let emptyDictionary: [String: Float] = [:]
323317
```swifttest
324318
-> let emptyArray: [String] = []
325319
-> let emptyDictionary: [String: Float] = [:]
326-
---
320+
327321
-> let anotherEmptyArray = [String]()
328322
-> let emptyDictionary = [String: Float]()
329323
```
@@ -438,7 +432,7 @@ if let name = optionalName {
438432
-> var optionalString: String? = "Hello"
439433
-> print(optionalString == nil)
440434
<- false
441-
---
435+
442436
-> var optionalName: String? = "John Appleseed"
443437
-> var greeting = "Hello!"
444438
-> if let name = optionalName {
@@ -664,7 +658,7 @@ print(m)
664658
}
665659
-> print(n)
666660
<- 128
667-
---
661+
668662
-> var m = 2
669663
-> repeat {
670664
m *= 2
@@ -1138,11 +1132,11 @@ class NamedShape {
11381132
-> class NamedShape {
11391133
var numberOfSides: Int = 0
11401134
var name: String
1141-
---
1135+
11421136
init(name: String) {
11431137
self.name = name
11441138
}
1145-
---
1139+
11461140
func simpleDescription() -> String {
11471141
return "A shape with \(numberOfSides) sides."
11481142
}
@@ -1208,17 +1202,17 @@ test.simpleDescription()
12081202
```swifttest
12091203
-> class Square: NamedShape {
12101204
var sideLength: Double
1211-
---
1205+
12121206
init(sideLength: Double, name: String) {
12131207
self.sideLength = sideLength
12141208
super.init(name: name)
12151209
numberOfSides = 4
12161210
}
1217-
---
1211+
12181212
func area() -> Double {
12191213
return sideLength * sideLength
12201214
}
1221-
---
1215+
12221216
override func simpleDescription() -> String {
12231217
return "A square with sides of length \(sideLength)."
12241218
}
@@ -1282,13 +1276,13 @@ print(triangle.sideLength)
12821276
```swifttest
12831277
-> class EquilateralTriangle: NamedShape {
12841278
var sideLength: Double = 0.0
1285-
---
1279+
12861280
init(sideLength: Double, name: String) {
12871281
self.sideLength = sideLength
12881282
super.init(name: name)
12891283
numberOfSides = 3
12901284
}
1291-
---
1285+
12921286
var perimeter: Double {
12931287
get {
12941288
return 3.0 * sideLength
@@ -1297,7 +1291,7 @@ print(triangle.sideLength)
12971291
sideLength = newValue / 3.0
12981292
}
12991293
}
1300-
---
1294+
13011295
override func simpleDescription() -> String {
13021296
return "An equilateral triangle with sides of length \(sideLength)."
13031297
}
@@ -1477,7 +1471,7 @@ let aceRawValue = ace.rawValue
14771471
case ace = 1
14781472
case two, three, four, five, six, seven, eight, nine, ten
14791473
case jack, queen, king
1480-
---
1474+
14811475
func simpleDescription() -> String {
14821476
switch self {
14831477
case .ace:
@@ -1568,7 +1562,7 @@ let heartsDescription = hearts.simpleDescription()
15681562
```swifttest
15691563
-> enum Suit {
15701564
case spades, hearts, diamonds, clubs
1571-
---
1565+
15721566
func simpleDescription() -> String {
15731567
switch self {
15741568
case .spades:
@@ -1685,10 +1679,10 @@ case let .failure(message):
16851679
case result(String, String)
16861680
case failure(String)
16871681
}
1688-
---
1682+
16891683
-> let success = ServerResponse.result("6:00 am", "8:09 pm")
16901684
-> let failure = ServerResponse.failure("Out of cheese.")
1691-
---
1685+
16921686
-> switch success {
16931687
case let .result(sunrise, sunset):
16941688
print("Sunrise is at \(sunrise) and sunset is at \(sunset).")
@@ -1916,7 +1910,6 @@ let userID = await server.connect()
19161910
```
19171911
-->
19181912

1919-
19201913
## Protocols and Extensions
19211914

19221915
Use `protocol` to declare a protocol.
@@ -1988,7 +1981,7 @@ let bDescription = b.simpleDescription
19881981
-> let aDescription = a.simpleDescription
19891982
>> print(aDescription)
19901983
<< A very simple class. Now 100% adjusted.
1991-
---
1984+
19921985
-> struct SimpleStructure: ExampleProtocol {
19931986
var simpleDescription: String = "A simple structure"
19941987
mutating func adjust() {
@@ -2315,13 +2308,13 @@ print(fridgeIsOpen)
23152308
```swifttest
23162309
-> var fridgeIsOpen = false
23172310
-> let fridgeContent = ["milk", "eggs", "leftovers"]
2318-
---
2311+
23192312
-> func fridgeContains(_ food: String) -> Bool {
23202313
fridgeIsOpen = true
23212314
defer {
23222315
fridgeIsOpen = false
23232316
}
2324-
---
2317+
23252318
let result = fridgeContent.contains(food)
23262319
return result
23272320
}

swift-6.docc/Info.plist

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>CFBundleDisplayName</key>
6-
<string>The Swift Programming Language(中文版)</string>
7-
<key>CFBundleIdentifier</key>
8-
<string>team.swiftgg.tspl</string>
9-
<key>CDDefaultCodeListingLanguage</key>
10-
<string>swift</string>
11-
<key>CDDefaultModuleKind</key>
12-
<string></string>
5+
<key>CFBundleDisplayName</key>
6+
<string>The Swift Programming Language</string>
7+
<key>CFBundleIdentifier</key>
8+
<string>org.swift.tspl</string>
9+
<key>CDDefaultCodeListingLanguage</key>
10+
<string>swift</string>
11+
<key>CDDefaultModuleKind</key>
12+
<string></string>
1313
</dict>
1414
</plist>

0 commit comments

Comments
 (0)