diff --git a/Package.swift b/Package.swift index 8fe0bb30..fa4030e4 100644 --- a/Package.swift +++ b/Package.swift @@ -1,10 +1,8 @@ -// swift-tools-version:5.3 -// In order to support users running on the latest Xcodes, please ensure that -// Package@swift-5.5.swift is kept in sync with this file. +// swift-tools-version:5.5 /* This source file is part of the Swift.org open source project - Copyright (c) 2021 Apple Inc. and the Swift project authors + Copyright (c) 2021-2023 Apple Inc. and the Swift project authors Licensed under Apache License v2.0 with Runtime Library Exception See https://swift.org/LICENSE.txt for license information @@ -51,9 +49,16 @@ let package = Package( if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { // Building standalone, so fetch all dependencies remotely. package.dependencies += [ - .package(url: "https://github.com/apple/swift-cmark.git", .branch("gfm")), - .package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "1.0.1")), + .package(url: "https://github.com/apple/swift-cmark.git", branch: "gfm"), + .package(url: "https://github.com/apple/swift-argument-parser", from: "1.2.2"), ] + + // SwiftPM command plugins are only supported by Swift version 5.6 and later. + #if swift(>=5.6) + package.dependencies += [ + .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.1.0"), + ] + #endif } else { // Building in the Swift.org CI system, so rely on local versions of dependencies. package.dependencies += [ diff --git a/Package@swift-5.5.swift b/Package@swift-5.5.swift deleted file mode 100644 index f06ac260..00000000 --- a/Package@swift-5.5.swift +++ /dev/null @@ -1,70 +0,0 @@ -// swift-tools-version:5.5 -// In order to support users running on previous versions of Xcode, please ensure that -// Package.swift is kept in sync with this file. -/* - This source file is part of the Swift.org open source project - - Copyright (c) 2021 Apple Inc. and the Swift project authors - Licensed under Apache License v2.0 with Runtime Library Exception - - See https://swift.org/LICENSE.txt for license information - See https://swift.org/CONTRIBUTORS.txt for Swift project authors -*/ - -import PackageDescription -import class Foundation.ProcessInfo - -let cmarkPackageName = ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil ? "swift-cmark" : "cmark" - -let package = Package( - name: "swift-markdown", - products: [ - .library( - name: "Markdown", - targets: ["Markdown"]), - ], - targets: [ - .target( - name: "Markdown", - dependencies: [ - "CAtomic", - .product(name: "cmark-gfm", package: cmarkPackageName), - .product(name: "cmark-gfm-extensions", package: cmarkPackageName), - ]), - .executableTarget( - name: "markdown-tool", - dependencies: [ - "Markdown", - .product(name: "ArgumentParser", package: "swift-argument-parser") - ]), - .testTarget( - name: "MarkdownTests", - dependencies: ["Markdown"], - resources: [.process("Visitors/Everything.md")]), - .target(name: "CAtomic"), - ] -) - -// If the `SWIFTCI_USE_LOCAL_DEPS` environment variable is set, -// we're building in the Swift.org CI system alongside other projects in the Swift toolchain and -// we can depend on local versions of our dependencies instead of fetching them remotely. -if ProcessInfo.processInfo.environment["SWIFTCI_USE_LOCAL_DEPS"] == nil { - // Building standalone, so fetch all dependencies remotely. - package.dependencies += [ - .package(url: "https://github.com/apple/swift-cmark.git", .branch("gfm")), - .package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "1.0.1")), - ] - - // SwiftPM command plugins are only supported by Swift version 5.6 and later. - #if swift(>=5.6) - package.dependencies += [ - .package(url: "https://github.com/apple/swift-docc-plugin", from: "1.1.0"), - ] - #endif -} else { - // Building in the Swift.org CI system, so rely on local versions of dependencies. - package.dependencies += [ - .package(path: "../cmark"), - .package(path: "../swift-argument-parser"), - ] -} diff --git a/README.md b/README.md index e9e9b6de..a7d8c327 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,18 @@ The markup tree provided by this package is comprised of immutable/persistent, t In your `Package.swift` Swift Package Manager manifest, add the following dependency to your `dependencies` argument: ```swift -.package(url: "https://github.com/apple/swift-markdown.git", .branch("main")), +.package(url: "https://github.com/apple/swift-markdown.git", branch: "main"), ``` Add the dependency to any targets you've declared in your manifest: ```swift -.target(name: "MyTarget", dependencies: ["Markdown"]), +.target( + name: "MyTarget", + dependencies: [ + .product(name: "Markdown", package: "swift-markdown"), + ] +), ``` To parse a document, use `Document(parsing:)`, supplying a `String` or `URL`: @@ -61,4 +66,4 @@ Swift Markdown can be improved to better meet your needs. Please see the [contributing guide](https://swift.org/contributing/#contributing-code) for more information. - + diff --git a/Sources/markdown-tool/main.swift b/Sources/markdown-tool/MarkdownCommand.swift similarity index 98% rename from Sources/markdown-tool/main.swift rename to Sources/markdown-tool/MarkdownCommand.swift index 7f6b2286..45aecba8 100644 --- a/Sources/markdown-tool/main.swift +++ b/Sources/markdown-tool/MarkdownCommand.swift @@ -12,6 +12,7 @@ import ArgumentParser import Foundation import Markdown +@main struct MarkdownCommand: ParsableCommand { enum Error: LocalizedError { case couldntDecodeInputAsUTF8 @@ -50,5 +51,3 @@ struct MarkdownCommand: ParsableCommand { return (stdinString, Document(parsing: stdinString, options: options)) } } - -MarkdownCommand.main()