rstcheck-core
rstcheck-core is the core library behind the rstcheck CLI application, used for checking the syntax of reStructuredText documents and code blocks embedded within them. It leverages docutils for parsing RST and reports found issues. The library follows semantic versioning, with bugfixes typically supported only for the current minor release. It has a regular release cadence, with updates often reflecting changes in the broader rstcheck ecosystem.
Warnings
- breaking The `rstcheck` project underwent a significant architectural change with version 6.0.0, where the core logic was extracted into the `rstcheck-core` library. Direct imports or interactions with internal `rstcheck` modules from versions 5.x or earlier will break when migrating to `rstcheck-core` or `rstcheck` v6+.
- gotcha Windows support for `rstcheck-core` is explicitly stated as not stable. Tests can fail with incorrect positives and negatives for unknown reasons, which may lead to unreliable linting results on Windows systems.
- gotcha Configuration settings defined in files (e.g., `.rstcheck.cfg`, `pyproject.toml`, `setup.cfg`) can be completely overridden by command-line interface (CLI) options. Additionally, `rstcheck-core` searches for configuration files by traversing up the directory tree from the checked file, which might lead to unexpected configuration being applied if not carefully managed.
Install
-
pip install rstcheck-core -
pip install rstcheck-core[sphinx,toml,yaml]
Imports
- check
from rstcheck_core import check
Quickstart
from rstcheck_core import check
rst_content = '''
Example
=======
.. code:: python
print("Hello, rstcheck!")
.. code:: badlang
This language does not exist.
'''
issues = list(check(rst_content))
for line, message in issues:
print(f"Line {line}: {message}")
# Example with an actual error:
error_rst = '''
Bad RST
=======
This title underline is too short.
===
'''
issues_with_error = list(check(error_rst))
for line, message in issues_with_error:
print(f"Line {line}: {message}")