2
2
#
3
3
# This source file is part of the Swift.org open source project
4
4
#
5
- # Copyright (c) 2022 Apple Inc. and the Swift project authors
5
+ # Copyright (c) 2022-2024 Apple Inc. and the Swift project authors
6
6
# Licensed under Apache License v2.0 with Runtime Library Exception
7
7
#
8
8
# See https://swift.org/LICENSE.txt for license information
9
9
# See https://swift.org/CONTRIBUTORS.txt for Swift project authors
10
10
#
11
- # Updates the GitHub Pages documentation site thats published from the 'docs'
11
+ # Updates the GitHub Pages documentation site thats published from the 'docs'
12
12
# subdirectory in the 'gh-pages' branch of this repository.
13
13
#
14
14
# This script should be run by someone with commit access to the 'gh-pages' branch
@@ -26,7 +26,8 @@ filepath() {
26
26
SWIFT_DOCC_ROOT=" $( dirname $( dirname $( filepath $0 ) ) ) "
27
27
28
28
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
30
31
31
32
mkdir -p " $DOCC_UTILITIES_OUTPUT_DIR "
32
33
@@ -42,14 +43,19 @@ export DOCC_JSON_PRETTYPRINT="YES"
42
43
43
44
# Generate documentation for the 'SwiftDocC' target and output it
44
45
# 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
+
45
49
swift package \
46
- --allow-writing-to-directory " $SWIFT_DOCC_ROOT /gh-pages/docs " \
50
+ --allow-writing-to-directory " $SWIFT_DOCC_ROOT " \
47
51
generate-documentation \
48
52
--target SwiftDocC \
49
53
--disable-indexing \
50
54
--transform-for-static-hosting \
51
55
--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"
53
59
54
60
# Generate documentation for the 'SwiftDocCUtilities' target and output it
55
61
# to a temporary output directory in the .build directory.
@@ -62,8 +68,13 @@ swift package \
62
68
--hosting-base-path swift-docc \
63
69
--output-path " $DOCC_UTILITIES_OUTPUT_DIR "
64
70
71
+ echo -e " \033[34;1m Merging docs \033q[0m"
72
+
65
73
# 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"
67
78
68
79
# Save the current commit we've just built documentation from in a variable
69
80
CURRENT_COMMIT_HASH=` git rev-parse --short HEAD`
@@ -73,7 +84,7 @@ cd gh-pages
73
84
git add docs
74
85
75
86
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."
77
88
git commit -m " Update GitHub Pages documentation site to $CURRENT_COMMIT_HASH "
78
89
git push origin HEAD:gh-pages
79
90
else
0 commit comments