Additions to Sybil, the documentation testing tool.
Project description
Add ons for Sybil.
Installation
$ pip install sybil-extras
Usage
MultiEvaluator
"""Use MultiEvaluator to run multiple evaluators on the same parser."""
from sybil import Example, Sybil
from sybil.evaluators.python import PythonEvaluator
from sybil.parsers.codeblock import CodeBlockParser
from sybil_extras.evaluators.multi import MultiEvaluator
def _evaluator_1(example: Example) -> None:
"""Check that the example is long enough."""
minimum_length = 50
assert len(example.parsed) >= minimum_length
evaluators = [_evaluator_1, PythonEvaluator()]
multi_evaluator = MultiEvaluator(evaluators=evaluators)
parser = CodeBlockParser(language="python", evaluator=multi_evaluator)
sybil = Sybil(parsers=[parser])
ShellCommandEvaluator
"""Use ShellCommandEvaluator to run shell commands against the code block."""
import sys
from sybil import Sybil
from sybil.parsers.codeblock import CodeBlockParser
from sybil_extras.evaluators.shell_evaluator import ShellCommandEvaluator
evaluator = ShellCommandEvaluator(
args=[sys.executable, "-m", "mypy"],
# The code block is written to a temporary file
# with this suffix.
tempfile_suffix=".py",
# Pad the temporary file with newlines so that the
# line numbers in the error messages match the
# line numbers in the source document.
pad_file=True,
# Don't write any changes back to the source document.
# This option is useful when running a linter or formatter
# which modifies the code.
write_to_file=False,
)
parser = CodeBlockParser(language="python", evaluator=evaluator)
sybil = Sybil(parsers=[parser])
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
sybil_extras-2024.9.7.tar.gz
(14.6 kB
view details)
Built Distribution
File details
Details for the file sybil_extras-2024.9.7.tar.gz
.
File metadata
- Download URL: sybil_extras-2024.9.7.tar.gz
- Upload date:
- Size: 14.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67f4c93d78c0e0e6b93ee98226f68bf010878e7bc0e49ad7d1c453911127a71f |
|
MD5 | 0c9046da455c73410032263ad8730e28 |
|
BLAKE2b-256 | b63cd71f26c8235c527553a7bd7d0120f25d51fc518d87d77d12b74d42c54bf1 |
File details
Details for the file sybil_extras-2024.9.7-py2.py3-none-any.whl
.
File metadata
- Download URL: sybil_extras-2024.9.7-py2.py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbbda243ceb205e85740d2ccadc1b9b5ec1b6253c4e1c86bbebc4d9f105ac807 |
|
MD5 | 534395567897612cf9d959ab66380eef |
|
BLAKE2b-256 | 70b5fb4480ef4c339abdad468347425f16487e72180aafee859c65d07fccf87a |