Skip to content

Commit 6d11986

Browse files
authored
Bump Swift version (#4)
* Bump swift version * Update .gitignore * Update check-source script Fix "[email protected] not pass the license check" issue * Fix everythindDocument * Update Package.swift Update to Swift 5.3 to support Bundle.module
1 parent b73b9d8 commit 6d11986

File tree

7 files changed

+95
-53
lines changed

7 files changed

+95
-53
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,5 @@
1010
/.build
1111
/Packages
1212
/*.xcodeproj
13+
.swiftpm
14+
Package.resolved

Package.swift

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// swift-tools-version:4.2
1+
// swift-tools-version:5.3
22
/*
33
This source file is part of the Swift.org open source project
44

@@ -25,13 +25,21 @@ let package = Package(
2525
targets: [
2626
.target(
2727
name: "Markdown",
28-
dependencies: ["cmark-gfm", "cmark-gfm-extensions", "CAtomic"]),
28+
dependencies: [
29+
"CAtomic",
30+
.product(name: "cmark-gfm", package: "swift-cmark"),
31+
.product(name: "cmark-gfm-extensions", package: "swift-cmark"),
32+
]),
2933
.target(
3034
name: "markdown-tool",
31-
dependencies: ["Markdown", .product(name: "ArgumentParser", package: "swift-argument-parser")]),
35+
dependencies: [
36+
"Markdown",
37+
.product(name: "ArgumentParser", package: "swift-argument-parser")
38+
]),
3239
.testTarget(
3340
name: "MarkdownTests",
34-
dependencies: ["Markdown"]),
41+
dependencies: ["Markdown"],
42+
resources: [.process("Visitors/Everything.md")]),
3543
.target(name: "CAtomic"),
3644
]
3745
)

[email protected]

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// swift-tools-version:5.5
2+
// In order to support users running on the latest Xcodes, please ensure that
3+
// [email protected] is kept in sync with this file.
4+
/*
5+
This source file is part of the Swift.org open source project
6+
7+
Copyright (c) 2021 Apple Inc. and the Swift project authors
8+
Licensed under Apache License v2.0 with Runtime Library Exception
9+
10+
See https://swift.org/LICENSE.txt for license information
11+
See https://swift.org/CONTRIBUTORS.txt for Swift project authors
12+
*/
13+
14+
import PackageDescription
15+
import class Foundation.ProcessInfo
16+
17+
let package = Package(
18+
name: "swift-markdown",
19+
products: [
20+
.library(
21+
name: "Markdown",
22+
targets: ["Markdown"]),
23+
.executable(
24+
name: "markdown-tool",
25+
targets: ["markdown-tool"]),
26+
],
27+
targets: [
28+
.target(
29+
name: "Markdown",
30+
dependencies: [
31+
"CAtomic",
32+
.product(name: "cmark-gfm", package: "swift-cmark"),
33+
.product(name: "cmark-gfm-extensions", package: "swift-cmark"),
34+
]),
35+
.executableTarget(
36+
name: "markdown-tool",
37+
dependencies: [
38+
"Markdown",
39+
.product(name: "ArgumentParser", package: "swift-argument-parser")
40+
]),
41+
.testTarget(
42+
name: "MarkdownTests",
43+
dependencies: ["Markdown"],
44+
resources: [.process("Visitors/Everything.md")]),
45+
.target(name: "CAtomic"),
46+
]
47+
)
48+
49+
// If the `SWIFTCI_USE_LOCAL_DEPS` environment variable is set,
50+
// we're building in the Swift.org CI system alongside other projects in the Swift toolchain and
51+
// we can depend on local versions of our dependencies instead of fetching them remotely.
52+
if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil {
53+
// Building standalone, so fetch all dependencies remotely.
54+
package.dependencies += [
55+
.package(url: "https://github.com/apple/swift-cmark.git", .branch("gfm")),
56+
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "0.4.4")),
57+
]
58+
} else {
59+
// Building in the Swift.org CI system, so rely on local versions of dependencies.
60+
package.dependencies += [
61+
.package(path: "../swift-cmark-gfm"),
62+
.package(path: "../swift-argument-parser"),
63+
]
64+
}

Tests/MarkdownTests/Visitors/Everything.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@
1313
> BlockQuote
1414
1515
```swift
16-
func foo() { let x = 1 }
16+
func foo() {
17+
let x = 1
18+
}
1719
```
1820

21+
// Is this real code? Or just fantasy?
22+
1923
This is an <topic://autolink>.
2024

2125
---
2226

2327
<a href="foo.png">
24-
An HTML Block.
28+
An HTML Block.
2529
</a>
2630

2731
This is some <p>inline html</p>.

Tests/MarkdownTests/Visitors/MarkupRewriterTests.swift

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,7 @@ import XCTest
1212
@testable import Markdown
1313

1414
/// A `Document` that has every kind of element in it at least once.
15-
let everythingDocument = Document(parsing: """
16-
# Header
17-
18-
*Emphasized* **strong** `inline code` [link](foo) ![image](foo).
19-
20-
- this
21-
- is
22-
- a
23-
- list
24-
25-
1. eggs
26-
1. milk
27-
28-
> BlockQuote
29-
30-
```swift
31-
func foo() {
32-
let x = 1
33-
}
34-
```
35-
36-
// Is this real code? Or just fantasy?
37-
38-
This is an <topic://autolink>.
39-
40-
---
41-
42-
<a href="foo.png">
43-
An HTML Block.
44-
</a>
45-
46-
This is some <p>inline html</p>.
47-
48-
line
49-
break
50-
51-
soft
52-
break
53-
""")
15+
let everythingDocument = Document(parsing: try! String(contentsOf: Bundle.module.url(forResource: "Everything", withExtension: "md")!))
5416

5517

5618
class MarkupRewriterTests: XCTestCase {

Tests/MarkdownTests/Visitors/MarkupTreeDumperTests.swift

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import XCTest
1414
final class MarkupTreeDumperTests: XCTestCase {
1515
func testDumpEverything() {
1616
let expectedDump = """
17-
Document @1:1-37:6 Root #\(everythingDocument.raw.metadata.id.rootId) #0
17+
Document @1:1-39:90 Root #\(everythingDocument.raw.metadata.id.rootId) #0
1818
├─ Heading @1:1-1:9 #1 level: 1
1919
│ └─ Text @1:3-1:9 #2 "Header"
2020
├─ Paragraph @3:1-3:65 #3
@@ -52,8 +52,8 @@ final class MarkupTreeDumperTests: XCTestCase {
5252
│ └─ ListItem @11:1-12:1 #35
5353
│ └─ Paragraph @11:4-11:8 #36
5454
│ └─ Text @11:4-11:8 #37 "milk"
55-
├─ BlockQuote @13:1-13:14 #38
56-
│ └─ Paragraph @13:3-13:14 #39
55+
├─ BlockQuote @13:1-13:13 #38
56+
│ └─ Paragraph @13:3-13:13 #39
5757
│ └─ Text @13:3-13:13 #40 "BlockQuote"
5858
├─ CodeBlock @15:1-19:4 #41 language: swift
5959
│ func foo() {
@@ -81,10 +81,12 @@ final class MarkupTreeDumperTests: XCTestCase {
8181
│ ├─ Text @33:1-33:7 #57 "line"
8282
│ ├─ LineBreak #58
8383
│ └─ Text @34:1-34:6 #59 "break"
84-
└─ Paragraph @36:1-37:6 #60
85-
├─ Text @36:1-36:5 #61 "soft"
86-
├─ SoftBreak #62
87-
└─ Text @37:1-37:6 #63 "break"
84+
├─ Paragraph @36:1-37:6 #60
85+
│ ├─ Text @36:1-36:5 #61 "soft"
86+
│ ├─ SoftBreak #62
87+
│ └─ Text @37:1-37:6 #63 "break"
88+
└─ HTMLBlock @39:1-39:90 #64
89+
<!-- Copyright (c) 2021 Apple Inc and the Swift Project authors. All Rights Reserved. -->
8890
"""
8991
print(everythingDocument.debugDescription(options: [.printEverything]))
9092
XCTAssertEqual(expectedDump, everythingDocument.debugDescription(options: [.printEverything]))

bin/check-source

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ for language in swift-or-c bash md-or-tutorial html docker; do
4949
reader=head
5050
case "$language" in
5151
swift-or-c)
52-
exceptions=( -name Package.swift)
52+
exceptions=( -name 'Package*.swift')
5353
matching_files=( -name '*.swift' -o -name '*.c' -o -name '*.h' )
5454
cat > "$tmp" <<"EOF"
5555
/*

0 commit comments

Comments
 (0)