Skip to main content

Syncs GitHub Markdown files to Notion

Project description

Git Notion

Syncs Github markdown files in your repository to Notion.

This utility is described in the following blog post.

See example Notion page.

Installation

pip install git-notion
pip install notion-cobertos-fork # IMPORTANT due to a md2notion notion-py dependency. Order also matters

or for local installation:

git clone https://github.com/Harbor-Systems/git-notion.git
cd git-notion
pip install -e .

Configuring

NOTION_TOKEN_V2 - Can be found in your browser cookies for Notion's website.
NOTION_ROOT_PAGE - URL for notion page. Repo docs will be a new page under this page.
NOTION_EXCLUDE_REGEX - Regex for paths to ignore.
NOTION_INCLUDE_REGEX - Regex for paths to include.
NOTION_CONFIG_PATH - Path to the setup.cfg file.

These environment variables can be set.

export NOTION_TOKEN_V2=<YOUR_TOKEN>
export NOTION_ROOT_PAGE="https://www.notion.so/..."  # Can be in setup.cfg as well
export NOTION_IGNORE_REGEX="(?i)(vendor\/.*\.md|deleteme\.md)" # Can be in setup.cfg as well
export NOTION_INCLUDE_REGEX="(?i)(docs\/.*\.md|readme\.md)" # Can be in setup.cfg as well
export NOTION_CONFIG_PATH="docs/"

These parameters can be set in the setup.cfg for the repo.

[git-notion]
ignore_regex = models/.*
include_regex = docs/.*
notion_root_page = https://www.notion.so/...

Running Locally

  1. Set up a virtual environment
python3 -m pip install virtualenv # only do this the first time
  1. Create a virtual environment
python3 -m virtualenv venv
  1. Activate the virtual environment
source venv/bin/activate
  1. Install the dependencies
python3 -m pip install -r requirements.in
  1. Set any environment variables and run the command
export NOTION_TOKEN_V2=<...>
export NOTION_ROOT_PAGE="https://www.notion.so/..."
python3 git-notion-pretty/cli.py [options]

Usage

# To upload your current directory
git-notion-pretty

# To upload to a different directory name
git-notion-pretty --dir-name="Application Docs"

# To use a flat structure instead of the nested structure
git-notion-pretty --page-structure=flat

# To use the file name instead searching for and using the H1 header on the first line
git-notion-pretty --use-file-name

Pushing to PYPI

python3 -m bumpversion patch   # Look-up bumpversion
rm -rf dist/
python3 setup.py sdist bdist_wheel
python3 -m twine upload dist/*

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

git_notion_pretty-1.0.4.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

git_notion_pretty-1.0.4-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2Python 3

File details

Details for the file git_notion_pretty-1.0.4.tar.gz.

File metadata

  • Download URL: git_notion_pretty-1.0.4.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for git_notion_pretty-1.0.4.tar.gz
Algorithm Hash digest
SHA256 43bbbb33167fe55b4e6988ae2741da38db97b177d3b41f6cef1eee62e4a5022b
MD5 6c516e951cc7d3b60936d240a68ab4a6
BLAKE2b-256 9546eea183b49dfba69540fa1d788a614101c85ec9057fabe7bbaa6bc9c3de5d

See more details on using hashes here.

File details

Details for the file git_notion_pretty-1.0.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for git_notion_pretty-1.0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 7cd33e89ca471208338af94459b59034929b64111162aabd6042ca542e134d45
MD5 b7f2d7dfa31dbe7142b908ff1ed3598a
BLAKE2b-256 f4bb8b32d7aa7358f8c309cb1ee212a22e348449238b51cd3c0e283fbd30feea

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