mirror of
https://github.com/apple/swift-async-algorithms
synced 2026-11-27 04:44:21 +00:00
Add support for the Swift package index (#297)
# Motivation We had some scripts around to generate docs for this package but all of our other packages are now providing documentation on the Swift package index. # Modification This removes the old script to generate documentation and adds an `.spi.yml` file. Furthermore, I removed the conditional dependency on the docc plugin which we are unconditionally depending on in most of our other packages like NIO.
This commit is contained in:
1 parent
f56556930f
commit
260e198221
4 files changed
+12
-103
No files matched your search
@@ -0,0 +1,4 @@
|
||||
version: 1
|
||||
builder:
|
||||
configs:
|
||||
- documentation_targets: [AsyncAlgorithms]
|
||||
+4
-16
@@ -13,7 +13,10 @@ let package = Package(
|
||||
products: [
|
||||
.library(name: "AsyncAlgorithms", targets: ["AsyncAlgorithms"]),
|
||||
],
|
||||
dependencies: [.package(url: "https://github.com/apple/swift-collections.git", .upToNextMajor(from: "1.0.4"))],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.4"),
|
||||
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "AsyncAlgorithms",
|
||||
@@ -46,18 +49,3 @@ let package = Package(
|
||||
),
|
||||
]
|
||||
)
|
||||
|
||||
#if canImport(Darwin)
|
||||
import Darwin
|
||||
let buildingDocs = getenv("BUILDING_FOR_DOCUMENTATION_GENERATION") != nil
|
||||
#elseif canImport(Glibc)
|
||||
import Glibc
|
||||
let buildingDocs = getenv("BUILDING_FOR_DOCUMENTATION_GENERATION") != nil
|
||||
#else
|
||||
let buildingDocs = false
|
||||
#endif
|
||||
|
||||
// Only require the docc plugin when building documentation
|
||||
package.dependencies += buildingDocs ? [
|
||||
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
|
||||
] : []
|
||||
+4
-16
@@ -16,7 +16,10 @@ let package = Package(
|
||||
.library(name: "_CAsyncSequenceValidationSupport", type: .static, targets: ["AsyncSequenceValidation"]),
|
||||
.library(name: "AsyncAlgorithms_XCTest", targets: ["AsyncAlgorithms_XCTest"]),
|
||||
],
|
||||
dependencies: [.package(url: "https://github.com/apple/swift-collections.git", .upToNextMajor(from: "1.0.4"))],
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/apple/swift-collections.git", from: "1.0.4"),
|
||||
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
|
||||
],
|
||||
targets: [
|
||||
.target(
|
||||
name: "AsyncAlgorithms",
|
||||
@@ -34,18 +37,3 @@ let package = Package(
|
||||
dependencies: ["AsyncAlgorithms", "AsyncSequenceValidation", "AsyncAlgorithms_XCTest"]),
|
||||
]
|
||||
)
|
||||
|
||||
#if canImport(Darwin)
|
||||
import Darwin
|
||||
let buildingDocs = getenv("BUILDING_FOR_DOCUMENTATION_GENERATION") != nil
|
||||
#elseif canImport(Glibc)
|
||||
import Glibc
|
||||
let buildingDocs = getenv("BUILDING_FOR_DOCUMENTATION_GENERATION") != nil
|
||||
#else
|
||||
let buildingDocs = false
|
||||
#endif
|
||||
|
||||
// Only require the docc plugin when building documentation
|
||||
package.dependencies += buildingDocs ? [
|
||||
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.0.0"),
|
||||
] : []
|
||||
@@ -1,71 +0,0 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
# This source file is part of the Swift.org open source project
|
||||
#
|
||||
# Copyright (c) 2022 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
|
||||
#
|
||||
# Updates the GitHub Pages documentation site thats published from the 'docs'
|
||||
# subdirectory in the 'gh-pages' branch of this repository.
|
||||
#
|
||||
# This script should be run by someone with commit access to the 'gh-pages' branch
|
||||
# at a regular frequency so that the documentation content on the GitHub Pages site
|
||||
# is up-to-date with the content in this repo.
|
||||
#
|
||||
|
||||
export BUILDING_FOR_DOCUMENTATION_GENERATION=1
|
||||
|
||||
set -eu
|
||||
|
||||
# A `realpath` alternative using the default C implementation.
|
||||
filepath() {
|
||||
[[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
|
||||
}
|
||||
|
||||
SWIFT_ASYNC_ALGORITHMS_ROOT="$(dirname $(dirname $(filepath $0)))"
|
||||
|
||||
ASYNC_ALGORITHMS_BUILD_DIR="$SWIFT_ASYNC_ALGORITHMS_ROOT"/.build/async-algorithms-gh-pages-build
|
||||
|
||||
# Set current directory to the repository root
|
||||
cd "$SWIFT_ASYNC_ALGORITHMS_ROOT"
|
||||
|
||||
# Use git worktree to checkout the gh-pages branch of this repository in a gh-pages sub-directory
|
||||
git fetch
|
||||
git worktree add --checkout gh-pages origin/gh-pages
|
||||
|
||||
# Pretty print DocC JSON output so that it can be consistently diffed between commits
|
||||
export DOCC_JSON_PRETTYPRINT="YES"
|
||||
|
||||
# Generate documentation for the 'AsyncAlgorithms' target and output it
|
||||
# to the /docs subdirectory in the gh-pages worktree directory.
|
||||
swift package \
|
||||
--allow-writing-to-directory "$SWIFT_ASYNC_ALGORITHMS_ROOT/gh-pages/docs" \
|
||||
generate-documentation \
|
||||
--target AsyncAlgorithms \
|
||||
--disable-indexing \
|
||||
--transform-for-static-hosting \
|
||||
--hosting-base-path swift-async-algorithms \
|
||||
--output-path "$SWIFT_ASYNC_ALGORITHMS_ROOT/gh-pages/docs"
|
||||
|
||||
# Save the current commit we've just built documentation from in a variable
|
||||
CURRENT_COMMIT_HASH=`git rev-parse --short HEAD`
|
||||
|
||||
# Commit and push our changes to the gh-pages branch
|
||||
cd gh-pages
|
||||
git add docs
|
||||
|
||||
if [ -n "$(git status --porcelain)" ]; then
|
||||
echo "Documentation changes found. Commiting the changes to the 'gh-pages' branch and pushing to origin."
|
||||
git commit -m "Update GitHub Pages documentation site to $CURRENT_COMMIT_HASH"
|
||||
git push origin HEAD:gh-pages
|
||||
else
|
||||
# No changes found, nothing to commit.
|
||||
echo "No documentation changes found."
|
||||
fi
|
||||
|
||||
# Delete the git worktree we created
|
||||
cd ..
|
||||
git worktree remove gh-pages
|
||||
Reference in new issue
Block a user