Additions to Sybil, the documentation testing tool.
Project description
sybil-extras
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.9.tar.gz
(15.8 kB
view details)
Built Distribution
File details
Details for the file sybil_extras-2024.9.9.tar.gz
.
File metadata
- Download URL: sybil_extras-2024.9.9.tar.gz
- Upload date:
- Size: 15.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cf1752f56b00b5fc32756fadae8bada8eaf919bba1594f80a3a710159f5d929 |
|
MD5 | 6e6e1478f51a5f5937444fb6a8da0b05 |
|
BLAKE2b-256 | 1ac6e1092aa73405e8173e201757d57fc5c5f2b0c5964cf25f7bb218147214d5 |
File details
Details for the file sybil_extras-2024.9.9-py2.py3-none-any.whl
.
File metadata
- Download URL: sybil_extras-2024.9.9-py2.py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70de46a75546cc35a79cbc6a911214a1fc26eb8caf8b39884d1baaafab2edfb2 |
|
MD5 | 3e6ba6f440f5dbb80c1d88ed4c948ffa |
|
BLAKE2b-256 | 7289bfd1beac574a03a3347c51d54abeaac251a06737188e9ce37ae796951c44 |