How to Add Repositories to docs-ng
This guide explains how to add a new repository to the docs-ng aggregation system.
Source Repository: gardenlinux/docs-ng
Prerequisites
- Access to the repository you want to add
- Understanding of the repository's documentation structure
- Edit access to
repos-config.json
Step 1: Add Repository Configuration
Edit repos-config.json and add a new entry to the repos array:
{
"name": "new-repo",
"url": "https://github.com/gardenlinux/new-repo",
"docs_path": "docs",
"target_path": "projects/new-repo",
"ref": "main",
"structure": "flat"
}Required Fields
name: Unique identifier for the repositoryurl: Git URL orfile://path for local developmentdocs_path: Path to docs directory within the repositorytarget_path: Where to place mirrored docs (usuallyprojects/<name>)ref: Git branch or tag to fetch from
Optional Fields
commit: Lock to a specific commit hash for reproducibilityroot_files: List of root-level files to copy (e.g.,["README.md", "CONTRIBUTING.md"])structure: Directory mapping strategy (see below)media_directories: List of media directories to copy (e.g.,[".media", "_static", "assets"])
Step 2: Choose a Structure Strategy
Flat Structure
Copy all files as-is without reorganization:
"structure": "flat"Sphinx Structure
For Sphinx-generated documentation:
"structure": "sphinx"Custom Mapping
Map source directories to Diataxis categories:
"structure": {
"tutorials": "tutorials",
"guides": "how-to",
"concepts": "explanation",
"api": "reference"
}Step 3: Configure Targeted Documentation
To have files automatically placed into the main Diataxis structure, add github_target_path frontmatter to markdown files in the source repository:
---
title: "Example Guide"
github_target_path: "docs/how-to/example-guide.md"
---
# Example Guide
Content here...Files with github_target_path will be copied to that exact location, not to projects/<repo-name>/.
Step 4: Test with Local Configuration
Create or edit repos-config.local.json for local testing:
{
"repos": [
{
"name": "new-repo",
"url": "file://../new-repo",
"docs_path": "docs",
"target_path": "projects/new-repo",
"structure": "flat"
}
]
}Then test aggregation:
make aggregate-localStep 5: Verify the Output
Check that files are in the correct locations:
ls -la docs/projects/new-repo/If using github_target_path, verify targeted files:
ls -la docs/tutorials/
ls -la docs/how-to/Step 6: Lock the Commit (Production)
For production, lock to a specific commit:
# This fetches the latest and updates repos-config.json
make aggregate-update-repo REPO=new-repoOr manually add the commit hash:
{
"name": "new-repo",
"url": "https://github.com/gardenlinux/new-repo",
"docs_path": "docs",
"target_path": "projects/new-repo",
"ref": "main",
"commit": "abc123def456...",
"structure": "flat"
}Advanced Configuration
Media Directories
Automatically copy media directories alongside documentation:
{
"name": "new-repo",
"media_directories": [".media", "assets", "_static"]
}The system will:
- Find all instances of these directories recursively
- Copy nested media dirs (e.g.,
tutorials/assets/) to the same relative path - Copy root-level media dirs (e.g.,
_static/) to the common ancestor of targeted files
Root Files
Copy root-level files (like README.md or CONTRIBUTING.md):
{
"name": "new-repo",
"root_files": ["README.md", "CONTRIBUTING.md", "LICENSE"]
}These files can also have github_target_path frontmatter for targeted placement.
Special Files
Handle non-standard files:
{
"name": "new-repo",
"special_files": {
"GUIDE.md": "how-to",
"CONCEPTS.md": "explanation"
}
}Complete Example
Here's a complete configuration:
{
"name": "example-tool",
"url": "https://github.com/gardenlinux/example-tool",
"docs_path": "documentation",
"target_path": "projects/example-tool",
"ref": "docs-ng",
"commit": "1234567890abcdef",
"root_files": ["README.md"],
"structure": {
"getting-started": "tutorials",
"guides": "how-to",
"concepts": "explanation",
"api-reference": "reference"
},
"media_directories": [".media", "images"],
"special_files": {
"CHANGELOG.md": "reference"
}
}Troubleshooting
Files Not Appearing
- Verify
docs_pathpoints to the correct directory - Check that the repository has a
docs-ngbranch or adjustref - Ensure
github_target_pathfrontmatter is correct
Media Not Copied
- Add media directory names to
media_directories - Check that media dirs exist in the source repository
Links Broken
- The transformer attempts to rewrite links automatically
- Check that relative links in source docs are correct
- Review
src/aggregation/transformer.pyfor link rewriting logic
See Also
- Configuration Reference — Complete field documentation
- Architecture Explanation — How aggregation works
- Technical Reference — Source code documentation