docutils-stubs

0.0.22 · active · verified Fri Apr 17

docutils-stubs provides PEP 561 type stubs for the docutils library, enabling static type checking tools like MyPy to verify code that uses docutils. It helps catch type-related errors before runtime. The current version is 0.0.22, with releases typically following updates to the underlying docutils library or bug fixes.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to use `docutils.core.publish_string` to convert reStructuredText to HTML. When `docutils-stubs` is installed alongside `docutils`, type checkers like MyPy will be able to provide accurate type analysis for calls to `publish_string` and other docutils functions, even though the import statement targets `docutils` directly.

from docutils.core import publish_string

rst_content = """
My Document
===========

This is a paragraph.

* A list item
* Another item
"""

# docutils-stubs provides type hints for this call
html_output = publish_string(
    source=rst_content,
    writer_name='html'
)

print(html_output[:100] + '...') # Print a snippet of the generated HTML

view raw JSON →