Skip to main content

MkDocs plugin to publish documentation to SharePoint

Project description

MkDocs SharePoint Plugin

A MkDocs plugin that automatically publishes your built documentation site to SharePoint Online.

Features

  • Automatic publishing - Upload the MkDocs site_dir output to SharePoint during mkdocs build
  • Folder structure preservation - Maintains subdirectories when uploading to a document library
  • App-based authentication - Uses Microsoft Entra app credentials (client ID/secret)
  • Flexible configuration - Config values with environment variable fallbacks
  • Dry-run mode - Test your configuration without publishing
  • Debug mode - Detailed logging for troubleshooting
  • Retry support - Exponential backoff for transient SharePoint API failures

Installation

Install from Source

pip install .

Development Installation

pip install -e ".[dev]"

Build from Source

python -m build
pip install dist/mkdocs_sharepoint_plugin-*.whl

Python Requirements

  • Python: >=3.7
  • Build System: setuptools>=61, wheel, build

Dependencies

Core Dependencies

  • mkdocs - The static site generator this plugin extends
  • Office365-REST-Python-Client - SharePoint REST API client
  • tenacity - Retry/backoff for API calls
  • requests - HTTP library
  • pyyaml - YAML parsing

Configuration

The plugin is registered as a MkDocs plugin via the entry point:

sharepoint = "mkdocs_sharepoint_plugin.plugin:SharePointPlugin"

Add the plugin to your mkdocs.yml:

plugins:
  - sharepoint:
      site_url: https://contoso.sharepoint.com/sites/Team
      documents_folder: /sites/Team/Shared Documents/Docs
      enabled_if_env: MKDOCS_TO_SHAREPOINT
      dryrun: false
      debug: false

Configuration Options

Option Description Default Required
site_url SharePoint site URL $SHAREPOINT_SITE_URL
client_id Entra app client ID $SHAREPOINT_CLIENT_ID
client_secret Entra app client secret $SHAREPOINT_CLIENT_SECRET
documents_folder Server-relative document library folder
pages_folder Server-relative Site Pages folder (for wiki helpers) null
enabled_if_env Environment variable to enable plugin
dryrun Test mode without publishing false
debug Enable debug logging false

Usage

Basic Usage

  1. Configure the plugin in your mkdocs.yml
  2. Set up environment variables for SharePoint authentication:
    export SHAREPOINT_SITE_URL=https://contoso.sharepoint.com/sites/Team
    export SHAREPOINT_CLIENT_ID=your-client-id
    export SHAREPOINT_CLIENT_SECRET=your-client-secret
    export MKDOCS_TO_SHAREPOINT=1
    
  3. Build and publish your documentation:
    mkdocs build
    

When enabled_if_env is set, the plugin only publishes when the environment variable equals 1.

Dry Run

Set dryrun: true in your plugin config to log what would be uploaded without calling the SharePoint API.

SharePoint API Helpers

The repo also includes helper functions and an optional CLI for direct SharePoint publishing outside MkDocs:

  • Module: src/mkdocs_sharepoint_plugin/sharepoint_publish.py
  • CLI: tools/sharepoint_publish.py

Example CLI usage:

python tools/sharepoint_publish.py upload-docs \
    --local-dir site \
    --server-folder "/sites/your-site/Shared Documents/Docs"

python tools/sharepoint_publish.py create-wiki \
    --title "How do I reset my password?" \
    --html-file page.html \
    --pages-folder "/sites/your-site/SitePages"

Development

Run Tests

coverage run -m pytest
coverage report

Format Code

black src tests

Authentication Notes

SharePoint Online automation typically uses app-only authentication in Microsoft Entra ID. The app needs appropriate SharePoint permissions (for example Sites.ReadWrite.All) and admin consent for the tenant.

Store secrets in environment variables or a secrets manager. Do not commit credentials to source control.

Related Projects

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

mkdocs_sharepoint_plugin-1.0.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

mkdocs_sharepoint_plugin-1.0.0-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file mkdocs_sharepoint_plugin-1.0.0.tar.gz.

File metadata

File hashes

Hashes for mkdocs_sharepoint_plugin-1.0.0.tar.gz
Algorithm Hash digest
SHA256 9c6254bce9b2377c841da7ff4ad1f0af5e05bb479d31c767aa8cd2d75cfd24eb
MD5 e49ffc79277c1f379a8ff18da7d51b31
BLAKE2b-256 353a19e2cf5feaa97440171b6ed265120bf6f9c87dd9a2014365649941458647

See more details on using hashes here.

File details

Details for the file mkdocs_sharepoint_plugin-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mkdocs_sharepoint_plugin-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9d195acd487e314fa87143673a967076a4af5e7060b3a926fde28dfbdc35ee72
MD5 bc5088f3f05210ff6a2337dd9bc2693b
BLAKE2b-256 27e28583d2e561997a2df7eed3c7a3b2d7df4ebc25913985354e8fd6ae2ef941

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