Local Documentation Testing
This guide shows how to test your documentation locally before deploying to GitHub Pages using containerized environments that don't affect your system.
Quick Start - Containerized Testingโ
DocuMCP automatically generates a containerized testing environment that requires only Docker or Podman:
# Run the containerized testing script
./test-docs-local.sh
This script will:
- Detect your container runtime (Podman or Docker)
- Build a documentation container
- Check for broken links in your documentation
- Serve the documentation at http://localhost:3001
Prerequisitesโ
You need either Docker or Podman installed:
Option 1: Podman (rootless, more secure)
# macOS
brew install podman
# Ubuntu/Debian
sudo apt-get install podman
# RHEL/CentOS/Fedora
sudo dnf install podman
Option 2: Docker
# macOS
brew install docker
# Or download from: https://docs.docker.com/get-docker/
Container-Based Testing Methodsโ
Method 1: Using the Generated Script (Recommended)โ
# Simple one-command testing
./test-docs-local.sh
Method 2: Using Docker Composeโ
# Build and run with Docker Compose
docker-compose -f docker-compose.docs.yml up --build
# Or with Podman Compose
podman-compose -f docker-compose.docs.yml up --build
Method 3: Manual Container Commandsโ
# Build the container
docker build -f Dockerfile.docs -t documcp-docs .
# or: podman build -f Dockerfile.docs -t documcp-docs .
# Run the container
docker run --rm -p 3001:3001 documcp-docs
# or: podman run --rm -p 3001:3001 documcp-docs
Method 4: Legacy Local Installation (Not Recommended)โ
If you prefer to install dependencies locally (affects your system):
cd docs-site
npm install
npm run build
npm run serve
Verification Checklistโ
โ Content Verificationโ
- All pages load without errors
- Navigation works correctly
- Links between pages function properly
- Search functionality works (if enabled)
- Code blocks render correctly with syntax highlighting
- Images and assets load properly
โ Structure Verificationโ
- Sidebar navigation reflects your documentation structure
- Categories and sections are properly organized
- Page titles and descriptions are accurate
- Breadcrumb navigation works
- Footer links are functional
โ Content Qualityโ
- No broken internal links
- No broken external links
- Code examples are up-to-date
- Screenshots are current and clear
- All content follows Diataxis framework principles
โ Performance Testingโ
- Pages load quickly (< 3 seconds)
- Search is responsive
- No console errors in browser developer tools
- Mobile responsiveness works correctly
Troubleshooting Common Issuesโ
Container Build Failuresโ
Problem: Container build fails
Solutions:
# Clean up any existing containers and images
docker system prune -f
# or: podman system prune -f
# Rebuild from scratch
docker build --no-cache -f Dockerfile.docs -t documcp-docs .
# or: podman build --no-cache -f Dockerfile.docs -t documcp-docs .
# Check for syntax errors in markdown files
find docs -name "*.md" -exec npx markdownlint {} \;
Container Runtime Issuesโ
Problem: "Neither Podman nor Docker found"
Solutions:
# Check if Docker/Podman is installed and running
docker --version
podman --version
# On macOS, ensure Docker Desktop is running
# On Linux, ensure Docker daemon is started:
sudo systemctl start docker
# For Podman on macOS, start the machine:
podman machine start
Broken Linksโ
Problem: Links between documentation pages don't work
Solutions:
- Check that file paths in your markdown match actual file locations
- Ensure relative links use correct syntax:
[text](../other-page.md)
- Verify that
sidebars.js
references match actual file names
Missing Pagesโ
Problem: Some documentation pages don't appear in navigation
Solutions:
- Update
docs-site/sidebars.js
to include new pages - Ensure files are in the correct directory structure
- Check that frontmatter is properly formatted
Styling Issuesโ
Problem: Documentation doesn't look right
Solutions:
- Check
docs-site/src/css/custom.css
for custom styles - Verify Docusaurus theme configuration
- Clear browser cache and reload
Link Checkingโ
Automated Link Checkingโ
DocuMCP provides built-in link checking:
# Check all links
npm run docs:check-links
# Check only external links
npm run docs:check-links:external
# Check only internal links
npm run docs:check-links:internal
Manual Link Checkingโ
Use markdown-link-check for comprehensive link validation:
# Install globally
npm install -g markdown-link-check
# Check specific file
markdown-link-check docs/index.md
# Check all markdown files
find docs -name "*.md" -exec markdown-link-check {} \;
Container Configuration Testingโ
Verify Container Configurationโ
# Test container health
docker ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
# or: podman ps --format "table {{.Names}}\t{{.Status}}\t{{.Ports}}"
# Check container logs
docker logs documcp-docs-test
# or: podman logs documcp-docs-test
# Execute commands inside running container
docker exec -it documcp-docs-test sh
# or: podman exec -it documcp-docs-test sh
Test Different Container Environmentsโ
# Test production build in container
docker run --rm -e NODE_ENV=production -p 3001:3001 documcp-docs
# Interactive debugging mode
docker run --rm -it --entrypoint sh documcp-docs
# Inside container: cd docs-site && npm run build --verbose
Deployment Previewโ
Before deploying to GitHub Pages, test with production settings:
# Build with production configuration
npm run build
# Serve the production build locally
npm run serve
This simulates exactly what GitHub Pages will serve.
Integration with Development Workflowโ
Pre-commit Testingโ
Add documentation testing to your git hooks:
# .husky/pre-commit
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"
# Run documentation tests
./test-docs-local.sh --build-only
# Run your regular tests
npm test
CI/CD Integrationโ
Add documentation testing to your GitHub Actions:
# .github/workflows/docs-test.yml
name: Documentation Tests
on:
pull_request:
paths:
- "docs/**"
- "docs-site/**"
jobs:
test-docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
cache: "npm"
cache-dependency-path: "docs-site/package-lock.json"
- name: Test documentation build
run: ./test-docs-local.sh --build-only
Advanced Testingโ
Performance Testingโ
# Install lighthouse CLI
npm install -g lighthouse
# Test performance of local documentation
lighthouse http://localhost:3001 --output=json --output-path=./lighthouse-report.json
# Check specific performance metrics
lighthouse http://localhost:3001 --only-categories=performance
Accessibility Testingโ
# Test accessibility
lighthouse http://localhost:3001 --only-categories=accessibility
# Use axe for detailed accessibility testing
npm install -g axe-cli
axe http://localhost:3001
SEO Testingโ
# Test SEO optimization
lighthouse http://localhost:3001 --only-categories=seo
# Check meta tags and structure
curl -s http://localhost:3001 | grep -E "<title>|<meta"
Automated Testing Scriptโ
Create a comprehensive test script:
#!/bin/bash
# comprehensive-docs-test.sh
echo "๐งช Running comprehensive documentation tests..."
# Build test
echo "๐ฆ Testing build..."
cd docs-site && npm run build
# Link checking
echo "๐ Checking links..."
cd .. && npm run docs:check-links:all
# Performance test (if lighthouse is available)
if command -v lighthouse &> /dev/null; then
echo "โก Testing performance..."
cd docs-site && npm run serve &
SERVER_PID=$!
sleep 5
lighthouse http://localhost:3001 --quiet --only-categories=performance
kill $SERVER_PID
fi
echo "โ
All tests completed!"
Best Practicesโ
1. Test Early and Oftenโ
- Test after every significant documentation change
- Include documentation testing in your regular development workflow
- Set up automated testing in CI/CD pipelines
2. Test Different Scenariosโ
- Test with different screen sizes and devices
- Test with JavaScript disabled
- Test with slow internet connections
3. Monitor Performanceโ
- Keep an eye on build times
- Monitor page load speeds
- Check for large images or files that slow down the site
4. Validate Content Qualityโ
- Use spell checkers and grammar tools
- Ensure code examples work and are current
- Verify that external links are still valid
By following this guide, you can ensure your documentation works perfectly before deploying to GitHub Pages, providing a better experience for your users and avoiding broken deployments.