Metadata-Version: 2.4
Name: notion-git-sync
Version: 0.1.3
Summary: Synchronize Notion pages to markdown files with frontmatter support
Author-email: Joe Southin <joe.southin@gmail.com>
License: MIT
Project-URL: Homepage, https://github.com/jsouthin/notion-git-sync
Project-URL: Repository, https://github.com/jsouthin/notion-git-sync.git
Project-URL: Documentation, https://github.com/jsouthin/notion-git-sync#readme
Keywords: notion,markdown,documentation,sync
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Topic :: Documentation
Classifier: Topic :: Software Development :: Documentation
Classifier: Topic :: Text Processing :: Markup
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: notion-client>=2.0.0
Requires-Dist: pyyaml>=6.0.0
Provides-Extra: test
Requires-Dist: pytest>=7.0.0; extra == "test"
Requires-Dist: pytest-cov>=4.0.0; extra == "test"
Provides-Extra: dev
Requires-Dist: black>=23.0.0; extra == "dev"
Requires-Dist: isort>=5.0.0; extra == "dev"
Requires-Dist: flake8>=6.0.0; extra == "dev"
Dynamic: license-file

# Notion Git Sync

Synchronize Notion pages to markdown files with frontmatter support.

## Features
- Converts Notion pages to markdown
- Supports YAML frontmatter
- Handles nested content
- Git integration
- Rich block type support
- Automatic change detection
- GitHub Actions integration

## Installation
```bash
pip install notion-git-sync
```

## Usage

### As a Python Library (Recommended)
```python
from notion_git_sync.sync import NotionSync, Config

# Create config from environment variables
config = Config.from_env()
# Or create config manually
config = Config(
    notion_client=notion_client,
    parent_ids=["page_id_1", "page_id_2"],
    output_dir="path/to/output",
    required_frontmatter={"title", "owner"}
)

# Initialize and run sync
syncer = NotionSync(config)
changed_files = syncer.sync()  # Returns list of changed files
```

### As a Command Line Tool
The package includes a CLI script for simple use cases:

```bash
# Set environment variables
export NOTION_TOKEN="your_notion_token"
export NOTION_PARENT_IDS="page_id_1,page_id_2"

# Run the sync
python -m notion_git_sync.sync
```

### GitHub Actions Integration
The package includes a GitHub Actions workflow for automated syncing:

```yaml
name: notion-sync
on:
  schedule: [{ cron: '5 2 * * *' }]  # nightly 02:05 UTC
  workflow_dispatch:

jobs:
  sync:
    runs-on: ubuntu-latest
    env:
      NOTION_TOKEN: ${{ secrets.NOTION_TOKEN }}
      NOTION_PARENT_IDS: ${{ secrets.NOTION_PARENT_IDS }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v5
      - run: pip install notion-git-sync
      - run: python -m notion_git_sync.sync
```

## Configuration

### Environment Variables
- `NOTION_TOKEN`: Your Notion integration token
- `NOTION_PARENT_IDS`: Comma-separated list of parent page IDs

### Config Object
The `Config` class accepts the following parameters:
- `notion_client`: A configured Notion client instance
- `parent_ids`: List of Notion page IDs to sync
- `output_dir`: Directory where markdown files will be saved
- `required_frontmatter`: Set of required frontmatter fields

## Development
```bash
# Install development dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/
```

## License
MIT
