Guide Based Auto Guide System
Comprehensive documentation system guides
🎯 Guide-Based Auto-Guide System - Stable & Predictable
✅ New Strategy Implemented
The docs-angular system now uses a stable, predictable guide-based approach instead of complex auto-detection logic.
🎯 How It Works
📁 Guide.md Files
Every directory that should support auto-guides now has a guide.md file:
apps/
├── guide.md ← Controls /apps route
├── singularity/
│ └── guide.md ← Controls /apps/singularity route
├── editor-web/
│ └── guide.md ← Controls /apps/editor-web route
├── space-map/
│ └── guide.md ← Controls /apps/space-map route
└── ux-test/
└── guide.md ← Controls /apps/ux-test route
🔧 Auto-Guide Trigger
A guide.md file triggers auto-guide when it contains:
Option 1: Auto-Guide Marker
<!-- AUTO-GUIDE -->
This marker tells the system to show the beautiful auto-guide.
Option 2: Empty/Minimal Content
- Empty file
- Only whitespace
- Less than 50 characters of actual content
📄 Custom Guide Content
If guide.md contains substantial content (50+ characters), it shows that content instead of the auto-guide.
🔄 Decision Flow
graph TD
A[Route Accessed] --> B{guide.md exists?}
B -->|Yes| C{Contains AUTO-GUIDE marker?}
B -->|No| H[Fallback: Check for children]
C -->|Yes| D[Show Auto-Guide]
C -->|No| E{Content < 50 chars?}
E -->|Yes| D
E -->|No| F[Show Guide Content]
H -->|Has children| D
H -->|No children| G[Try to load regular content]
D --> I[Beautiful Auto-Guide with Cards]
F --> J[Custom Guide Content]
G --> K[Regular Markdown Content]
🛠️ Implementation Details
📋 DocsPageComponent Logic
private smartLoadContent(path: string): void {
// 1. Try to load guide.md first
const guidePath = cleanPath === '/' ? '/guide' : `${cleanPath}/guide`;
this.markdownService.loadContent(guidePath, 'en').subscribe({
next: (guideContent) => {
// 2. Check if it's an auto-guide marker
if (this.isAutoGuideMarker(guideContent.content)) {
this.showAutoGuide.set(true); // Show auto-guide
} else {
this.content.set(guideContent); // Show guide content
}
},
error: () => {
// 3. Fallback to children detection
this.fallbackToChildrenDetection(cleanPath);
}
});
}
🎯 Auto-Guide Marker Detection
private isAutoGuideMarker(content: string): boolean {
const trimmedContent = content.trim();
// Check for explicit marker
if (trimmedContent.includes('<!-- AUTO-GUIDE -->')) {
return true;
}
// Check if essentially empty
const contentWithoutMarker = trimmedContent.replace(/<!--[\s\S]*?-->/g, '').trim();
return contentWithoutMarker.length < 50;
}
🎯 Benefits of New System
✅ Predictable
- Clear intent -
guide.mdexplicitly controls behavior - No guessing - System knows exactly what to do
- Consistent results - Same file always produces same behavior
✅ Stable
- No complex detection - Simple file-based logic
- Fewer edge cases - Explicit control reduces errors
- Easier debugging - Clear decision path
✅ Flexible
- Auto-guide on demand - Add
<!-- AUTO-GUIDE -->marker - Custom guides - Write custom content when needed
- Easy switching - Change marker to switch behavior
✅ Maintainable
- Simple to understand - Clear file-based pattern
- Easy to add - Just create
guide.mdfile - Version controllable - Guide decisions tracked in git
📝 Usage Examples
🎯 Creating Auto-Guide for New Section
# 1. Create directory
mkdir apps/docs-angular/src/assets/docs/english/my-section
# 2. Add content files
echo "# Feature 1" > apps/docs-angular/src/assets/docs/english/my-section/feature-1.md
echo "# Feature 2" > apps/docs-angular/src/assets/docs/english/my-section/feature-2.md
# 3. Create guide.md for auto-guide
cat > apps/docs-angular/src/assets/docs/english/my-section/guide.md << 'EOF'
<!-- AUTO-GUIDE -->
Auto-guide for my-section with all features.
EOF
# 4. Regenerate manifest
node apps/docs-angular/scripts/scan-docs-structure.js
# Result: /my-section shows beautiful auto-guide with Feature 1 & Feature 2 cards! ✨
🎨 Creating Custom Guide
# Create guide.md with substantial content
cat > apps/docs-angular/src/assets/docs/english/my-section/guide.md << 'EOF'
# My Section Guide
This is a custom guide with specific instructions for this section.
## Getting Started
Follow these steps...
## Advanced Usage
For advanced features...
EOF
# Result: /my-section shows custom guide content instead of auto-guide
🔄 Switching Between Auto-Guide and Custom
# Switch to auto-guide
echo "<!-- AUTO-GUIDE -->" > apps/docs-angular/src/assets/docs/english/my-section/guide.md
# Switch to custom guide
echo "# Custom Guide Content..." > apps/docs-angular/src/assets/docs/english/my-section/guide.md
🚀 Migration from Old System
✅ All Apps Already Migrated
- ✅
/apps- Has guide.md with auto-guide marker - ✅
/apps/singularity- Has guide.md with auto-guide marker - ✅
/apps/editor-web- Has guide.md with auto-guide marker - ✅
/apps/space-map- Has guide.md with auto-guide marker - ✅
/apps/ux-test- Has guide.md with auto-guide marker
🔄 Fallback System
The system still includes fallback logic for routes without guide.md:
- First: Try to find
guide.md - If not found: Check for children (old logic)
- If no children: Load regular content
This ensures zero breaking changes while providing the new stable system.
🔍 Debugging Guide
🐛 Auto-Guide Not Showing
- Check guide.md exists:
/path/to/section/guide.md - Verify marker: Contains
<!-- AUTO-GUIDE -->or is < 50 chars - Check console: Look for guide-based loading messages
- Verify children: Ensure section has child content
📄 Content Not Loading
- Check guide.md content: If > 50 chars, it shows as content
- Remove marker: Delete
<!-- AUTO-GUIDE -->if you want content - Check file structure: Ensure content files exist
🔄 Fallback Issues
- Add guide.md: Create explicit guide.md for predictable behavior
- Check manifest: Ensure
node apps/docs-angular/scripts/scan-docs-structure.jswas run - Verify routes: Check navigation structure for correct paths
🎯 Best Practices
📁 Directory Structure
my-section/
├── guide.md ← Controls section behavior
├── overview.md ← Content files
├── getting-started.md
└── advanced-features.md
🎯 Guide.md Patterns
<!-- For auto-guide -->
<!-- AUTO-GUIDE -->
Brief description of what this section contains.
<!-- For custom guide -->
# Section Guide
Custom guide content with specific instructions...
📋 Naming Conventions
- Always use:
guide.md(lowercase, exact name) - Not:
Guide.md,GUIDE.md,guide.markdown - Location: Always in the directory root
🌟 Conclusion
The new guide-based system provides:
🎯 For Users
- Predictable behavior - Same route always works the same way
- Beautiful auto-guides - When intended, perfect guides display
- Custom guides - When needed, custom content available
🛠️ For Developers
- Simple logic - Easy to understand and debug
- Explicit control - Clear intent with guide.md files
- Zero maintenance - Once set up, works reliably
📈 For Growth
- Scalable pattern - Works for any number of sections
- Version controlled - All decisions tracked in git
- Future-proof - Simple system that won't break
Your docs-angular system now has rock-solid, predictable auto-guide behavior! 🚀