Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 67 additions & 51 deletions .github/workflows/docc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,61 +51,77 @@ jobs:
- 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

# Debug: Show the structure of generated files
echo "=== Generated file structure ==="
find DocsBuild -type f | head -20

# Debug: Show original index.html
echo "=== Original index.html (first 30 lines) ==="
head -30 DocsBuild/index.html || true

# Fix resource paths in HTML files
# DocC's --hosting-base-path doesn't add the base path to script/link tags in HTML
echo "=== Fixing resource paths in HTML files ==="
find DocsBuild -type f -name "*.html" | while read -r file; do
# Fix script src attributes
sed -i '' 's|src="/js/|src="/'$DOCC_HOSTING_BASE_PATH'/js/|g' "$file"
sed -i '' 's|src="/css/|src="/'$DOCC_HOSTING_BASE_PATH'/css/|g' "$file"
sed -i '' 's|src="/images/|src="/'$DOCC_HOSTING_BASE_PATH'/images/|g' "$file"

# Fix link href attributes
sed -i '' 's|href="/js/|href="/'$DOCC_HOSTING_BASE_PATH'/js/|g' "$file"
sed -i '' 's|href="/css/|href="/'$DOCC_HOSTING_BASE_PATH'/css/|g' "$file"
sed -i '' 's|href="/images/|href="/'$DOCC_HOSTING_BASE_PATH'/images/|g' "$file"

# Fix favicon paths
sed -i '' 's|href="/favicon.ico"|href="/'$DOCC_HOSTING_BASE_PATH'/favicon.ico"|g' "$file"
sed -i '' 's|href="/favicon.svg"|href="/'$DOCC_HOSTING_BASE_PATH'/favicon.svg"|g' "$file"
done

# Fix data and documentation paths in JavaScript files
# JavaScript code has hardcoded absolute paths that need the base path prefix
echo "=== Fixing paths in JavaScript files ==="
find DocsBuild -type f -name "*.js" | while read -r file; do
# Fix data directory paths
sed -i '' 's|"/data/|"/'$DOCC_HOSTING_BASE_PATH'/data/|g' "$file"
sed -i '' "s|'/data/|'/$DOCC_HOSTING_BASE_PATH/data/|g" "$file"

# Fix documentation paths
sed -i '' 's|"/documentation/|"/'$DOCC_HOSTING_BASE_PATH'/documentation/|g' "$file"
sed -i '' "s|'/documentation/|'/$DOCC_HOSTING_BASE_PATH/documentation/|g" "$file"

# Fix tutorials paths
sed -i '' 's|"/tutorials/|"/'$DOCC_HOSTING_BASE_PATH'/tutorials/|g' "$file"
sed -i '' "s|'/tutorials/|'/$DOCC_HOSTING_BASE_PATH/tutorials/|g" "$file"
done

# Debug: Show fixed index.html
echo "=== Fixed index.html ==="
cat DocsBuild/index.html || true

echo ""
echo "=== Checking for NavigationSplitView in JS files ==="
grep -o "NavigationSplitView" DocsBuild/js/*.js | head -5 || echo "Not found"
echo "=== Documentation processed for static hosting ==="
echo "Hosting base path: $DOCC_HOSTING_BASE_PATH"

- name: Add .nojekyll and root redirect
run: |
# Add .nojekyll to prevent GitHub Pages from ignoring files starting with _
touch DocsBuild/.nojekyll

# Create redirect from root to documentation page
# The actual documentation lives at /documentation/<bundle-id>/
cat > DocsBuild/index.html << 'EOF'
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Redirecting to NavigationSplitView Documentation</title>
<meta http-equiv="refresh" content="0; url=./documentation/navigationsplitview/">
<link rel="canonical" href="./documentation/navigationsplitview/">
Comment on lines 51 to +77

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Removing path rewrite leaves DocC assets pointing to site root

The new workflow assumes that setting DOCC_HOSTING_BASE_PATH in the Xcode project makes DocC emit asset URLs that include the repository path, so the sed-based post‑processing was deleted. However, the build still invokes xcrun docc convert directly rather than xcodebuild, so the project build setting is never read and DocC continues to output absolute /js, /css, /data, /documentation, and /tutorials URLs. When the site is published under /NavigationSplitView on GitHub Pages those URLs 404, leaving the documentation without styles or scripts. The removed rewriting step was the only thing adjusting those paths. Consider keeping the rewrite or switching to an invocation that actually applies the Xcode build setting.

Useful? React with 👍 / 👎.

<style>
body {
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
margin: 0;
background: #f5f5f7;
}
.container {
text-align: center;
padding: 2rem;
}
h1 {
font-size: 2rem;
font-weight: 600;
margin-bottom: 1rem;
color: #1d1d1f;
}
p {
font-size: 1.125rem;
color: #86868b;
}
a {
color: #0071e3;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h1>NavigationSplitView Documentation</h1>
<p>Redirecting to <a href="./documentation/navigationsplitview/">documentation</a>...</p>
</div>
<script>
window.location.href = "./documentation/navigationsplitview/";
</script>
</body>
</html>
EOF

echo "=== Created root redirect ==="
cat DocsBuild/index.html

- name: Upload documentation artifact
if: github.event_name == 'push'
Expand Down
2 changes: 2 additions & 0 deletions XcodeProject/NewNav.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = P8T2366K8X;
DOCC_HOSTING_BASE_PATH = NavigationSplitView;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
Expand Down Expand Up @@ -218,6 +219,7 @@
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = P8T2366K8X;
DOCC_HOSTING_BASE_PATH = NavigationSplitView;
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_USER_SCRIPT_SANDBOXING = YES;
Expand Down