Skip to main content

CLI tool for syncing documentation from multiple repositories for Docusaurus

Project description

๐Ÿ“š DocuSync

Effortlessly sync documentation from multiple repositories into your Docusaurus site

Python Version License: MIT Code style: black

Features โ€ข Installation โ€ข Quick Start โ€ข Usage โ€ข Configuration


๐ŸŽฏ Overview

DocuSync is a powerful CLI tool designed specifically for Docusaurus projects that need to aggregate documentation from multiple GitHub repositories. It automatically clones, organizes, and generates the proper category structure for your multi-repository documentation setup.

Perfect for:

  • ๐Ÿข Microservices architectures - Centralize docs from multiple services
  • ๐Ÿ“ฆ Monorepo projects - Sync docs from different packages
  • ๐Ÿ”ง SDK ecosystems - Aggregate documentation from multiple SDKs
  • ๐ŸŒ Multi-team projects - Combine docs from different teams

โœจ Features

  • ๐Ÿš€ Fast & Efficient - Shallow cloning with configurable depth
  • ๐ŸŽจ Docusaurus Integration - Auto-generates _category_.json files
  • ๐Ÿ“‹ Multi-Repository Support - Sync from unlimited GitHub repositories
  • ๐Ÿ”ง Flexible Configuration - JSON-based configuration with validation
  • ๐Ÿ“Š Beautiful Output - Rich console interface with progress indicators
  • ๐Ÿงน Clean & Safe - Automatic cleanup of temporary files
  • โœ… Type-Safe - Built with Pydantic for robust configuration
  • ๐ŸŽฏ Selective Sync - Sync all repos or just one
  • ๐Ÿ”จ MD/MDX Fixer - Automatically fix common Markdown/MDX issues that cause Docusaurus build failures

๐Ÿ“ฆ Installation

Using uv (Recommended)

uv add docusync

Using pip

pip install docusync

For Development

git clone https://github.com/Roman505050/docusync.git
cd docusync
uv sync --all-groups

๐Ÿš€ Quick Start

  1. Initialize configuration
docusync init
  1. Edit docusync.json with your repositories

  2. Sync your documentation

docusync sync
  1. Run Docusaurus
npm run start

That's it! Your documentation is now synced and ready to go! ๐ŸŽ‰

๐Ÿ“– Usage

Sync All Repositories

docusync sync

With verbose output:

docusync sync -v

Keep temporary files for debugging:

docusync sync --no-cleanup

Automatically fix MD/MDX issues after sync:

docusync sync --fix-md

Sync Single Repository

docusync sync-one <repository-name>

Example:

docusync sync-one api-gateway

With automatic MD/MDX fixing:

docusync sync-one api-gateway --fix-md

Fix Markdown/MDX Files

Fix common MDX/Markdown issues that cause Docusaurus build failures:

# Fix all .md files in a directory
docusync fix docs/

# Fix a single file
docusync fix docs/my-file.md

# Preview changes without applying them
docusync fix docs/ --dry-run

# Fix only files in the target directory (non-recursive)
docusync fix docs/ --no-recursive

What the fixer fixes:

  • โŒ Invalid JSX tag names (e.g., <1something> โ†’ &lt;1something&gt;)
  • โŒ HTML comments in MDX context (e.g., <!-- comment --> โ†’ {/* comment */})
  • โŒ Unclosed void elements (e.g., <br> โ†’ <br />)
  • โŒ Invalid HTML attributes (e.g., class= โ†’ className=, for= โ†’ htmlFor=)
  • โŒ Self-closing tag spacing (e.g., <tag/> โ†’ <tag />)
  • โŒ Malformed numeric entities (e.g., &#123 โ†’ &#123;)

List Configured Repositories

docusync list

Initialize Configuration

docusync init

With custom config path:

docusync init -c custom-config.json

โš™๏ธ Configuration

Basic Configuration

Create a docusync.json file in your Docusaurus project root:

{
  "repositories": [
    {
      "github_path": "acme-corp/api-gateway",
      "docs_path": "docs",
      "display_name": "API Gateway",
      "position": 1,
      "description": "Central API gateway documentation"
    },
    {
      "github_path": "acme-corp/user-service",
      "docs_path": "documentation",
      "display_name": "User Service",
      "position": 2,
      "description": "User management and authentication service"
    },
    {
      "github_path": "acme-corp/payment-processor",
      "docs_path": "docs",
      "display_name": "Payment Processor",
      "position": 3,
      "description": "Payment processing and billing documentation"
    }
  ],
  "paths": {
    "temp_dir": ".temp-repos",
    "docs_dir": "docs"
  },
  "git": {
    "clone_depth": 1,
    "default_branches": ["main", "master"]
  }
}

Configuration Options

repositories (required)

Array of repositories to sync:

Field Type Description
github_path string GitHub repository path (owner/repo)
docs_path string Path to documentation within the repository
display_name string Display name for the category
position integer Sidebar position (must be unique)
description string Category description for Docusaurus

paths (required)

Field Type Description
temp_dir string Directory for temporary clones (auto-deleted)
docs_dir string Target directory for documentation

git (required)

Field Type Description
clone_depth integer Git clone depth (1 for shallow clone)
default_branches array Default branches to try cloning

๐ŸŽจ Docusaurus Integration

Automatic _category_.json Generation

DocuSync automatically creates _category_.json files in each synced documentation directory, following the Docusaurus category format:

{
  "label": "API Gateway",
  "position": 1,
  "link": {
    "type": "generated-index",
    "description": "Central API gateway documentation"
  }
}

This enables Docusaurus to:

  • โœ… Automatically generate index pages for each category
  • โœ… Properly order documentation in the sidebar
  • โœ… Display category descriptions on index pages
  • โœ… Create a beautiful, organized documentation structure

Project Structure After Sync

your-docusaurus-project/
โ”œโ”€โ”€ docusaurus.config.js
โ”œโ”€โ”€ docusync.json
โ”œโ”€โ”€ docs/
โ”‚   โ”œโ”€โ”€ api-gateway/
โ”‚   โ”‚   โ”œโ”€โ”€ _category_.json      # Auto-generated โœจ
โ”‚   โ”‚   โ”œโ”€โ”€ intro.md
โ”‚   โ”‚   โ”œโ”€โ”€ getting-started.md
โ”‚   โ”‚   โ””โ”€โ”€ api-reference.md
โ”‚   โ”œโ”€โ”€ user-service/
โ”‚   โ”‚   โ”œโ”€โ”€ _category_.json      # Auto-generated โœจ
โ”‚   โ”‚   โ”œโ”€โ”€ overview.md
โ”‚   โ”‚   โ””โ”€โ”€ configuration.md
โ”‚   โ””โ”€โ”€ payment-processor/
โ”‚       โ”œโ”€โ”€ _category_.json      # Auto-generated โœจ
โ”‚       โ”œโ”€โ”€ setup.md
โ”‚       โ””โ”€โ”€ webhooks.md
โ””โ”€โ”€ .temp-repos/                 # Cleaned up after sync

๐Ÿ” Real-World Example

Here's a complete workflow for a microservices documentation setup:

# 1. Initialize your Docusaurus project
npx create-docusaurus@latest my-docs classic

# 2. Navigate to your project
cd my-docs

# 3. Initialize DocuSync
docusync init

# 4. Configure your repositories in docusync.json
cat > docusync.json << 'EOF'
{
  "repositories": [
    {
      "github_path": "your-org/auth-service",
      "docs_path": "docs",
      "display_name": "Authentication Service",
      "position": 1,
      "description": "User authentication and authorization"
    },
    {
      "github_path": "your-org/billing-service",
      "docs_path": "docs",
      "display_name": "Billing Service",
      "position": 2,
      "description": "Payment processing and billing management"
    }
  ],
  "paths": {
    "temp_dir": ".temp-repos",
    "docs_dir": "docs"
  },
  "git": {
    "clone_depth": 1,
    "default_branches": ["main", "master"]
  }
}
EOF

# 5. Sync documentation
docusync sync -v

# 6. Start Docusaurus
npm run start

๐Ÿ› ๏ธ Development

Setup Development Environment

# Clone the repository
git clone https://github.com/Roman505050/docusync.git
cd docusync

# Install dependencies
uv sync --all-groups

Code Quality

# Format code
uv run black src/
uv run isort src/

# Lint
uv run flake8 src/

# Type check
uv run mypy src/

Running Tests

# Run all tests
uv run pytest

# With coverage
uv run pytest --cov=docusync --cov-report=html

๐Ÿ“‹ Requirements

  • Python 3.12 or higher
  • Git with SSH access to GitHub repositories
  • Docusaurus 2.x or higher (for the target project)

๐Ÿค Contributing

Contributions are welcome! Here's how you can help:

  1. ๐Ÿด Fork the repository
  2. ๐Ÿ”ง Create a feature branch (git checkout -b feature/amazing-feature)
  3. โœ… Commit your changes (git commit -m 'Add amazing feature')
  4. ๐Ÿ“ค Push to the branch (git push origin feature/amazing-feature)
  5. ๐ŸŽ‰ Open a Pull Request

Please make sure to:

  • Add tests for new features
  • Update documentation as needed
  • Follow the existing code style
  • Run linters before submitting

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Click - Beautiful CLI framework
  • Rich - Rich text and formatting in the terminal
  • Pydantic - Data validation using Python type hints
  • Docusaurus - The documentation framework this tool was built for

๐Ÿ“ง Support

๐ŸŒŸ Show Your Support

If you find DocuSync helpful, please consider giving it a โญ๏ธ on GitHub!


Made with โค๏ธ for the Docusaurus community

Report Bug โ€ข Request Feature

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

docusync-2.0.0.tar.gz (40.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

docusync-2.0.0-py3-none-any.whl (19.6 kB view details)

Uploaded Python 3

File details

Details for the file docusync-2.0.0.tar.gz.

File metadata

  • Download URL: docusync-2.0.0.tar.gz
  • Upload date:
  • Size: 40.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for docusync-2.0.0.tar.gz
Algorithm Hash digest
SHA256 c8bef9af1d5653bac0da5f2e436caef484070ef7cbbb8a6c3152a46dbe8e989a
MD5 df443edc6ead825700f99e6daaaf63fd
BLAKE2b-256 ce14a8fb75800d7b26e860c16d94c6e4683d5b66cd92ad4124c7637c0e6291e5

See more details on using hashes here.

File details

Details for the file docusync-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: docusync-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.13 {"installer":{"name":"uv","version":"0.9.13"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for docusync-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6017c18f48076bc469f3a784c1e2dfee7a5137954f3e0bc5f2dec6bff9833aaa
MD5 689b8fd3c66204fa045d86a6589b65f1
BLAKE2b-256 297eecf0da90133fb73600b7bd1cb6f6a4b8018f209a5fc6c9239471cb7206a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page