Enhanced Docs System

Comprehensive documentation system guides

🚀 Enhanced Documentation System

Overview

We've completely redesigned the documentation system to provide automatic directory discovery, multi-language support, and intelligent content management. This system addresses both improvement requests:

✅ Improvement #1: Unified System with Automatic Discovery

✅ Improvement #2: Multi-Language Support

🏗️ New Architecture

Services Separation

Service Responsibility Location
DocumentationService Logic & Discovery services/documentation.service.ts
NavigationService Navigation Structure services/navigation.service.ts
MarkdownService Markdown Parsing services/markdown.service.ts
DynamicRoutesService Route Generation services/dynamic-routes.service.ts

Key Features

📁 Directory Structure

apps/docs-angular/src/assets/docs/
├── english/                    # English documentation
│   ├── getting-started/
│   ├── guide/
│   ├── development/
│   ├── apps/
│   ├── libs/
│   ├── troubleshooting/
│   └── examples/
├── spanish/                    # Spanish documentation (future)
│   └── [same structure as english]
├── index.md               # English homepage
├── index.es.md                # Spanish homepage
└── docs-manifest.json         # Generated structure manifest

🚀 Quick Start

1. Scan Documentation Structure

# Generate manifest of all documentation files
yarn docs:scan

# Watch for changes and auto-scan
yarn docs:scan:watch

# Get statistics only
yarn docs:stats

2. Add New Documentation

Simply add a .md file in the appropriate language directory:

# Create new file
echo "# My New Guide" > apps/docs-angular/src/assets/docs/english/guide/my-new-guide.md

# Scan to discover it
yarn docs:scan

The system will automatically:

3. Language Support

// Switch language programmatically
const docService = inject(DocumentationService);
await docService.switchLanguage('es');

// Load content for specific language
const content = await docService.loadContent('/guide/feature', 'es');

4. Manual Navigation Overrides

Edit services/navigation.service.ts to customize navigation:

readonly navigationStructure = signal<NavigationItem[]>([
  {
    text: '🚀 Getting Started',
    order: 1,
    items: [
      { text: 'Introduction', link: '/getting-started', order: 1 },
      // Add your custom items here
    ]
  }
]);

🛠️ Development Tools

Available Commands

# Documentation development  
yarn docs:dev              # Start docs dev server
yarn docs:scan             # Scan documentation structure
yarn docs:scan:watch       # Watch and auto-scan changes
yarn docs:stats            # Get documentation statistics

# Structure management
yarn docs:build            # Build documentation
yarn docs:preview          # Preview production build

Service APIs

// DocumentationService
const stats = docService.documentationStats();
await docService.refreshStructure();
const exists = await docService.contentExists('/path', 'en');

// NavigationService  
const navItem = navService.getNavigationItem('/path');
await navService.syncWithDocumentationService();

// MarkdownService
markdownService.clearCache();
const cacheStats = markdownService.getCacheStats();

📊 File Naming & Detection

Priority Order for Language Detection

  1. Directory-based: Files in /english/ or /spanish/ directories
  2. Extension-based: Files with .md or .es.md extensions
  3. Service state: Current language in DocumentationService
  4. Default: English (en)

Path Resolution Order

When loading content, the system tries these paths in order:

  1. /assets/docs/english/guide/feature.md
  2. /assets/docs/guide/feature.md (legacy)

🔄 Migration from Old System

Automatic Migration

Most content should work automatically. The system provides backward compatibility for:

Manual Steps

  1. Move Files (Optional): Move files to language directories for cleaner organization
  2. Update References: Update any hardcoded file paths in components
  3. Test Navigation: Verify all navigation links work
  4. Scan Structure: Run yarn docs:scan to generate manifest

🎯 Benefits

For Developers

For Content Creators

For Users

📋 Scripts Overview

Main Scanner Script

Package.json Scripts

{
  "docs:scan": "node apps/docs-angular/scripts/scan-docs-structure.js",
  "docs:scan:watch": "nodemon --watch apps/docs-angular/src/assets/docs --ext md --exec 'yarn docs:scan'",
  "docs:stats": "node apps/docs-angular/scripts/scan-docs-structure.js --stats-only"
}

🔮 Future Enhancements

🚨 Troubleshooting

Common Issues

Issue Solution
File not found Check path resolution order and naming
Navigation missing Verify NavigationService includes section
Language not working Check language detection priority
Cache issues Clear cache: markdownService.clearCache()

Debug Commands

// Check system status
console.log(docService.documentationStats());
console.log(navService.currentSection());
console.log(markdownService.getCacheStats());

// Verify file discovery
const exists = await docService.contentExists('/guide/feature', 'en');
const structure = await docService.scanDocumentationStructure('en');

📞 Support

For questions or issues with the enhanced documentation system:

  1. Check the Enhanced Documentation System Guide
  2. Review service APIs and interfaces
  3. Use built-in debugging tools
  4. Run yarn docs:scan to refresh structure

The new system provides a robust foundation for documentation management while maintaining flexibility for future growth and localization needs.