reStructuredText Linter

2.0.2 · active · verified Thu Apr 09

restructuredtext-lint is a Python library for linting reStructuredText (RST) documents to identify errors, warnings, and style issues. It leverages `docutils` for parsing and provides programmatic access to linting results, including line numbers, types, and messages. The current version is 2.0.2, and it maintains a slow but active release cadence, primarily focusing on bug fixes and compatibility with newer Python and `docutils` versions.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to use `restructuredtext-lint` to check a string for reStructuredText syntax errors and warnings. It iterates through the detected errors, printing their type, line number, and message. It also shows the general approach for linting files.

from restructuredtext_lint import lint

rst_content = '''
My Document
===========

.. This is a comment

This is a paragraph with some `broken

.. bad_directive::

An error will be reported above.
'''

errors = lint(rst_content)

if errors:
    print(f"Found {len(errors)} linting issues:")
    for error in errors:
        print(f"  [{error.type.upper()}] Line {error.line}: {error.message}")
else:
    print("No linting issues found.")

# To lint a file:
# from restructuredtext_lint.file_lint import lint_file
# errors_from_file = lint_file('path/to/your/file.rst')

view raw JSON →