Skip to content

Commit e5e3e2d

Browse files
committed
Add orphan check, update testing page and rename bad filenames
1 parent 67914a6 commit e5e3e2d

File tree

3 files changed

+128
-0
lines changed

3 files changed

+128
-0
lines changed

TESTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,39 @@ This script searches all `.md` files for external links (http:// or https://) in
7676
> [!Important]
7777
> Pay attention to your use of external links and consider any complexities around linking to forks of this documentation repository. Wherever possible content should be local and forks can then modify content as required.
7878
79+
### Validating Internal Links
80+
81+
Before committing changes, verify that all internal markdown links are valid:
82+
83+
```bash
84+
# Check all internal .md links
85+
./check-internal-linkage.sh
86+
```
87+
88+
This script scans all `.md` files in `wiki-default/` and verifies that:
89+
- All internal markdown links point to existing files
90+
- Links include the `.md` extension
91+
- Relative and absolute paths are correct
92+
- No broken links exist
93+
94+
The script will report any broken links with the source file and expected target location. It exits with code 1 if broken links are found, making it suitable for CI/CD integration.
95+
96+
### Finding Orphaned Pages
97+
98+
To identify documentation pages that exist but aren't linked in the navigation sidebar:
99+
100+
```bash
101+
# Find pages not linked in Sidebar.md
102+
./check-orphans.sh
103+
```
104+
105+
This script helps maintain documentation organization by finding:
106+
- Pages that exist in `wiki-default/` but aren't in `Sidebar.md`
107+
- Content that may be inaccessible to users
108+
- Candidates for the `Orphans/` directory
109+
110+
The output shows which pages are orphaned so you can decide whether to add them to the sidebar or move them to an appropriate location.
111+
79112
### Important Notes
80113

81114
- The `mockup/` folder is in `.gitignore` - it will never be committed

check-orphans.sh

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
#!/bin/bash
2+
3+
# Script to find orphaned pages - .md files not linked in Sidebar.md
4+
# These pages exist but are not accessible through the main navigation
5+
6+
set -e
7+
8+
# Colors for output
9+
RED='\033[0;31m'
10+
GREEN='\033[0;32m'
11+
YELLOW='\033[1;33m'
12+
BLUE='\033[0;34m'
13+
NC='\033[0m' # No Color
14+
15+
SIDEBAR_FILE="wiki-default/Sidebar.md"
16+
17+
# Check if Sidebar.md exists
18+
if [[ ! -f "$SIDEBAR_FILE" ]]; then
19+
echo -e "${RED}Error: $SIDEBAR_FILE not found${NC}"
20+
exit 1
21+
fi
22+
23+
echo "Checking for orphaned pages in wiki-default/..."
24+
echo ""
25+
26+
# Extract all .md file links from Sidebar.md (normalize paths)
27+
linked_pages=()
28+
while IFS= read -r link; do
29+
# Skip empty lines
30+
[[ -z "$link" ]] && continue
31+
32+
# Remove leading/trailing whitespace
33+
link=$(echo "$link" | xargs)
34+
35+
# Normalize path - remove leading ./ and wiki-default/
36+
link="${link#./}"
37+
link="${link#wiki-default/}"
38+
39+
linked_pages+=("$link")
40+
done < <(perl -nle 'while (/\]\(([^)]+(?:\([^)]*\)[^)]*)*)\)/g) { print $1 }' "$SIDEBAR_FILE" 2>/dev/null | grep '\.md$')
41+
42+
# Find all .md files in wiki-default (excluding Sidebar.md, Footer.md, _* files)
43+
orphaned_pages=()
44+
total_pages=0
45+
46+
while IFS= read -r -d '' md_file; do
47+
# Get relative path from wiki-default/
48+
rel_path="${md_file#wiki-default/}"
49+
50+
# Skip special files
51+
if [[ "$rel_path" == "Sidebar.md" ]] || \
52+
[[ "$rel_path" == "Footer.md" ]] || \
53+
[[ "$rel_path" == _* ]] || \
54+
[[ "$rel_path" == */_* ]]; then
55+
continue
56+
fi
57+
58+
total_pages=$((total_pages + 1))
59+
60+
# Check if this page is linked in Sidebar
61+
found=false
62+
for linked in "${linked_pages[@]}"; do
63+
if [[ "$linked" == "$rel_path" ]]; then
64+
found=true
65+
break
66+
fi
67+
done
68+
69+
if [[ "$found" == false ]]; then
70+
orphaned_pages+=("$rel_path")
71+
fi
72+
done < <(find wiki-default -name "*.md" -type f -print0)
73+
74+
echo "===================="
75+
echo "Summary:"
76+
echo "===================="
77+
echo -e "Total pages (excluding special files): ${total_pages}"
78+
echo -e "Pages linked in Sidebar: ${#linked_pages[@]}"
79+
echo -e "Orphaned pages: ${#orphaned_pages[@]}"
80+
echo ""
81+
82+
if [[ ${#orphaned_pages[@]} -eq 0 ]]; then
83+
echo -e "${GREEN}✓ No orphaned pages found - all pages are linked in Sidebar.md${NC}"
84+
exit 0
85+
else
86+
echo -e "${YELLOW}⚠ Found ${#orphaned_pages[@]} orphaned page(s):${NC}"
87+
echo ""
88+
for page in "${orphaned_pages[@]}"; do
89+
echo -e " ${BLUE}${NC} $page"
90+
done
91+
echo ""
92+
echo -e "${YELLOW}Note: These pages exist but are not accessible through the sidebar navigation.${NC}"
93+
echo -e "${YELLOW}Consider adding them to Sidebar.md or moving them to the Orphans/ directory.${NC}"
94+
exit 0
95+
fi
File renamed without changes.

0 commit comments

Comments
 (0)