-
Notifications
You must be signed in to change notification settings - Fork 5
894 lines (792 loc) · 33.5 KB
/
docs.yml
File metadata and controls
894 lines (792 loc) · 33.5 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
# Workflow: Documentation Build and Deploy
#
# This workflow builds and validates Rust documentation, and optionally
# deploys it to GitHub Pages. It ensures that documentation stays up-to-date
# and accessible to users and contributors.
name: Documentation
# Trigger conditions
on:
# Run on pushes to main branch to keep docs updated
push:
branches: [ "main", "master" ]
# Run on pull requests to validate documentation changes
pull_request:
branches: [ "main", "master" ]
# Allow manual triggering for documentation updates
workflow_dispatch:
# Set permissions for GitHub Pages deployment
permissions:
contents: read
pages: write
id-token: write
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
# Define environment variables
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
# Define the documentation jobs
jobs:
# Job 1: Build and validate documentation
build-docs:
name: Build Documentation
runs-on: ubuntu-latest
steps:
# Step 1: Check out the source code
- name: Checkout source code
uses: actions/checkout@v4
# Step 2: Install Rust toolchain with Cargo.lock v4 support
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.86.0
# Step 3: Setup Rust caching
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
# Step 4: Build documentation for all crates
# This generates HTML documentation from Rust doc comments
- name: Build Rust documentation
run: |
echo "Building Rust documentation..."
cargo doc --all --no-deps --document-private-items
env:
# Treat documentation warnings as errors to ensure quality
RUSTDOCFLAGS: "-D warnings"
# Step 5: Create comprehensive documentation website
- name: Create documentation website
run: |
echo "Creating comprehensive documentation website..."
# Create main website directory structure
mkdir -p target/doc/website
mkdir -p target/doc/tutorials
# Copy tutorial markdown files
cp README.md target/doc/website/
cp mcp_rust_tutorial.md target/doc/tutorials/ 2>/dev/null || echo "Tutorial file not found, skipping"
# Create main index page
cat > target/doc/index.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MCP Rust Examples - Complete Learning Resource</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
line-height: 1.6;
color: #333;
background: #f8f9fa;
}
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
.header {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 60px 0;
text-align: center;
margin-bottom: 40px;
}
.header h1 { font-size: 3rem; margin-bottom: 20px; }
.header p { font-size: 1.2rem; opacity: 0.9; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 30px; margin-bottom: 40px; }
.card {
background: white;
padding: 30px;
border-radius: 12px;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
transition: transform 0.3s ease;
}
.card:hover { transform: translateY(-5px); }
.card h3 { color: #667eea; margin-bottom: 15px; font-size: 1.4rem; }
.card p { color: #666; margin-bottom: 20px; }
.btn {
display: inline-block;
padding: 12px 24px;
background: #667eea;
color: white;
text-decoration: none;
border-radius: 6px;
transition: background 0.3s ease;
}
.btn:hover { background: #5a6fd8; }
.examples { background: white; padding: 30px; border-radius: 12px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.examples h3 { color: #667eea; margin-bottom: 20px; }
.example-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 15px; }
.example-item {
padding: 15px;
background: #f8f9fa;
border-radius: 8px;
border-left: 4px solid #667eea;
}
.example-item strong { color: #333; }
.footer { text-align: center; margin-top: 60px; padding: 30px; color: #666; }
code {
background: #f4f4f4;
padding: 2px 6px;
border-radius: 4px;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}
.highlight { background: #fff3cd; padding: 20px; border-radius: 8px; border-left: 4px solid #ffc107; margin: 20px 0; }
</style>
</head>
<body>
<div class="header">
<div class="container">
<h1>🦀 MCP Rust Examples</h1>
<p>Complete Learning Resource for Model Context Protocol Development with Rust</p>
</div>
</div>
<div class="container">
<div class="highlight">
<strong>🚀 Ready to start?</strong> Choose your learning path and begin building amazing MCP applications with Rust!
</div>
<div class="grid">
<div class="card">
<h3>📚 API Documentation</h3>
<p>Complete Rust API documentation for all examples and utilities. Generated from source code comments.</p>
<a href="mcp_rust_examples/index.html" class="btn">Browse API Docs</a>
</div>
<div class="card">
<h3>📖 Learning Tutorials</h3>
<p>Comprehensive tutorials covering MCP development from beginner to enterprise level.</p>
<a href="tutorials/mcp_rust_tutorial.html" class="btn">Start Learning</a>
</div>
<div class="card">
<h3>🎯 Quick Start</h3>
<p>Get up and running quickly with our step-by-step setup guide and first example.</p>
<div style="margin-top: 15px;">
<code>cargo run --bin example_01_hello_world</code>
</div>
</div>
<div class="card">
<h3>🛠️ Development Tools</h3>
<p>Local testing tools and scripts for development workflow optimization.</p>
<div style="margin-top: 15px;">
<code>./scripts/test-workflows.sh</code>
</div>
</div>
</div>
<div class="examples">
<h3>🎪 20 Complete Working Examples</h3>
<div class="example-list">
<div class="example-item">
<strong>Examples 1-5:</strong> Basic MCP Concepts<br>
<small>Hello World, Calculator, Text Processor, Resource Provider</small>
</div>
<div class="example-item">
<strong>Examples 6-10:</strong> Intermediate Features<br>
<small>Configuration, File Ops, HTTP Client, Database, Streaming</small>
</div>
<div class="example-item">
<strong>Examples 11-15:</strong> Advanced Patterns<br>
<small>Monitoring, Task Queues, Auth, Notifications, Data Pipeline</small>
</div>
<div class="example-item">
<strong>Examples 16-20:</strong> Enterprise Solutions<br>
<small>Search Engine, Blockchain, ML Server, Microservices, Complete App</small>
</div>
</div>
</div>
<div class="footer">
<p>🌟 <strong>Open Source Educational Resource</strong> | Built with ❤️ for the Rust and MCP Community</p>
<p>Updated automatically from the latest codebase</p>
</div>
</div>
</body>
</html>
EOF
# Convert README to HTML if pandoc is available
if command -v pandoc >/dev/null 2>&1; then
echo "Converting README to HTML..."
pandoc README.md -o target/doc/website/readme.html --standalone --css=../style.css 2>/dev/null || cp README.md target/doc/website/
else
echo "Pandoc not available, copying README as-is"
cp README.md target/doc/website/
fi
# Step 5.5: Install markdown processing tools and create tutorial HTML
- name: Install markdown processing tools
run: |
echo "Installing markdown processing tools..."
# Install pandoc for proper markdown to HTML conversion
sudo apt-get update
sudo apt-get install -y pandoc
# Install Python markdown for fallback
pip install markdown[extra] pygments
- name: Create beautiful tutorial HTML pages
run: |
echo "Creating beautiful tutorial HTML pages..."
# Create enhanced CSS for beautiful rendering
cat > target/doc/tutorials/tutorial-style.css << 'EOF'
/* Beautiful Tutorial Styling */
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
line-height: 1.7;
color: #2c3e50;
max-width: 1200px;
margin: 0 auto;
padding: 20px;
background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
min-height: 100vh;
}
.container {
background: white;
border-radius: 12px;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
padding: 40px;
margin: 20px auto;
}
.nav {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 20px;
border-radius: 12px;
margin-bottom: 40px;
text-align: center;
box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}
.nav a {
color: white;
text-decoration: none;
margin: 0 20px;
padding: 8px 16px;
border-radius: 6px;
transition: background 0.3s ease;
}
.nav a:hover {
background: rgba(255,255,255,0.2);
text-decoration: none;
}
h1 {
color: #667eea;
font-size: 2.5rem;
margin-bottom: 30px;
text-align: center;
background: linear-gradient(135deg, #667eea, #764ba2);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
h2 {
color: #4a5568;
font-size: 1.8rem;
margin: 40px 0 20px 0;
padding-bottom: 10px;
border-bottom: 3px solid #667eea;
}
h3 {
color: #667eea;
font-size: 1.4rem;
margin: 30px 0 15px 0;
}
p {
margin-bottom: 20px;
text-align: justify;
}
pre {
background: #2d3748;
color: #e2e8f0;
padding: 20px;
border-radius: 8px;
overflow-x: auto;
border-left: 4px solid #667eea;
margin: 20px 0;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}
code {
background: #edf2f7;
color: #e53e3e;
padding: 3px 8px;
border-radius: 4px;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', monospace;
font-size: 0.9em;
}
pre code {
background: transparent;
color: inherit;
padding: 0;
}
.example {
background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
border: 1px solid #dee2e6;
border-radius: 12px;
padding: 25px;
margin: 25px 0;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.toc {
background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
padding: 25px;
border-radius: 12px;
margin: 30px 0;
border-left: 5px solid #2196f3;
}
.toc ul { list-style-type: none; padding-left: 20px; }
.toc > ul { padding-left: 0; }
.toc a { color: #1976d2; text-decoration: none; font-weight: 500; }
.toc a:hover { text-decoration: underline; color: #0d47a1; }
.highlight {
background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
border: 1px solid #ffeaa7;
border-radius: 8px;
padding: 20px;
margin: 25px 0;
border-left: 5px solid #f39c12;
}
.note {
background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
border: 1px solid #c3e6cb;
border-radius: 8px;
padding: 20px;
margin: 25px 0;
border-left: 5px solid #28a745;
}
.warning {
background: linear-gradient(135deg, #f8d7da 0%, #f1b2b7 100%);
border: 1px solid #f1b2b7;
border-radius: 8px;
padding: 20px;
margin: 25px 0;
border-left: 5px solid #dc3545;
}
ul, ol {
margin-bottom: 20px;
padding-left: 30px;
}
li {
margin-bottom: 8px;
}
strong {
color: #2d3748;
font-weight: 600;
}
em {
color: #667eea;
font-style: italic;
}
blockquote {
border-left: 4px solid #667eea;
padding-left: 20px;
margin: 20px 0;
font-style: italic;
color: #4a5568;
background: #f7fafc;
padding: 15px 20px;
border-radius: 0 8px 8px 0;
}
table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
border-radius: 8px;
overflow: hidden;
}
th, td {
padding: 12px 15px;
text-align: left;
border-bottom: 1px solid #e2e8f0;
}
th {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
font-weight: 600;
}
tr:hover {
background: #f8f9fa;
}
a {
color: #667eea;
text-decoration: none;
border-bottom: 1px solid transparent;
transition: border-color 0.3s ease;
}
a:hover {
border-bottom: 1px solid #667eea;
}
.footer {
text-align: center;
margin-top: 60px;
padding: 30px;
color: #718096;
border-top: 1px solid #e2e8f0;
}
EOF
# Create complete HTML template
cat > target/doc/tutorials/template.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>MCP Rust Tutorial - Complete Learning Resource</title>
<link rel="stylesheet" href="tutorial-style.css">
<link rel="icon" href="data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><text y='.9em' font-size='90'>🦀</text></svg>">
<meta name="description" content="Complete tutorial for learning MCP (Model Context Protocol) development with Rust">
<meta name="keywords" content="Rust, MCP, Model Context Protocol, Tutorial, Programming">
</head>
<body>
<div class="nav">
<a href="../index.html">🏠 Home</a>
<a href="../mcp_rust_examples/index.html">📚 API Docs</a>
<a href="mcp_rust_tutorial.html">📖 Tutorial</a>
<a href="../website/readme.html">📄 README</a>
</div>
<div class="container">
EOF
# Convert markdown to beautiful HTML using pandoc
if [ -f "mcp_rust_tutorial.md" ]; then
echo "Converting tutorial markdown to beautiful HTML..."
# Try pandoc with advanced features first
if pandoc mcp_rust_tutorial.md \
-f markdown+smart+pipe_tables+fenced_code_blocks+definition_lists \
-t html5 \
--standalone \
--toc \
--toc-depth=4 \
--section-divs \
--html-q-tags \
--highlight-style=tango \
--template=target/doc/tutorials/template.html \
-o target/doc/tutorials/mcp_rust_tutorial.html \
--metadata title="MCP Rust Tutorial - Complete Learning Resource" 2>/dev/null; then
# Add closing tags
echo '</div><div class="footer">🦀 <strong>MCP Rust Tutorial</strong> | Built with ❤️ for the Rust Community</div></body></html>' >> target/doc/tutorials/mcp_rust_tutorial.html
echo "✅ Beautiful tutorial HTML created successfully with pandoc!"
else
echo "⚠️ Pandoc failed, trying simpler conversion..."
# Fallback to basic pandoc conversion
if pandoc mcp_rust_tutorial.md \
-f markdown \
-t html5 \
--standalone \
--toc \
--template=target/doc/tutorials/template.html \
-o target/doc/tutorials/mcp_rust_tutorial.html 2>/dev/null; then
echo '</div><div class="footer">🦀 <strong>MCP Rust Tutorial</strong> | Built with ❤️ for the Rust Community</div></body></html>' >> target/doc/tutorials/mcp_rust_tutorial.html
echo "✅ Tutorial HTML created with basic pandoc conversion!"
else
echo "⚠️ Pandoc conversion failed, creating manual HTML..."
# Manual HTML creation as ultimate fallback
cat target/doc/tutorials/template.html > target/doc/tutorials/mcp_rust_tutorial.html
# Use a simple Python one-liner for markdown conversion
python3 -c "import markdown; print(markdown.markdown(open('mcp_rust_tutorial.md').read(), extensions=['toc', 'codehilite', 'tables']))" >> target/doc/tutorials/mcp_rust_tutorial.html
echo '</div><div class="footer">🦀 <strong>MCP Rust Tutorial</strong> | Built with ❤️ for the Rust Community</div></body></html>' >> target/doc/tutorials/mcp_rust_tutorial.html
echo "✅ Tutorial HTML created with Python markdown!"
fi
fi
else
echo "⚠️ Tutorial markdown not found, creating placeholder..."
cat target/doc/tutorials/template.html > target/doc/tutorials/mcp_rust_tutorial.html
echo '<h1>🚧 Tutorial Coming Soon</h1><p>The comprehensive MCP Rust tutorial will be available soon.</p></div></body></html>' >> target/doc/tutorials/mcp_rust_tutorial.html
fi
# Step 5.6: Create additional navigation and utility pages
- name: Create site navigation and utilities
run: |
echo "Creating additional site pages..."
# Create a sitemap for better navigation
cat > target/doc/sitemap.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Site Map - MCP Rust Examples</title>
<style>
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; }
h1, h2 { color: #667eea; }
ul { list-style-type: none; padding-left: 20px; }
li { margin: 10px 0; }
a { color: #667eea; text-decoration: none; }
a:hover { text-decoration: underline; }
</style>
</head>
<body>
<h1>🗺️ Site Map</h1>
<ul>
<li><a href="index.html">🏠 Home</a></li>
<li><a href="mcp_rust_examples/index.html">📚 API Documentation</a></li>
<li><a href="tutorials/mcp_rust_tutorial.html">📖 Complete Tutorial</a></li>
<li><a href="website/readme.html">📄 Project README</a></li>
</ul>
<h2>📁 Examples by Category</h2>
<ul>
<li><strong>Basic (1-5):</strong> Fundamentals and Core Concepts</li>
<li><strong>Intermediate (6-10):</strong> Configuration, I/O, and Data</li>
<li><strong>Advanced (11-15):</strong> Auth, Monitoring, and Async</li>
<li><strong>Enterprise (16-20):</strong> Search, Blockchain, ML, and Production</li>
</ul>
</body>
</html>
EOF
# Create a robots.txt for search engines
cat > target/doc/robots.txt << 'EOF'
User-agent: *
Allow: /
Sitemap: https://rustsandbox.github.io/MCP-Development-with-Rust/sitemap.html
EOF
# Create a custom 404 page
cat > target/doc/404.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page Not Found - MCP Rust Examples</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
text-align: center;
padding: 50px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
min-height: 100vh;
margin: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.container { background: rgba(255,255,255,0.1); padding: 40px; border-radius: 12px; backdrop-filter: blur(10px); }
h1 { font-size: 4rem; margin-bottom: 20px; }
p { font-size: 1.2rem; margin-bottom: 30px; }
.btn {
display: inline-block;
padding: 12px 24px;
background: rgba(255,255,255,0.2);
color: white;
text-decoration: none;
border-radius: 6px;
transition: background 0.3s ease;
border: 2px solid white;
}
.btn:hover { background: rgba(255,255,255,0.3); }
</style>
</head>
<body>
<div class="container">
<h1>🦀 404</h1>
<p>Oops! The page you're looking for doesn't exist.</p>
<p>But don't worry, there's plenty of great content to explore!</p>
<a href="/MCP-Development-with-Rust/" class="btn">🏠 Go Home</a>
</div>
</body>
</html>
EOF
# Create a CNAME file for custom domain (if needed)
# Uncomment the line below if you have a custom domain
# echo "your-domain.com" > target/doc/CNAME
echo "✅ Site structure created successfully"
# Step 5.7: Ensure 404 page is created (fix for deployment issue)
- name: Create 404 page
run: |
echo "Creating 404.html page..."
cat > target/doc/404.html << 'EOF'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Page Not Found - MCP Rust Examples</title>
<style>
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
text-align: center;
padding: 50px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
min-height: 100vh;
margin: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
}
.container { background: rgba(255,255,255,0.1); padding: 40px; border-radius: 12px; backdrop-filter: blur(10px); }
h1 { font-size: 4rem; margin-bottom: 20px; }
p { font-size: 1.2rem; margin-bottom: 30px; }
.btn {
display: inline-block;
padding: 12px 24px;
background: rgba(255,255,255,0.2);
color: white;
text-decoration: none;
border-radius: 6px;
transition: background 0.3s ease;
border: 2px solid white;
}
.btn:hover { background: rgba(255,255,255,0.3); }
</style>
</head>
<body>
<div class="container">
<h1>🦀 404</h1>
<p>Oops! The page you're looking for doesn't exist.</p>
<p>But don't worry, there's plenty of great content to explore!</p>
<a href="/MCP-Development-with-Rust/" class="btn">🏠 Go Home</a>
</div>
</body>
</html>
EOF
echo "✅ 404.html created successfully"
# Step 6: Verify documentation structure
- name: Verify documentation
run: |
echo "Verifying comprehensive documentation structure..."
# Check if main documentation was generated
if [ ! -d "target/doc" ]; then
echo "❌ Documentation directory not found!"
exit 1
fi
# Verify main site structure
echo "🔍 Checking main site files..."
required_files=(
"target/doc/index.html"
"target/doc/404.html"
"target/doc/sitemap.html"
"target/doc/robots.txt"
)
for file in "${required_files[@]}"; do
if [ -f "$file" ]; then
echo "✅ $file exists"
else
echo "❌ $file missing"
exit 1
fi
done
# Check directory structure
echo "🔍 Checking directory structure..."
required_dirs=(
"target/doc/website"
"target/doc/tutorials"
)
for dir in "${required_dirs[@]}"; do
if [ -d "$dir" ]; then
echo "✅ $dir exists"
else
echo "❌ $dir missing"
exit 1
fi
done
# Check if Rust API documentation was generated
if [ -d "target/doc/mcp_rust_examples" ]; then
echo "✅ Rust API documentation generated"
else
echo "⚠️ Rust API documentation not found (may be normal)"
fi
# Count HTML files for statistics
html_count=$(find target/doc -name "*.html" | wc -l)
echo "📊 Statistics:"
echo " - Total HTML files: $html_count"
echo " - Site structure: Complete"
echo " - Ready for GitHub Pages: ✅"
# Display site structure
echo "🌐 Site structure overview:"
tree target/doc -L 3 2>/dev/null || find target/doc -type d | head -10
echo "✅ Documentation verification complete - Ready for deployment!"
# Step 7: Upload documentation artifacts
- name: Upload documentation artifacts
uses: actions/upload-artifact@v4
with:
name: rust-documentation
path: target/doc/
retention-days: 30
# Step 8: Setup Pages (only on main branch, and only if Pages is enabled)
- name: Setup Pages
id: setup-pages
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
uses: actions/configure-pages@v4
continue-on-error: true
# Step 9: Upload to GitHub Pages (only if Pages setup succeeded)
- name: Upload to GitHub Pages
if: (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master') && steps.setup-pages.outcome == 'success'
uses: actions/upload-pages-artifact@v3
with:
path: target/doc/
# Job 2: Deploy to GitHub Pages (only on main branch)
deploy-pages:
name: Deploy to GitHub Pages
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
needs: build-docs
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
# Step 1: Deploy to GitHub Pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
# Job 3: Documentation quality checks
doc-quality:
name: Documentation Quality
runs-on: ubuntu-latest
steps:
# Step 1: Check out the source code
- name: Checkout source code
uses: actions/checkout@v4
# Step 2: Install Rust toolchain with Cargo.lock v4 support
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@1.86.0
# Step 3: Setup Rust caching
- name: Setup Rust cache
uses: Swatinem/rust-cache@v2
# Step 4: Check documentation coverage
- name: Check documentation coverage
run: |
echo "Checking documentation coverage..."
# Generate documentation with coverage information
cargo doc --all --no-deps --document-private-items 2>&1 | tee doc-output.log
# Check for missing documentation warnings
if grep -i "missing documentation" doc-output.log; then
echo "⚠️ Found missing documentation warnings"
else
echo "✅ No missing documentation warnings"
fi
# Check for broken intra-doc links
if grep -i "broken.*link" doc-output.log; then
echo "❌ Found broken documentation links"
exit 1
else
echo "✅ No broken documentation links"
fi
# Step 5: Validate README files
- name: Validate README files
run: |
echo "Validating README files..."
# Check if main README exists and has content
if [ -f "README.md" ] && [ -s "README.md" ]; then
echo "✅ Main README.md exists and has content"
else
echo "❌ README.md is missing or empty"
exit 1
fi
# Step 6: Generate documentation report
- name: Generate documentation report
run: |
echo "# Documentation Quality Report" > doc-report.md
echo "" >> doc-report.md
echo "Generated on: $(date)" >> doc-report.md
echo "Repository: ${{ github.repository }}" >> doc-report.md
echo "Commit: ${{ github.sha }}" >> doc-report.md
echo "" >> doc-report.md
echo "## Documentation Build Status" >> doc-report.md
if [ -d "target/doc" ]; then
echo "✅ Documentation built successfully" >> doc-report.md
# Count documentation files
html_files=$(find target/doc -name "*.html" | wc -l)
echo "- Generated $html_files HTML files" >> doc-report.md
else
echo "❌ Documentation build failed" >> doc-report.md
fi
echo "" >> doc-report.md
echo "---" >> doc-report.md
echo "*Report generated by GitHub Actions Documentation Workflow*" >> doc-report.md
# Step 7: Upload documentation report
- name: Upload documentation report
uses: actions/upload-artifact@v4
with:
name: documentation-report
path: doc-report.md
retention-days: 90