Skip to content

Commit 59068ac

Browse files
authored
Github Pages and Wiki fixes (#125)
## Description <!-- Provide a clear and concise description of your changes --> ## Related Issue <!-- Link to the issue this PR addresses --> Fixes # ## Type of Change <!-- Check all that apply --> - [ ] Bug fix (non-breaking change that fixes an issue) - [ ] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to change) - [ ] Documentation update - [ ] Refactor (code change that neither fixes a bug nor adds a feature) ## Checklist <!-- Ensure all items are completed before requesting review --> - [ ] I have added tests that prove my fix is effective or my feature works - [ ] I have updated the documentation accordingly - [ ] I have updated the [CHANGELOG](../CHANGELOG.md) - [ ] My changes do not introduce breaking changes, or breaking changes are documented
1 parent 12b0026 commit 59068ac

30 files changed

+3454
-328
lines changed

β€Ž.githooks/pre-pushβ€Ž

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,43 @@ else
133133
echo 'PowerShell not found; skipping test lints.' >&2
134134
fi
135135

136+
# Wiki generation tests (validates sidebar format, link transformations)
137+
# This mirrors the validate-wiki-links.yml CI workflow
138+
WIKI_CHANGES=$(git diff --name-only @{upstream}..HEAD 2>/dev/null | grep -E '^(scripts/wiki/|scripts/tests/test-wiki-generation\.sh|\.github/workflows/deploy-wiki\.yml)' || true)
139+
if [ -z "$WIKI_CHANGES" ]; then
140+
# Also check staged/uncommitted wiki-related changes
141+
WIKI_CHANGES=$(git diff --name-only HEAD 2>/dev/null | grep -E '^(scripts/wiki/|scripts/tests/test-wiki-generation\.sh|\.github/workflows/deploy-wiki\.yml)' || true)
142+
fi
143+
144+
if [ -n "$WIKI_CHANGES" ]; then
145+
echo "Wiki-related files changed:"
146+
echo "$WIKI_CHANGES" | sed 's/^/ /'
147+
echo "Running wiki generation tests..."
148+
if ! bash scripts/tests/test-wiki-generation.sh; then
149+
echo ""
150+
echo "=== Wiki generation tests failed ==="
151+
echo "Fix the issues in scripts/wiki/*.py or scripts/tests/test-wiki-generation.sh"
152+
echo ""
153+
exit 1
154+
fi
155+
echo "βœ“ Wiki generation tests OK"
156+
157+
# Also run Python wiki tests if pytest is available
158+
if command -v python3 >/dev/null 2>&1 && python3 -c "import pytest" 2>/dev/null; then
159+
echo "Running Python wiki script tests..."
160+
if ! python3 -m pytest scripts/wiki/test_wiki_scripts.py -v; then
161+
echo ""
162+
echo "=== Python wiki tests failed ==="
163+
echo "Fix the issues in scripts/wiki/*.py"
164+
echo ""
165+
exit 1
166+
fi
167+
echo "βœ“ Python wiki tests OK"
168+
else
169+
echo "pytest not installed; skipping Python wiki tests. CI will run them." >&2
170+
fi
171+
fi
172+
136173
# actionlint check for GitHub Actions workflows (only if workflow files changed)
137174
# This mirrors the actionlint.yml CI workflow
138175
# Use @{upstream} to compare against the remote tracking branch

β€Ž.github/workflows/deploy-wiki.ymlβ€Ž

Lines changed: 21 additions & 250 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ jobs:
6969
path: main
7070
fetch-depth: 1
7171

72+
- name: Set up Python
73+
uses: actions/setup-python@v5
74+
with:
75+
python-version: "3.11"
76+
7277
- name: Clone wiki repository
7378
id: clone-wiki
7479
run: |
@@ -96,68 +101,20 @@ jobs:
96101
run: |
97102
set -euo pipefail
98103
99-
# Track statistics
100-
pages_created=0
101-
images_copied=0
102-
103-
# Clear existing wiki content (except .git and special wiki files we'll regenerate)
104+
# Clear existing wiki content (except .git)
104105
echo "Clearing existing wiki content..."
105106
find wiki -mindepth 1 -maxdepth 1 ! -name '.git' -exec rm -rf {} +
106107
107-
# Copy README as Home page
108-
echo "Creating Home.md from README.md..."
109-
cp main/README.md wiki/Home.md
110-
pages_created=$((pages_created + 1))
111-
112-
# Copy CHANGELOG
113-
echo "Creating CHANGELOG.md..."
114-
cp main/CHANGELOG.md wiki/CHANGELOG.md
115-
pages_created=$((pages_created + 1))
116-
117-
# Copy index.md if it exists and differs from README
118-
if [ -f "main/index.md" ]; then
119-
echo "Creating Index.md..."
120-
cp main/index.md wiki/Index.md
121-
pages_created=$((pages_created + 1))
122-
fi
123-
124-
# Process and copy docs with proper structure
125-
echo "Processing documentation files..."
126-
cd main/docs
127-
128-
# Create wiki pages from docs structure - use process substitution to avoid subshell
129-
# Note: Not using -print0/-d '' because wiki forbids filenames with spaces
130-
while IFS= read -r file; do
131-
# Remove leading ./
132-
file="${file#./}"
133-
134-
# Create wiki-friendly filename:
135-
# 1. Replace / with -
136-
# 2. Capitalize first letter of each segment
137-
wiki_name=$(echo "$file" | sed 's|/|-|g' | sed 's|\.md$||')
138-
139-
# Capitalize each segment after dash
140-
wiki_name=$(echo "$wiki_name" | awk -F'-' '{for(i=1;i<=NF;i++){$i=toupper(substr($i,1,1))substr($i,2)}}1' OFS='-')
141-
wiki_name="${wiki_name}.md"
142-
143-
# Copy file
144-
cp "$file" "../../wiki/$wiki_name"
145-
echo " πŸ“„ Created: $wiki_name (from $file)"
146-
pages_created=$((pages_created + 1))
147-
done < <(find . -name "*.md" -type f ! -name "*.meta" | sort)
148-
149-
# Copy images - handle nested image directories
150-
echo "Copying images..."
151-
if [ -d "images" ]; then
152-
while IFS= read -r img; do
153-
mkdir -p "../../wiki/$(dirname "$img")"
154-
cp "$img" "../../wiki/$img"
155-
echo " πŸ–ΌοΈ Copied: $img"
156-
images_copied=$((images_copied + 1))
157-
done < <(find images -type f ! -name "*.meta" 2>/dev/null || true)
158-
fi
108+
# Run Python script to prepare wiki content
109+
echo "Preparing wiki content with Python scripts..."
110+
python main/scripts/wiki/prepare_wiki.py \
111+
--source main \
112+
--dest wiki \
113+
--verbose
159114
160-
cd ../..
115+
# Report statistics
116+
pages_created=$(find wiki -name "*.md" -type f | wc -l)
117+
images_copied=$(find wiki -type f ! -name "*.md" ! -path "wiki/.git/*" 2>/dev/null | wc -l || echo "0")
161118
162119
echo "pages_created=$pages_created" >> "$GITHUB_OUTPUT"
163120
echo "images_copied=$images_copied" >> "$GITHUB_OUTPUT"
@@ -166,210 +123,24 @@ jobs:
166123
echo " Pages: $pages_created"
167124
echo " Images: $images_copied"
168125
169-
- name: Fix wiki links
170-
run: |
171-
set -euo pipefail
172-
cd wiki
173-
174-
echo "Fixing wiki links..."
175-
links_fixed=0
176-
177-
for file in *.md; do
178-
if [ -f "$file" ]; then
179-
original_hash=$(md5sum "$file" | cut -d' ' -f1)
180-
181-
# Fix relative doc links - convert paths to wiki page references
182-
# Handle ../path/to/file.md and ./path/to/file.md patterns
183-
sed -i -E 's|\(\.\.?/([^)]+)\.md\)|(\1)|g' "$file"
184-
185-
# Convert path separators to dashes and capitalize for wiki links
186-
# This handles links like (features/inspector/overview) β†’ (Features-Inspector-Overview)
187-
sed -i -E 's|\(([a-z][^)]*)/([^)]*)\)|(\u\1-\u\2)|g' "$file"
188-
189-
# Fix image paths - normalize to images/ prefix
190-
sed -i 's|docs/images/|images/|g' "$file"
191-
sed -i 's|\.\./images/|images/|g' "$file"
192-
sed -i 's|\./images/|images/|g' "$file"
193-
194-
# Check if file was modified
195-
new_hash=$(md5sum "$file" | cut -d' ' -f1)
196-
if [ "$original_hash" != "$new_hash" ]; then
197-
echo " πŸ”— Fixed links in: $file"
198-
links_fixed=$((links_fixed + 1))
199-
fi
200-
fi
201-
done
202-
203-
echo "βœ… Link fixing complete ($links_fixed files updated)"
204-
205126
- name: Generate sidebar
206127
run: |
207128
set -euo pipefail
208-
cd wiki
209-
210-
echo "Generating _Sidebar.md dynamically from actual files..."
211-
212-
# Function to convert wiki filename to display name
213-
# e.g., "Features-Inspector-Inspector-Overview" -> "Inspector Overview"
214-
# e.g., "Features-Inspector-Utility-Components" -> "Utility Components"
215-
# e.g., "Overview-Getting-Started" -> "Getting Started"
216-
get_display_name() {
217-
local wiki_name="$1"
218-
local display="$wiki_name"
219-
220-
# Remove top-level category prefix (Features, Overview, Performance, Guides, Project)
221-
# Using sed for extended regex alternation which can't be done with bash substitution
222-
# shellcheck disable=SC2001
223-
display=$(echo "$display" | sed -E 's/^(Features|Overview|Performance|Guides|Project)-//')
224-
225-
# Remove subcategory prefix only if it matches known subcategories
226-
# This preserves context for files like "Utilities-Data-Structures" -> "Data Structures"
227-
# shellcheck disable=SC2001
228-
display=$(echo "$display" | sed -E 's/^(Inspector|Effects|Relational-Components|Serialization|Spatial|Logging|Utilities|Editor-Tools)-//')
229-
230-
# Convert remaining dashes to spaces
231-
display="${display//-/ }"
232-
echo "$display"
233-
}
234-
235-
# Start building the sidebar
236-
# NOTE: Use standard Markdown link syntax [Display](Page) instead of MediaWiki
237-
# wikilink syntax [[Page|Display]]. GitHub Wiki renders Markdown pages,
238-
# and MediaWiki wikilinks don't render correctly in Markdown context.
239-
{
240-
echo "## πŸ“š Documentation"
241-
echo ""
242-
echo "### Getting Started"
243-
echo "- [Home](Home)"
244129
245-
# Overview section
246-
for file in Overview-*.md; do
247-
[ -f "$file" ] || continue
248-
wiki_name="${file%.md}"
249-
display=$(get_display_name "$wiki_name")
250-
echo "- [$display]($wiki_name)"
251-
done
252-
253-
echo ""
254-
echo "### Inspector Features"
255-
for file in Features-Inspector-*.md; do
256-
[ -f "$file" ] || continue
257-
wiki_name="${file%.md}"
258-
display=$(get_display_name "$wiki_name")
259-
echo "- [$display]($wiki_name)"
260-
done
261-
262-
echo ""
263-
echo "### Effects System"
264-
for file in Features-Effects-*.md; do
265-
[ -f "$file" ] || continue
266-
wiki_name="${file%.md}"
267-
display=$(get_display_name "$wiki_name")
268-
echo "- [$display]($wiki_name)"
269-
done
270-
271-
echo ""
272-
echo "### Relational Components"
273-
for file in Features-Relational-Components-*.md; do
274-
[ -f "$file" ] || continue
275-
wiki_name="${file%.md}"
276-
display=$(get_display_name "$wiki_name")
277-
echo "- [$display]($wiki_name)"
278-
done
279-
280-
echo ""
281-
echo "### Serialization"
282-
for file in Features-Serialization-*.md; do
283-
[ -f "$file" ] || continue
284-
wiki_name="${file%.md}"
285-
display=$(get_display_name "$wiki_name")
286-
echo "- [$display]($wiki_name)"
287-
done
288-
289-
echo ""
290-
echo "### Spatial Trees"
291-
for file in Features-Spatial-*.md; do
292-
[ -f "$file" ] || continue
293-
wiki_name="${file%.md}"
294-
display=$(get_display_name "$wiki_name")
295-
echo "- [$display]($wiki_name)"
296-
done
297-
298-
echo ""
299-
echo "### Logging"
300-
for file in Features-Logging-*.md; do
301-
[ -f "$file" ] || continue
302-
wiki_name="${file%.md}"
303-
display=$(get_display_name "$wiki_name")
304-
echo "- [$display]($wiki_name)"
305-
done
306-
307-
echo ""
308-
echo "### Utilities"
309-
for file in Features-Utilities-*.md; do
310-
[ -f "$file" ] || continue
311-
wiki_name="${file%.md}"
312-
display=$(get_display_name "$wiki_name")
313-
echo "- [$display]($wiki_name)"
314-
done
315-
316-
echo ""
317-
echo "### Editor Tools"
318-
for file in Features-Editor-Tools-*.md; do
319-
[ -f "$file" ] || continue
320-
wiki_name="${file%.md}"
321-
display=$(get_display_name "$wiki_name")
322-
echo "- [$display]($wiki_name)"
323-
done
324-
325-
echo ""
326-
echo "### Guides"
327-
for file in Guides-*.md; do
328-
[ -f "$file" ] || continue
329-
wiki_name="${file%.md}"
330-
display=$(get_display_name "$wiki_name")
331-
echo "- [$display]($wiki_name)"
332-
done
333-
334-
echo ""
335-
echo "### Performance"
336-
for file in Performance-*.md; do
337-
[ -f "$file" ] || continue
338-
wiki_name="${file%.md}"
339-
display=$(get_display_name "$wiki_name")
340-
echo "- [$display]($wiki_name)"
341-
done
342-
343-
echo ""
344-
echo "### Project"
345-
echo "- [Changelog](CHANGELOG)"
346-
for file in Project-*.md; do
347-
[ -f "$file" ] || continue
348-
wiki_name="${file%.md}"
349-
display=$(get_display_name "$wiki_name")
350-
echo "- [$display]($wiki_name)"
351-
done
352-
} > _Sidebar.md
130+
echo "Generating _Sidebar.md with Python script..."
131+
python main/scripts/wiki/generate_wiki_sidebar.py wiki --output wiki/_Sidebar.md
353132
354133
echo "Generated sidebar content:"
355-
cat _Sidebar.md
134+
cat wiki/_Sidebar.md
356135
echo ""
357-
echo "βœ… Sidebar generated dynamically"
136+
echo "βœ… Sidebar generated"
358137
359138
- name: Generate footer
360139
run: |
361140
set -euo pipefail
362-
cd wiki
363-
364-
echo "Generating _Footer.md..."
365141
366-
cat > _Footer.md << 'FOOTER_EOF'
367-
---
368-
πŸ“¦ [Unity Helpers](https://github.com/wallstop/unity-helpers) |
369-
πŸ“– [Documentation](https://wallstop.github.io/unity-helpers/) |
370-
πŸ› [Issues](https://github.com/wallstop/unity-helpers/issues) |
371-
πŸ“œ [MIT License](https://github.com/wallstop/unity-helpers/blob/main/LICENSE)
372-
FOOTER_EOF
142+
echo "Generating _Footer.md with Python script..."
143+
python main/scripts/wiki/generate_wiki_footer.py --output wiki/_Footer.md
373144
374145
echo "βœ… Footer generated"
375146

β€Ž.github/workflows/validate-docs.ymlβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,3 +274,15 @@ jobs:
274274
echo "❌ Jekyll build did not produce _site directory"
275275
exit 1
276276
fi
277+
278+
validate-css-layout:
279+
name: Validate CSS Layout
280+
runs-on: ubuntu-latest
281+
steps:
282+
- name: Checkout repository
283+
uses: actions/checkout@v4
284+
285+
- name: Validate GitHub Pages CSS
286+
run: |
287+
chmod +x ./scripts/validate-github-pages-css.sh
288+
./scripts/validate-github-pages-css.sh

0 commit comments

Comments
Β (0)