Docutils: Python Documentation Utilities
Docutils is a modular system for processing plaintext documentation into useful formats, such as HTML, LaTeX, and XML. The current version is 0.22.4, released on March 28, 2026. Docutils follows a regular release cadence, with major releases introducing new features and minor releases focusing on bug fixes and improvements.
Warnings
- breaking Docutils 0.20 is the last version supporting Python 3.7 and 3.8.
- deprecated The 'rst2html.py' script is deprecated and will be removed in a future release.
- gotcha Ensure that the 'docutils' package is installed in your Python environment to avoid ImportError.
Install
-
pip install docutils
Imports
- Publisher
from docutils.core import Publisher
- Reader
from docutils.readers.standalone import Reader
- Writer
from docutils.writers.html4css1 import Writer
Quickstart
import os
from docutils.core import publish_string
from docutils.readers.standalone import Reader
from docutils.writers.html4css1 import Writer
# Sample reStructuredText input
rst_input = '''
Title
=====
This is a sample reStructuredText document.
'''
# Create Reader and Writer instances
reader = Reader()
writer = Writer()
# Process the input
output = publish_string(source=rst_input.encode('utf-8'), reader=reader, writer=writer)
# Print the HTML output
print(output.decode('utf-8'))