Skip to content

docs: add a documentation #13

docs: add a documentation

docs: add a documentation #13

Workflow file for this run

name: Deploy DocC Documentation
on:
push:
branches: ["main"]
pull_request:
branches: ["main"]
workflow_dispatch:
inputs:
version:
description: 'Documentation version'
required: false
default: latest'
permissions:
contents: write
concurrency:
group: "pages"
cancel-in-progress: true
jobs:
deploy:
runs-on: macos-14
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: latest-stable
- name: Get Version
id: version
run: |
if [ -n "${{ github.event.inputs.version }}" ]; then
VERSION="${{ github.event.inputs.version }}"
else
VERSION="latest"
fi
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Building documentation for version: $VERSION"
- name: Build DocC Documentation
run: |
set -o pipefail
set -e
CURRENT_VERSION="latest"
# 🔧 CONFIG
SCHEMES=(
"ValidatorCore"
"ValidatorUI"
)
BUILD="build"
DOCS_DIR="docs"
# 🔍 Detect repository context
REPO_NAME=$(basename "$GITHUB_REPOSITORY")
echo "📘 Building DocC for repository: $REPO_NAME"
echo "📘 Version: $CURRENT_VERSION"
# 🧼 Clean up
rm -rf $BUILD
rm -rf $DOCS_DIR
mkdir -p "$DOCS_DIR"
# 📘 Generate DocC for each scheme
echo "📘 Building DocC for schemes: ${SCHEMES[*]}"
for SCHEME in "${SCHEMES[@]}"; do
echo ""
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "📘 Building DocC for $SCHEME ..."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
DERIVED_DATA="$BUILD/$SCHEME"
xcodebuild docbuild \
-scheme "$SCHEME" \
-destination 'platform=macOS' \
-derivedDataPath "$DERIVED_DATA"
ARCHIVE_PATH=$(find "$DERIVED_DATA" -name "$SCHEME.doccarchive" -type d | head -n 1)
if [ -z "$ARCHIVE_PATH" ]; then
echo "❌ No doccarchive for $SCHEME"
echo "Searching in $DERIVED_DATA:"
find "$DERIVED_DATA" -name "*.doccarchive" -type d || echo "No archives found"
exit 1
fi
echo "✅ Found archive: $ARCHIVE_PATH"
OUTPUT_PATH="$DOCS_DIR/$CURRENT_VERSION/$SCHEME"
mkdir -p "$OUTPUT_PATH"
# 🔧 Set hosting base path
HOSTING_BASE_PATH="$REPO_NAME/$CURRENT_VERSION/$SCHEME"
echo "📘 Using hosting base path: $HOSTING_BASE_PATH"
$(xcrun --find docc) process-archive \
transform-for-static-hosting \
"$ARCHIVE_PATH" \
--output-path "$OUTPUT_PATH" \
--hosting-base-path "$HOSTING_BASE_PATH"
echo "✅ $SCHEME docs ready at $OUTPUT_PATH"
done
echo ""
echo "🎉 Documentation generated for $REPO_NAME version $CURRENT_VERSION"
- name: Create Index Page
run: |
CURRENT_VERSION="${{ steps.version.outputs.VERSION }}"
REPO_NAME=$(basename "$GITHUB_REPOSITORY")
cat > docs/index.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Validator Documentation</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
background: #f5f5f7;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
padding: 40px 20px;
color: #1d1d1f;
}
.container {
max-width: 980px;
width: 100%;
}
header {
text-align: center;
margin-bottom: 60px;
}
h1 {
font-size: 56px;
font-weight: 600;
letter-spacing: -0.005em;
line-height: 1.07143;
margin-bottom: 8px;
color: #1d1d1f;
}
.subtitle {
font-size: 28px;
font-weight: 400;
line-height: 1.14286;
color: #6e6e73;
}
.version-badge {
display: inline-block;
background: #0071e3;
color: white;
padding: 6px 14px;
border-radius: 16px;
font-size: 14px;
font-weight: 600;
margin-top: 12px;
}
.docs-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
gap: 24px;
margin-bottom: 40px;
}
.doc-card {
background: white;
border-radius: 18px;
padding: 40px;
box-shadow: 0 4px 12px rgba(0,0,0,0.08);
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
text-decoration: none;
display: block;
border: 1px solid rgba(0,0,0,0.06);
}
.doc-card:hover {
transform: translateY(-4px);
box-shadow: 0 12px 24px rgba(0,0,0,0.12);
}
.doc-card h2 {
font-size: 32px;
font-weight: 600;
margin-bottom: 12px;
color: #1d1d1f;
letter-spacing: -0.003em;
}
.doc-card p {
font-size: 17px;
line-height: 1.47059;
color: #6e6e73;
margin-bottom: 20px;
}
.doc-card .link {
font-size: 17px;
color: #0071e3;
font-weight: 400;
display: inline-flex;
align-items: center;
}
.doc-card .link::after {
content: '→';
margin-left: 8px;
transition: transform 0.3s ease;
}
.doc-card:hover .link::after {
transform: translateX(4px);
}
.module-badge {
display: inline-block;
background: #f5f5f7;
color: #6e6e73;
padding: 4px 12px;
border-radius: 12px;
font-size: 12px;
font-weight: 600;
letter-spacing: 0.5px;
text-transform: uppercase;
margin-bottom: 16px;
}
footer {
text-align: center;
padding-top: 40px;
border-top: 1px solid rgba(0,0,0,0.08);
margin-top: 40px;
}
footer p {
font-size: 14px;
color: #86868b;
}
@media (max-width: 768px) {
h1 {
font-size: 40px;
}
.subtitle {
font-size: 21px;
}
.docs-grid {
grid-template-columns: 1fr;
}
.doc-card {
padding: 32px;
}
}
</style>
</head>
<body>
<div class="container">
<header>
<h1>Validator</h1>
<p class="subtitle">Comprehensive documentation for Swift validation framework</p>
<span class="version-badge">VERSION_PLACEHOLDER</span>
</header>
<div class="docs-grid">
<a href="VERSION_PLACEHOLDER/ValidatorCore/documentation/validatorcore" class="doc-card">
<span class="module-badge">Core Module</span>
<h2>ValidatorCore</h2>
<p>Core validation functionality and rules for Swift applications. Contains base types, protocols, and validator implementations.</p>
<span class="link">View documentation</span>
</a>
<a href="VERSION_PLACEHOLDER/ValidatorUI/documentation/validatorui" class="doc-card">
<span class="module-badge">UI Module</span>
<h2>ValidatorUI</h2>
<p>UI components and helpers for building validation interfaces. Ready-to-use solutions for SwiftUI and UIKit.</p>
<span class="link">View documentation</span>
</a>
</div>
<footer>
<p>Generated with Swift DocC</p>
</footer>
</div>
</body>
</html>
EOF
# Replace VERSION_PLACEHOLDER with actual version
sed -i '' "s/VERSION_PLACEHOLDER/$CURRENT_VERSION/g" docs/index.html || \
sed -i "s/VERSION_PLACEHOLDER/$CURRENT_VERSION/g" docs/index.html
echo "✅ Index page created with version $CURRENT_VERSION"
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./docs
force_orphan: true