|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Fix auto-generated documentation titles and navigation |
| 4 | +# Replace "Table of Contents" with the actual module name |
| 5 | +# Improve header hierarchy for better navigation |
| 6 | + |
| 7 | +echo "Fixing documentation titles and navigation..." |
| 8 | + |
| 9 | +for file in $(find docs/components -name "*.md" -exec grep -l "# Table of Contents" {} \;); do |
| 10 | + # Extract the module name from the first TOC entry |
| 11 | + module_name=$(grep -m 1 "^\* \[.*\]" "$file" | sed 's/^\* \[\(.*\)\](#.*)/\1/' | sed 's/\\_/_/g') |
| 12 | + if [ ! -z "$module_name" ]; then |
| 13 | + echo "Processing $file -> $module_name" |
| 14 | + |
| 15 | + # Replace "Table of Contents" with module name |
| 16 | + sed -i "1s/# Table of Contents/# $module_name/" "$file" |
| 17 | + |
| 18 | + # Promote method headers from H4 (####) to H3 (###) for better navigation |
| 19 | + # This makes methods appear in the right-hand navigation menu |
| 20 | + # Handle both regular and escaped method names |
| 21 | + sed -i 's/^#### \([a-zA-Z_\\][a-zA-Z0-9_\\]*\)(/### \1(/g' "$file" |
| 22 | + |
| 23 | + # Also promote method headers that don't have parameters (like properties) |
| 24 | + sed -i 's/^#### \([a-zA-Z_\\][a-zA-Z0-9_\\]*\)$/### \1/g' "$file" |
| 25 | + |
| 26 | + # Clean up method headers to show only method name (without parameters) in navigation |
| 27 | + # This keeps the full signature in the content but shows clean names in the TOC |
| 28 | + sed -i 's/^### \([a-zA-Z_\\][a-zA-Z0-9_\\]*\)(.*/### \1/g' "$file" |
| 29 | + |
| 30 | + # Also clean up the table of contents to show clean method names |
| 31 | + sed -i 's/\* \[\([a-zA-Z_\\][a-zA-Z0-9_\\]*\)([^)]*)/ * [\1/g' "$file" |
| 32 | + |
| 33 | + # Promote standalone functions (those at module level, not class methods) to H2 |
| 34 | + # Identify standalone functions from TOC: they appear as " * [function_name]" (module level) |
| 35 | + # vs class methods which appear as " * [method_name]" (indented further) |
| 36 | + # Promote standalone functions (those at module level, not class methods) to H2 |
| 37 | + # This creates a clearer navigation hierarchy where standalone functions |
| 38 | + # are separate from class methods |
| 39 | + |
| 40 | + # For al_general.md, promote common standalone functions |
| 41 | + if [[ "$file" == *"al_general.md" ]]; then |
| 42 | + sed -i 's/^### section\\_links$/## section\\_links/g' "$file" |
| 43 | + sed -i 's/^### will\\_send\\_to\\_real\\_court$/## will\\_send\\_to\\_real\\_court/g' "$file" |
| 44 | + sed -i 's/^### filter\\_letters$/## filter\\_letters/g' "$file" |
| 45 | + sed -i 's/^### fa\\_icon$/## fa\\_icon/g' "$file" |
| 46 | + sed -i 's/^### is\\_sms\\_enabled$/## is\\_sms\\_enabled/g' "$file" |
| 47 | + sed -i 's/^### is\\_phone\\_or\\_email$/## is\\_phone\\_or\\_email/g' "$file" |
| 48 | + sed -i 's/^### github\\_modified\\_date$/## github\\_modified\\_date/g' "$file" |
| 49 | + sed -i 's/^### language\\_name$/## language\\_name/g' "$file" |
| 50 | + sed -i 's/^### safe\\_states\\_list$/## safe\\_states\\_list/g' "$file" |
| 51 | + sed -i 's/^### has\\_parsable\\_pronouns$/## has\\_parsable\\_pronouns/g' "$file" |
| 52 | + sed -i 's/^### parse\\_custom\\_pronouns$/## parse\\_custom\\_pronouns/g' "$file" |
| 53 | + sed -i 's/^### get\\_visible\\_al\\_nav\\_items$/## get\\_visible\\_al\\_nav\\_items/g' "$file" |
| 54 | + fi |
| 55 | + |
| 56 | + # Convert **Arguments**: and **Returns**: to proper H4 headings for better navigation |
| 57 | + sed -i 's/^\*\*Arguments\*\*:/#### Arguments/g' "$file" |
| 58 | + sed -i 's/^\*\*Returns\*\*:/#### Returns/g' "$file" |
| 59 | + sed -i 's/^\*\*Attributes\*\*:/#### Attributes/g' "$file" |
| 60 | + sed -i 's/^\*\*Notes\*\*:/#### Notes/g' "$file" |
| 61 | + sed -i 's/^\*\*Raises\*\*:/#### Raises/g' "$file" |
| 62 | + |
| 63 | + # Remove stray YAML frontmatter blocks that appear in the middle of files |
| 64 | + # These are artifacts from the old template processing |
| 65 | + sed -i '/^---$/,/^---$/d' "$file" |
| 66 | + fi |
| 67 | +done |
| 68 | + |
| 69 | +echo "Done fixing documentation titles and navigation." |
0 commit comments