Skip to content

Commit f41eab6

Browse files
committed
chore: update documentation generation workflow with improved link handling and baseurl configuration
- Modified the fix-schema-links.sh script to use relative paths for better link management in markdown files. - Enhanced the test-docs-generation.yml workflow to ensure proper execution of documentation processing scripts and improved handling of unconverted markdown files. - Added verification for the Jekyll baseurl configuration, ensuring it is set correctly for the documentation site.
1 parent 21a34c2 commit f41eab6

File tree

2 files changed

+62
-19
lines changed

2 files changed

+62
-19
lines changed

.github/scripts/docs/fix-schema-links.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
#!/bin/bash
22

3-
43
if sed --version 2>&1 | grep -q GNU; then
54
SED_INPLACE=(-i)
65
else
76
SED_INPLACE=(-i "")
87
fi
98

9+
# Use relative path from script directory
10+
BASE_DIR="../../../site-src"
11+
cd $(dirname "$0")
12+
echo "Working from $(pwd)"
13+
1014
echo "🔍 Starting comprehensive schema link fixing process..."
1115

1216
# 1. Process all files recursively, with special handling for schema files
13-
find . -type f -name "*.md" | while read file; do
17+
find "$BASE_DIR" -type f -name "*.md" | while read file; do
1418
if [[ "$file" == *"/schemas/"* ]]; then
1519
echo -n "."
1620
else
1721
echo "Processing: $file"
1822
fi
1923

2024
# === Fix all .md links to match Jekyll's pretty permalinks ===
21-
sed "${SED_INPLACE[@]}" -E 's/\(([^)]+)\.md(#[^)]+)?\)/(\1\2)/g' "$file"
22-
sed "${SED_INPLACE[@]}" -E 's/\(([^)]+)\.md\)/(\1)/g' "$file"
25+
sed "${SED_INPLACE[@]}" -E 's|\[([^]]+)\]\(([^)]+)\.md(#[^)]+)?\)|\[\1\]\(/forms-engine-plugin/\2\3\)|g' "$file"
26+
sed "${SED_INPLACE[@]}" -E 's|\[([^]]+)\]\(([^)]+)\.md\)|\[\1\]\(/forms-engine-plugin/\2\)|g' "$file"
2327

2428
# === Specific handling for schema files ===
2529
if [[ "$file" == *"/schemas/"* ]]; then

.github/workflows/test-docs-generation.yml

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ jobs:
7777
- name: Process schema documentation and prepare for Jekyll
7878
run: |
7979
echo "🔄 Processing documentation files..."
80-
chmod +x .github/scripts/docs/process-docs.sh
81-
.github/scripts/docs/process-docs.sh
80+
cd site-src
81+
chmod +x ../.github/scripts/docs/process-docs.sh
82+
../.github/scripts/docs/process-docs.sh
83+
cd ..
8284
8385
- name: Fix documentation links
8486
run: |
@@ -98,7 +100,7 @@ jobs:
98100
echo "🔨 Building Jekyll site..."
99101
cd site-src
100102
bundle install
101-
JEKYLL_ENV=production bundle exec jekyll build --verbose --destination ../_site
103+
JEKYLL_ENV=production bundle exec jekyll build --destination ../_site
102104
cd ..
103105
104106
# Fix capitalization issues
@@ -108,7 +110,7 @@ jobs:
108110
cp "_site/INDEX.html" "_site/index.html"
109111
fi
110112
111-
# Fix unconverted markdown files
113+
# Fix unconverted markdown files - with proper paths
112114
echo "🔧 Handling unconverted markdown files..."
113115
for md_file in $(find _site -name "*.md"); do
114116
html_file="${md_file%.md}.html"
@@ -117,17 +119,43 @@ jobs:
117119
118120
echo " Converting $md_file to HTML..."
119121
120-
# Create a minimal HTML version of the markdown file
121-
echo "<html><head><title>$base_name</title>" > "$html_file"
122-
echo "<meta http-equiv=\"refresh\" content=\"0; url='$base_name'\">" >> "$html_file"
123-
echo "</head><body>" >> "$html_file"
124-
echo "<h1>$base_name</h1>" >> "$html_file"
125-
echo "<p>This page should redirect automatically. If not, <a href=\"$base_name\">click here</a>.</p>" >> "$html_file"
126-
echo "</body></html>" >> "$html_file"
122+
# Create a minimal HTML version of the markdown file that uses the baseurl
123+
cat > "$html_file" << EOF
124+
<html>
125+
<head>
126+
<title>$base_name</title>
127+
<meta http-equiv="refresh" content="0; url='/forms-engine-plugin$dir_name/$base_name/'">
128+
</head>
129+
<body>
130+
<h1>$base_name</h1>
131+
<p>Redirecting to <a href="/forms-engine-plugin$dir_name/$base_name/">/forms-engine-plugin$dir_name/$base_name/</a></p>
132+
</body>
133+
</html>
134+
EOF
135+
136+
# Create directory and index.html for pretty URLs
137+
mkdir -p "_site$dir_name/$base_name"
138+
139+
# Create an index.html in the subdirectory with the actual content
140+
cat > "_site$dir_name/$base_name/index.html" << EOF
141+
<html>
142+
<head>
143+
<title>$base_name</title>
144+
<link rel="stylesheet" href="/forms-engine-plugin/assets/css/just-the-docs-default.css">
145+
</head>
146+
<body>
147+
<div class="main-content">
148+
<h1>$base_name</h1>
149+
<div class="content">
150+
$(cat "$md_file" | sed 's|](/|](/forms-engine-plugin/|g')
151+
</div>
152+
</div>
153+
</body>
154+
</html>
155+
EOF
127156
128-
# Create index.html in a directory with the same name for proper paths
129-
mkdir -p "$dir_name/$base_name"
130-
cp "$html_file" "$dir_name/$base_name/index.html"
157+
# Remove the original markdown file
158+
rm "$md_file"
131159
done
132160
133161
# Ensure lowercase 'index' directory exists for assets
@@ -185,4 +213,15 @@ jobs:
185213
id: deployment
186214
uses: actions/deploy-pages@v4
187215
with:
188-
timeout: 600000 # 10 minutes in milliseconds
216+
timeout: 600000 # 10 minutes in milliseconds
217+
218+
run: |
219+
echo "🔧 Verifying Jekyll baseurl configuration..."
220+
if ! grep -q "baseurl: \"/forms-engine-plugin\"" site-src/_config.yml; then
221+
sed -i.bak 's|baseurl: ""|baseurl: "/forms-engine-plugin"|g' site-src/_config.yml
222+
sed -i.bak 's|baseurl: "/"|baseurl: "/forms-engine-plugin"|g' site-src/_config.yml
223+
rm -f site-src/_config.yml.bak
224+
echo "✅ Updated baseurl in _config.yml"
225+
else
226+
echo "✅ baseurl already correctly configured"
227+
fi

0 commit comments

Comments
 (0)