Configurable Docs Directory System

Complete guide to configuring and using the new configurable docs directory system with automatic discovery

๐Ÿ“ Configurable Docs Directory System

The docs-angular system now supports configurable documentation directory locations with optional automatic discovery. This allows you to place your documentation files anywhere in your project and configure the system to find them automatically.

๐ŸŽฏ What's New

โœ… Configurable Paths

โœ… Automatic Discovery

โœ… Backward Compatibility


๐Ÿš€ Quick Start

1. Basic Configuration

Create or update apps/docs-angular/src/assets/docs-config.json:

{
  "docsPath": "assets/docs",
  "autoDiscovery": false,
  "docsDirectoryName": "docs",
  "recursiveSearch": true,
  "maxSearchDepth": 3,
  "fallbackPaths": [
    "assets/docs",
    "docs",
    "content/docs",
    "documentation"
  ]
}

2. Enable Auto-Discovery

To enable automatic docs directory discovery:

{
  "docsPath": "assets/docs",
  "autoDiscovery": true,
  "docsDirectoryName": "docs",
  "recursiveSearch": true,
  "maxSearchDepth": 3,
  "fallbackPaths": [
    "assets/docs",
    "docs",
    "content/docs",
    "documentation",
    "src/docs",
    "app/docs",
    "libs/docs"
  ]
}

3. Build and Run

The system automatically configures itself during build:

# Build with configurable paths
nx build docs-angular

# Or serve with auto-configuration
nx serve docs-angular

๐Ÿ“‹ Configuration Options

Core Settings

Property Type Default Description
docsPath string "assets/docs" Primary docs directory path
autoDiscovery boolean false Enable automatic directory discovery
docsDirectoryName string "docs" Directory name to search for
recursiveSearch boolean true Search subdirectories recursively
maxSearchDepth number 3 Maximum search depth for recursion
fallbackPaths string[] ["assets/docs", "docs", ...] Fallback paths to try

Advanced Configuration

{
  "docsPath": "content/documentation",
  "autoDiscovery": true,
  "docsDirectoryName": "docs",
  "recursiveSearch": true,
  "maxSearchDepth": 5,
  "fallbackPaths": [
    "content/documentation",
    "docs",
    "documentation",
    "src/docs",
    "app/docs",
    "libs/docs",
    "packages/docs",
    "content/docs"
  ],
  "description": "Custom docs configuration for multi-package project",
  "version": "1.0.0"
}

๐Ÿ” Auto-Discovery System

How It Works

The auto-discovery system uses multiple strategies to find documentation directories:

  1. Fallback Path Testing - Tests configured fallback paths
  2. Recursive Search - Searches subdirectories for docs folders
  3. Manifest Detection - Looks for docs-manifest.json files
  4. Structure Validation - Validates expected docs structure
  5. Confidence Scoring - Rates discovery results

Discovery Process

// Example discovery result
{
  path: "content/docs",
  confidence: 0.95,
  reason: "Found docs-manifest.json and expected structure",
  alternatives: [
    "docs",
    "documentation"
  ]
}

Confidence Levels


๐Ÿ“ Directory Structure Examples

Example 1: Root-Level Docs

project-root/
โ”œโ”€โ”€ docs/                    โ† Docs directory
โ”‚   โ”œโ”€โ”€ english/
โ”‚   โ”‚   โ””โ”€โ”€ public/
โ”‚   โ”‚       โ””โ”€โ”€ documentation/
โ”‚   โ””โ”€โ”€ spanish/
โ”‚       โ””โ”€โ”€ public/
โ”‚           โ””โ”€โ”€ documentacion/
โ”œโ”€โ”€ src/
โ””โ”€โ”€ package.json

Configuration:

{
  "docsPath": "docs",
  "autoDiscovery": true
}

Example 2: Content Directory

project-root/
โ”œโ”€โ”€ content/
โ”‚   โ””โ”€โ”€ documentation/       โ† Docs directory
โ”‚       โ”œโ”€โ”€ english/
โ”‚       โ””โ”€โ”€ spanish/
โ”œโ”€โ”€ src/
โ””โ”€โ”€ package.json

Configuration:

{
  "docsPath": "content/documentation",
  "autoDiscovery": true
}

Example 3: Multi-Package Structure

project-root/
โ”œโ”€โ”€ packages/
โ”‚   โ”œโ”€โ”€ docs-package/
โ”‚   โ”‚   โ””โ”€โ”€ docs/           โ† Docs directory
โ”‚   โ””โ”€โ”€ other-package/
โ”œโ”€โ”€ src/
โ””โ”€โ”€ package.json

Configuration:

{
  "docsPath": "packages/docs-package/docs",
  "autoDiscovery": true,
  "fallbackPaths": [
    "packages/docs-package/docs",
    "docs",
    "content/docs"
  ]
}

๐Ÿ”ง Build System Integration

Automatic Configuration

The build system automatically configures paths based on your settings:

  1. Configuration Loading - Reads docs-config.json
  2. Path Updates - Updates project.json assets configuration
  3. Script Updates - Modifies manifest generation scripts
  4. Environment Generation - Creates TypeScript environment config

Build Targets

{
  "targets": {
    "configure-docs-path": {
      "executor": "nx:run-commands",
      "options": {
        "command": "node apps/docs-angular/scripts/configure-docs-path.js"
      }
    },
    "build": {
      "dependsOn": [
        "configure-docs-path",
        "generate-manifest",
        "generate-folders-config"
      ]
    }
  }
}

Manual Configuration

You can also run the configuration script manually:

# Configure with default config file
node apps/docs-angular/scripts/configure-docs-path.js

# Configure with custom config file
node apps/docs-angular/scripts/configure-docs-path.js custom-config.json

๐Ÿ› ๏ธ Service Integration

Path Resolution Service

All services now use the PathResolutionService for dynamic path resolution:

// Before (hardcoded)
const manifestPath = '/assets/docs/docs-manifest.json';

// After (configurable)
const manifestPath = this.pathResolution.resolveManifestPath();

Updated Services

Configuration Service

The DocsConfigService provides centralized configuration management:

// Get effective docs path
const docsPath = this.docsConfig.effectiveDocsPath();

// Update configuration
this.docsConfig.updateConfig({
  docsPath: 'new/path',
  autoDiscovery: true
});

// Run auto-discovery
const result = await this.docsConfig.discoverDocsDirectory();

๐Ÿงช Testing Different Configurations

Test 1: Move Docs to Root

  1. Move files:

    mv apps/docs-angular/src/assets/docs ./docs
    
  2. Update config:

    {
      "docsPath": "docs",
      "autoDiscovery": true
    }
    
  3. Build and test:

    nx build docs-angular
    nx serve docs-angular
    

Test 2: Custom Directory Name

  1. Rename directory:

    mv docs documentation
    
  2. Update config:

    {
      "docsPath": "documentation",
      "autoDiscovery": true,
      "docsDirectoryName": "documentation"
    }
    

Test 3: Nested Structure

  1. Create nested structure:

    mkdir -p content/docs
    mv docs/* content/docs/
    
  2. Update config:

    {
      "docsPath": "content/docs",
      "autoDiscovery": true
    }
    

๐Ÿ” Debugging and Troubleshooting

Configuration Debugging

Check the browser console for configuration logs:

๐Ÿ“ Docs configuration updated: { docsPath: "docs", autoDiscovery: true }
๐ŸŽฏ Docs directory discovered: { path: "docs", confidence: 0.95 }
โœ… Docs system initialized with configurable paths
๐Ÿ“ Effective docs path: docs
๐Ÿ“„ Manifest path: docs/docs-manifest.json

Common Issues

Issue 1: Docs Not Found

Problem: System can't find documentation files

Solutions:

  1. Check docsPath configuration
  2. Verify directory structure
  3. Enable auto-discovery
  4. Check fallback paths

Issue 2: Auto-Discovery Fails

Problem: Auto-discovery returns low confidence

Solutions:

  1. Ensure docs-manifest.json exists
  2. Check directory structure matches expected format
  3. Increase maxSearchDepth
  4. Add more fallback paths

Issue 3: Build Errors

Problem: Build fails with path errors

Solutions:

  1. Run configure-docs-path script manually
  2. Check project.json assets configuration
  3. Verify all required files exist
  4. Check file permissions

Debug Commands

# Check configuration
node -e "console.log(require('./apps/docs-angular/src/assets/docs-config.json'))"

# Test path resolution
node apps/docs-angular/scripts/configure-docs-path.js --debug

# Validate directory structure
find . -name "docs-manifest.json" -type f

๐Ÿš€ Migration Guide

From Hardcoded to Configurable

Step 1: Create Configuration

Create apps/docs-angular/src/assets/docs-config.json:

{
  "docsPath": "assets/docs",
  "autoDiscovery": false
}

Step 2: Test Current Setup

nx build docs-angular
nx serve docs-angular

Step 3: Move Documentation

# Move to new location
mv apps/docs-angular/src/assets/docs ./docs

# Update configuration
echo '{"docsPath": "docs", "autoDiscovery": true}' > apps/docs-angular/src/assets/docs-config.json

Step 4: Rebuild and Test

nx build docs-angular
nx serve docs-angular

Gradual Migration

You can migrate gradually by:

  1. Start with default config - Keep existing structure
  2. Enable auto-discovery - Let system find docs automatically
  3. Move docs gradually - Move sections one at a time
  4. Update config - Adjust configuration as needed

๐Ÿ“Š Performance Considerations

Auto-Discovery Performance

Path Resolution Performance

Build Performance


๐Ÿ”ฎ Future Enhancements

Planned Features

  1. Dynamic Configuration - Change paths at runtime
  2. Multiple Docs Sources - Support multiple docs directories
  3. Cloud Integration - Auto-discovery from cloud storage
  4. Configuration UI - Web-based configuration interface
  5. Path Validation - Real-time path validation and testing

Advanced Discovery

  1. Git Integration - Discover docs based on git history
  2. Package Analysis - Auto-detect docs from package.json
  3. Symlink Support - Follow symlinks for discovery
  4. Remote Discovery - Discover docs from remote repositories

๐Ÿ“ž Support and Resources

Documentation

Community

Tools


๐ŸŽ‰ Summary

The configurable docs directory system provides:

โœ… Flexibility - Place docs anywhere in your project
โœ… Automation - Automatic discovery with confidence scoring
โœ… Compatibility - Backward compatible with existing setups
โœ… Performance - Optimized path resolution and caching
โœ… Maintainability - Centralized configuration management

Get started today by creating your docs-config.json file and enabling auto-discovery!


This system is maintained by the GoGrab Development Team and is updated regularly with new features and improvements.