Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Sphinx docx builder extension.

Project Description

Sphinx docx builder extension generate single docx file from Sphinx document source. This extension use python-docx module (included) for the docx file generation.


  • This extension work on Multi-platform (not need OpenOffice or MS Word).
  • Usable sphinx syntax and directives:
    • heading line output
    • paragraph output (standard body text)
    • image and figure directive output
    • bullet-list and numbered-list output
    • table output (restrictive)

Currently, many directives and indented block are not work correctly, yet.


Make environment by easy_install

Not yet.

Make environment by buildout

‘hg clone’ or download sphinxcontrib-docxbuilder archive from ‘get source’ menu at

$ cd /path/to/sphinxcontrib-docxbuilder
$ python -d init
$ bin/buildout

run example

for example sphinx-docx building, simply run below:

$ bin/example
Saved new file to: examples/example-0.1.docx


Set ‘sphinxcontrib-docxbuilder’ to ‘extensions’ line of target sphinx source

extensions = ['sphinxcontrib-docxbuilder']

Execute sphinx-build with below option:

$ bin/sphinx-build -b docx [input-dir] [output-dir]
$ ls [output-dir]


  • Python 2.6 or later (not support 3.x)
  • python-docx (not released, but included), Thanks Mike MacCana.
  • setuptools or distriubte.


0.0.1 (unreleased)

  • Not released.



  • table output
  • toctree generation (dispose toctree output? create by docx function?)
  • reset number for non-continuous numbered list
  • add page-break directive
  • implement many many directives
    • note
    • warning
    • code highlighting
    • and etc….
  • using dotx template
  • some emphasis (italic, bold)


  • docx builder need python-docx package, but not distributed at PyPI.
  • python-docx can’t generate <w:i> (italic) and <w:b> (bold) mode tag.

Known Issues

  • some indented block output are not working correctly yet.
    • block-quote
    • literal-block
  • figure directive’s caption become normal paragraph (not bundled with image).
  • python-docx using template’s media(image) folder for temporarily, then some independent document’s media files are shared unexpectly.
  • image directive break docx format (maybe very large file are included)

Release History

This version
History Node


Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting