Skip to main content

Sphinx extension to build Notion pages.

Project description

Build Status codecov PyPI

Notion Builder for Sphinx

Extension for Sphinx which enables publishing documentation to Notion.

Installation

sphinx-notionbuilder is compatible with Python 3.11+.

$ pip install sphinx-notionbuilder

Add the following to conf.py to enable the extension:

"""Configuration for Sphinx."""

extensions = ["sphinx_notion"]

For collapsible sections (toggle blocks), also add the sphinx-toolbox collapse extension:

"""Configuration for Sphinx."""

extensions = [
    "sphinx_notion",
    "sphinx_toolbox.collapse",
]

For video support, also add the sphinxcontrib-video extension:

"""Configuration for Sphinx."""

extensions = [
    "sphinxcontrib.video",  # Must be before sphinx_notion
    "sphinx_notion",
]

For strikethrough text support, also add the sphinxnotes-strike extension:

"""Configuration for Sphinx."""

extensions = [
    "sphinxnotes.strike",  # Must be before sphinx_notion
    "sphinx_notion",
]

For audio support, also add the atsphinx-audioplayer extension:

"""Configuration for Sphinx."""

extensions = [
    "atsphinx.audioplayer",
    "sphinx_notion",
]

For TODO list support, also add the sphinx-immaterial task lists extension:

"""Configuration for Sphinx."""

extensions = [
    "sphinx_immaterial.task_lists",
    "sphinx_notion",
]

PDF support is included by default with the sphinx-notionbuilder extension.

Supported markup

The following syntax is supported:

  • Headers

  • Bulleted lists

  • TODO lists (with checkboxes)

  • Code blocks

  • Table of contents

  • Block quotes

  • All standard admonitions (note, warning, tip, attention, caution, danger, error, hint, important)

  • Collapsible sections (using sphinx-toolbox collapse directive)

  • Images (with URLs or local paths)

  • Videos (with URLs or local paths)

  • Audio (with URLs or local paths)

  • PDFs (with URLs or local paths)

  • Tables

  • Strikethrough text

  • Colored text

See a sample document source and the published Notion page.

Using Audio

Audio files can be embedded using the audio directive. Both remote URLs and local file paths are supported:

.. audio:: https://www.example.com/audio.mp3

.. audio:: _static/local-audio.mp3

The audio will be rendered as an audio player in the generated Notion page.

Using PDFs

PDF files can be embedded using the pdf-include directive. Both remote URLs and local file paths are supported.

.. pdf-include:: https://www.example.com/document.pdf

.. pdf-include:: _static/local-document.pdf

The PDF will be rendered as an embedded PDF viewer in the generated Notion page.

Using Colored Text

Colored text can be added using the sphinxcontrib-text-styles extension. First, install the extension:

$ pip install sphinxcontrib-text-styles

Then add it to your conf.py:

"""Configuration for Sphinx."""

extensions = [
    "sphinxcontrib_text_styles",
    "sphinx_notion",
]

You can then use colored text in your reStructuredText documents:

This is :text-red:`red text`, :text-blue:`blue text`, and :text-green:`green text`.

The following colors are supported: red, blue, green, yellow, orange, purple, pink, brown, and gray.

Using TODO Lists

TODO lists with checkboxes can be created using the sphinx-immaterial.task_lists extension. Both bulleted and numbered lists support checkboxes:

.. task-list::

    1. [x] Completed task
    2. [ ] Incomplete task
    3. [ ] Another task

* [x] Bulleted completed task
* [ ] Bulleted incomplete task

The checkboxes will be rendered as interactive TODO items in the generated Notion page, with completed tasks showing as checked and incomplete tasks as unchecked.

Unsupported Notion Block Types

  • Bookmark

  • Breadcrumb

  • Child database

  • Child page

  • Column and column list

  • Divider

  • Embed

  • Equation

  • File

  • Link preview

  • Mention

  • Synced block

  • Template

  • Heading with is_toggleable set to True

Uploading Documentation to Notion

After building your documentation with the Notion builder, you can upload it to Notion using the included command-line tool.

Prerequisites

  1. Create a Notion integration at https://www.notion.so/my-integrations

  2. Get your integration token and set it as an environment variable:

$ export NOTION_TOKEN="your_integration_token_here"

Usage

$ notion-upload -f path/to/output.json -p parent_page_id -t "Page Title"

Arguments:

  • --file: Path to the JSON file generated by the Notion builder

  • --parent-id: The ID of the parent page or database in Notion (must be shared with your integration)

  • --parent-type: “page” or “database”

  • --title: Title for the new page in Notion

The command will create a new page if one with the given title doesn’t exist, or update the existing page if one with the given title already exists.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

sphinx_notionbuilder-2025.10.3.tar.gz (43.2 kB view details)

Uploaded Source

Built Distribution

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

sphinx_notionbuilder-2025.10.3-py2.py3-none-any.whl (14.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file sphinx_notionbuilder-2025.10.3.tar.gz.

File metadata

  • Download URL: sphinx_notionbuilder-2025.10.3.tar.gz
  • Upload date:
  • Size: 43.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sphinx_notionbuilder-2025.10.3.tar.gz
Algorithm Hash digest
SHA256 20b688d5ecb6dcc39c0aeb7fce30a053b2f4691706f6fc8f2993938f13008191
MD5 282660bcf0ac3564f6b97df8641f300e
BLAKE2b-256 c171d8f75c3796a086f374347ffa4e5f7b4cda99c249a28df01bbf04f5ce1b77

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_notionbuilder-2025.10.3.tar.gz:

Publisher: release.yml on adamtheturtle/sphinx-notionbuilder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sphinx_notionbuilder-2025.10.3-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_notionbuilder-2025.10.3-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 49628ed888d67f9aca31b7e81697df00a017071893798450ef9b479b87dd82ea
MD5 377b9e5198c024cecc93d577316035e6
BLAKE2b-256 2707677a4ed73106d85675083d068d9e81ac068db943d37d8059bed9c92377e7

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_notionbuilder-2025.10.3-py2.py3-none-any.whl:

Publisher: release.yml on adamtheturtle/sphinx-notionbuilder

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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