-
Notifications
You must be signed in to change notification settings - Fork 0
189 lines (159 loc) · 6.94 KB
/
docc.yml
File metadata and controls
189 lines (159 loc) · 6.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
name: DocC Documentation
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: docc-pages
cancel-in-progress: true
env:
DOCC_HOSTING_BASE_PATH: NavigationSplitView
jobs:
build:
name: Build DocC archive
runs-on: macos-15
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Select Xcode 16.1
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: "16.1"
- name: Show Xcode version
run: xcodebuild -version
- name: Build documentation archive
run: |
set -eo pipefail
# Clean up any previous build artifacts
rm -rf DerivedData DocsArchive DocsBuild
# Use xcodebuild docbuild to build full documentation including API
# This will create both /documentation/ (API) and /tutorials/ sections
# DOCC_HOSTING_BASE_PATH is set in Xcode project, but we can override via environment
xcodebuild docbuild \
-project XcodeProject/NewNav.xcodeproj \
-scheme NewNav \
-derivedDataPath ./DerivedData \
-destination 'generic/platform=iOS Simulator' \
CODE_SIGN_IDENTITY="" \
CODE_SIGNING_REQUIRED=NO \
CODE_SIGNING_ALLOWED=NO \
DOCC_HOSTING_BASE_PATH="$DOCC_HOSTING_BASE_PATH"
# Find the generated .doccarchive
DOCCARCHIVE=$(find DerivedData -name "*.doccarchive" | head -1)
echo "Found doccarchive at: $DOCCARCHIVE"
# Copy to expected location
mkdir -p DocsArchive
cp -R "$DOCCARCHIVE" DocsArchive/NavigationSplitView.doccarchive
- name: Prepare static documentation output
run: |
set -eo pipefail
# The DOCC_HOSTING_BASE_PATH is now set in Xcode project settings
# so DocC will generate the correct paths automatically
xcrun docc process-archive transform-for-static-hosting DocsArchive/NavigationSplitView.doccarchive \
--hosting-base-path "$DOCC_HOSTING_BASE_PATH" \
--output-path DocsBuild
echo "=== Documentation processed for static hosting ==="
echo "Hosting base path: $DOCC_HOSTING_BASE_PATH"
echo ""
echo "=== Directory structure ==="
find DocsBuild -type d | sort
echo ""
echo "=== Files in documentation directory ==="
find DocsBuild/documentation -type f 2>/dev/null | head -20 || echo "No documentation directory found"
echo ""
echo "=== Files in tutorials directory ==="
find DocsBuild/tutorials -type f 2>/dev/null | head -20 || echo "No tutorials directory found"
echo ""
echo "=== Root level files ==="
ls -la DocsBuild/
echo ""
echo "=== Index directory contents ==="
ls -la DocsBuild/index/ 2>/dev/null || echo "No index directory"
echo ""
echo "=== Data directory structure ==="
find DocsBuild/data -type f 2>/dev/null | head -10 || echo "No data directory"
echo ""
echo "=== metadata.json content ==="
cat DocsBuild/metadata.json 2>/dev/null || echo "No metadata.json"
echo ""
echo "=== Original index.html content ==="
cat DocsBuild/index.html
- name: Fix resource paths and add .nojekyll
run: |
# Add .nojekyll to prevent GitHub Pages from ignoring files starting with _
touch DocsBuild/.nojekyll
# Fix resource paths in HTML files
# Even with DOCC_HOSTING_BASE_PATH in Xcode, DocC still generates absolute paths
echo "=== Fixing resource paths in HTML files ==="
find DocsBuild -type f -name "*.html" -exec sed -i '' \
-e 's|var baseUrl = "/"|var baseUrl = "/'$DOCC_HOSTING_BASE_PATH'/"|g' \
-e 's|src="/js/|src="/'$DOCC_HOSTING_BASE_PATH'/js/|g' \
-e 's|src="/css/|src="/'$DOCC_HOSTING_BASE_PATH'/css/|g' \
-e 's|href="/css/|href="/'$DOCC_HOSTING_BASE_PATH'/css/|g' \
-e 's|href="/js/|href="/'$DOCC_HOSTING_BASE_PATH'/js/|g' \
-e 's|href="/documentation/|href="/'$DOCC_HOSTING_BASE_PATH'/documentation/|g' \
-e 's|href="/tutorials/|href="/'$DOCC_HOSTING_BASE_PATH'/tutorials/|g' \
-e 's|href="/favicon.ico"|href="/'$DOCC_HOSTING_BASE_PATH'/favicon.ico"|g' \
-e 's|href="/favicon.svg"|href="/'$DOCC_HOSTING_BASE_PATH'/favicon.svg"|g' \
{} +
# Fix paths in JavaScript files
echo "=== Fixing paths in JavaScript files ==="
find DocsBuild -type f -name "*.js" -exec sed -i '' \
-e 's|"/data/|"/'$DOCC_HOSTING_BASE_PATH'/data/|g' \
-e 's|"/documentation/|"/'$DOCC_HOSTING_BASE_PATH'/documentation/|g' \
-e 's|"/tutorials/|"/'$DOCC_HOSTING_BASE_PATH'/tutorials/|g' \
-e 's|"/index/|"/'$DOCC_HOSTING_BASE_PATH'/index/|g' \
{} +
# Fix paths in JSON data files
echo "=== Fixing paths in JSON files ==="
find DocsBuild/data -type f -name "*.json" -exec sed -i '' \
-e 's|"/documentation/|"/'$DOCC_HOSTING_BASE_PATH'/documentation/|g' \
-e 's|"/tutorials/|"/'$DOCC_HOSTING_BASE_PATH'/tutorials/|g' \
-e 's|"/images/|"/'$DOCC_HOSTING_BASE_PATH'/images/|g' \
-e 's|"/videos/|"/'$DOCC_HOSTING_BASE_PATH'/videos/|g' \
-e 's|"/downloads/|"/'$DOCC_HOSTING_BASE_PATH'/downloads/|g' \
{} + 2>/dev/null || echo "No JSON files to fix"
echo "=== Fixed paths ==="
echo "Fixed index.html:"
head -5 DocsBuild/index.html
- name: Create root redirect
run: |
# Create redirect from root to documentation/newnav
cat > DocsBuild/index.html << 'EOF'
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Redirecting to NewNav Documentation</title>
<meta http-equiv="refresh" content="0; url=./documentation/newnav/">
<link rel="canonical" href="./documentation/newnav/">
</head>
<body>
<p>Redirecting to <a href="./documentation/newnav/">NewNav Documentation</a>...</p>
<script>window.location.href = "./documentation/newnav/";</script>
</body>
</html>
EOF
echo "Created redirect to documentation/newnav/"
- name: Upload documentation artifact
if: github.event_name == 'push'
uses: actions/upload-pages-artifact@v3
with:
path: DocsBuild
deploy:
name: Deploy documentation
needs: build
if: github.event_name == 'push'
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4