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
0 commit comments