Skip to content

Commit ae3146a

Browse files
committed
Publish docs for SwiftDocC and SwiftDocCUtilities as a combined archive
1 parent 8b1022f commit ae3146a

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

bin/update-gh-pages-documentation-site

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
#
33
# This source file is part of the Swift.org open source project
44
#
5-
# Copyright (c) 2022 Apple Inc. and the Swift project authors
5+
# Copyright (c) 2022-2024 Apple Inc. and the Swift project authors
66
# Licensed under Apache License v2.0 with Runtime Library Exception
77
#
88
# See https://swift.org/LICENSE.txt for license information
99
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
1010
#
11-
# Updates the GitHub Pages documentation site thats published from the 'docs'
11+
# Updates the GitHub Pages documentation site thats published from the 'docs'
1212
# subdirectory in the 'gh-pages' branch of this repository.
1313
#
1414
# This script should be run by someone with commit access to the 'gh-pages' branch
@@ -26,7 +26,8 @@ filepath() {
2626
SWIFT_DOCC_ROOT="$(dirname $(dirname $(filepath $0)))"
2727

2828
DOCC_BUILD_DIR="$SWIFT_DOCC_ROOT"/.build/docc-gh-pages-build
29-
DOCC_UTILITIES_OUTPUT_DIR="$DOCC_BUILD_DIR"/docc-utilities-docs
29+
DOCC_OUTPUT_DIR="$DOCC_BUILD_DIR"/SwiftDocC.doccarchive
30+
DOCC_UTILITIES_OUTPUT_DIR="$DOCC_BUILD_DIR"/SwiftDocCUtilities.doccarchive
3031

3132
mkdir -p "$DOCC_UTILITIES_OUTPUT_DIR"
3233

@@ -42,14 +43,19 @@ export DOCC_JSON_PRETTYPRINT="YES"
4243

4344
# Generate documentation for the 'SwiftDocC' target and output it
4445
# to the /docs subdirectory in the gh-pages worktree directory.
46+
47+
echo -e "\033[34;1m Building SwiftDocC docs at $DOCC_OUTPUT_DIR \033[0m"
48+
4549
swift package \
46-
--allow-writing-to-directory "$SWIFT_DOCC_ROOT/gh-pages/docs" \
50+
--allow-writing-to-directory "$SWIFT_DOCC_ROOT" \
4751
generate-documentation \
4852
--target SwiftDocC \
4953
--disable-indexing \
5054
--transform-for-static-hosting \
5155
--hosting-base-path swift-docc \
52-
--output-path "$SWIFT_DOCC_ROOT/gh-pages/docs"
56+
--output-path "$DOCC_OUTPUT_DIR"
57+
58+
echo -e "\033[34;1m Building SwiftDocC Utilities docs at $DOCC_UTILITIES_OUTPUT_DIR \033[0m"
5359

5460
# Generate documentation for the 'SwiftDocCUtilities' target and output it
5561
# to a temporary output directory in the .build directory.
@@ -62,8 +68,13 @@ swift package \
6268
--hosting-base-path swift-docc \
6369
--output-path "$DOCC_UTILITIES_OUTPUT_DIR"
6470

71+
echo -e "\033[34;1m Merging docs \033q[0m"
72+
6573
# Merge the SwiftDocCUtilities docs into the primary SwiftDocC docs
66-
cp -R "$DOCC_UTILITIES_OUTPUT_DIR"/* "$SWIFT_DOCC_ROOT/gh-pages/docs/"
74+
swift run docc merge \
75+
"$DOCC_OUTPUT_DIR" \
76+
"$DOCC_UTILITIES_OUTPUT_DIR" \
77+
--output-path "$SWIFT_DOCC_ROOT/gh-pages/docs"
6778

6879
# Save the current commit we've just built documentation from in a variable
6980
CURRENT_COMMIT_HASH=`git rev-parse --short HEAD`
@@ -73,7 +84,7 @@ cd gh-pages
7384
git add docs
7485

7586
if [ -n "$(git status --porcelain)" ]; then
76-
echo "Documentation changes found. Commiting the changes to the 'gh-pages' branch and pushing to origin."
87+
echo "Documentation changes found. Committing the changes to the 'gh-pages' branch and pushing to origin."
7788
git commit -m "Update GitHub Pages documentation site to $CURRENT_COMMIT_HASH"
7889
git push origin HEAD:gh-pages
7990
else

0 commit comments

Comments
 (0)