-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-docs.sh
More file actions
executable file
·195 lines (157 loc) · 6.2 KB
/
generate-docs.sh
File metadata and controls
executable file
·195 lines (157 loc) · 6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#!/bin/bash
# Generate Static Documentation Script
# This script creates a complete documentation website from OpenAPI specs
echo "🚀 Generating API Documentation Website..."
# Create output directory
mkdir -p docs-site
cd docs-site
echo "📥 Downloading Swagger UI..."
# Download and setup Swagger UI
curl -L https://github.com/swagger-api/swagger-ui/archive/master.zip -o swagger-ui.zip
unzip -q swagger-ui.zip
cp -r swagger-ui-master/dist/* .
rm -rf swagger-ui-master swagger-ui.zip
echo "📋 Copying API specifications..."
# Copy API specs
cp ../docs/tech-writer-reference/api-assets/openapi/customer-api.yaml .
# Update Swagger UI to use our API spec
sed -i.bak 's|https://petstore.swagger.io/v2/swagger.json|./customer-api.yaml|g' swagger-initializer.js
rm swagger-initializer.js.bak
echo "📚 Converting documentation to HTML..."
# Copy markdown documentation and convert to HTML (if pandoc is available)
if command -v pandoc &> /dev/null; then
echo "Converting Markdown files to HTML..."
mkdir -p tech-writer-reference/reference
# Function to convert markdown, removing Jekyll front matter and first heading to avoid duplicates
convert_md_to_html() {
local input_file="$1"
local output_file="$2"
local css_path="$3"
# Extract the first heading for title, then remove Jekyll front matter and first heading
local title=$(grep '^# ' "$input_file" | head -1 | sed 's/^# //')
# Create temporary file with Jekyll front matter removed and first heading removed
local temp_file=$(mktemp)
sed '/^---$/,/^---$/d' "$input_file" | sed '/^# /{ /^# '"$title"'$/d; }' > "$temp_file"
# Convert to HTML
pandoc "$temp_file" --from markdown --to html --standalone --css="$css_path" \
--metadata title="$title" \
-o "$output_file"
# Clean up temp file
rm "$temp_file"
}
# Convert main guides
convert_md_to_html "../docs/tech-writer-reference/TECH_WRITER_GUIDE.md" "tech-writer-reference/TECH_WRITER_GUIDE.html" "../style.css"
convert_md_to_html "../docs/tech-writer-reference/01-generated-documentation-guide.md" "tech-writer-reference/01-generated-documentation-guide.html" "../style.css"
convert_md_to_html "../docs/tech-writer-reference/02-manual-yaml-writing-guide.md" "tech-writer-reference/02-manual-yaml-writing-guide.html" "../style.css"
convert_md_to_html "../docs/tech-writer-reference/03-testing-validation-guide.md" "tech-writer-reference/03-testing-validation-guide.html" "../style.css"
convert_md_to_html "../docs/tech-writer-reference/04-api-documentation-publishing-guide.md" "tech-writer-reference/04-api-documentation-publishing-guide.html" "../style.css"
# Convert reference materials
convert_md_to_html "../docs/tech-writer-reference/reference/openapi-examples.md" "tech-writer-reference/reference/openapi-examples.html" "../../style.css"
convert_md_to_html "../docs/tech-writer-reference/reference/annotation-reference.md" "tech-writer-reference/reference/annotation-reference.html" "../../style.css"
convert_md_to_html "../docs/tech-writer-reference/reference/tools-comparison.md" "tech-writer-reference/reference/tools-comparison.html" "../../style.css"
echo "✅ Markdown converted to HTML"
else
echo "📝 Pandoc not found - copying Markdown files as-is"
cp -r ../docs/tech-writer-reference .
fi
echo "🎨 Adding custom landing page..."
# Copy the custom landing page
cp ../docs-template/index.html landing.html
# Create a simple CSS for the converted HTML files
cat > style.css << 'EOF'
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
line-height: 1.6;
max-width: 800px;
margin: 0 auto;
padding: 2rem;
color: #333;
}
h1, h2, h3, h4, h5, h6 {
color: #2c3e50;
margin-top: 2rem;
margin-bottom: 1rem;
}
code {
background: #f8f9fa;
padding: 0.2rem 0.4rem;
border-radius: 4px;
font-size: 0.9em;
}
pre {
background: #f8f9fa;
padding: 1rem;
border-radius: 8px;
overflow-x: auto;
}
pre code {
background: none;
padding: 0;
}
blockquote {
border-left: 4px solid #3498db;
margin-left: 0;
padding-left: 1rem;
color: #7f8c8d;
}
table {
border-collapse: collapse;
width: 100%;
margin: 1rem 0;
}
th, td {
border: 1px solid #ddd;
padding: 0.5rem;
text-align: left;
}
th {
background: #f8f9fa;
font-weight: bold;
}
.nav-link {
display: inline-block;
margin: 0.5rem 1rem 0.5rem 0;
padding: 0.5rem 1rem;
background: #3498db;
color: white;
text-decoration: none;
border-radius: 5px;
}
.nav-link:hover {
background: #2980b9;
}
EOF
echo "📂 Creating directory structure..."
# Create additional directories
mkdir -p api-assets/postman api-assets/openapi
# Copy Postman assets
cp -r ../docs/tech-writer-reference/api-assets/postman/* api-assets/postman/
cp -r ../docs/tech-writer-reference/api-assets/openapi/* api-assets/openapi/
echo "🔧 Creating navigation..."
# Create a simple navigation file
cat > navigation.html << 'EOF'
<nav style="background: #f8f9fa; padding: 1rem; border-radius: 8px; margin-bottom: 2rem;">
<h3>📖 Documentation Navigation</h3>
<a href="../landing.html" class="nav-link">🏠 Home</a>
<a href="../index.html" class="nav-link">🚀 API Explorer</a>
<a href="TECH_WRITER_GUIDE.html" class="nav-link">📚 Writer Guide</a>
<a href="01-generated-documentation-guide.html" class="nav-link">⚡ Generated Docs</a>
<a href="02-manual-yaml-writing-guide.html" class="nav-link">✍️ Manual YAML</a>
<a href="03-testing-validation-guide.html" class="nav-link">🧪 Testing</a>
<a href="04-api-documentation-publishing-guide.html" class="nav-link">🌐 Publishing</a>
</nav>
EOF
cd ..
echo ""
echo "✅ Documentation website generated successfully!"
echo ""
echo "📂 Generated files in: docs-site/"
echo "🌐 Main API Explorer: docs-site/index.html"
echo "🏠 Landing Page: docs-site/landing.html"
echo ""
echo "🚀 Next steps:"
echo "1. Upload to GitHub repository"
echo "2. Enable GitHub Pages"
echo "3. Access at: https://kolchfa-aws.github.io/your-repo-name/"
echo ""
echo "💡 Tip: Use 'landing.html' as your main page for a professional presentation"