Name | sybil-extras JSON |
Version |
2024.10.18
JSON |
| download |
home_page | None |
Summary | Additions to Sybil, the documentation testing tool. |
upload_time | 2024-10-18 00:43:12 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.10 |
license | The MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
keywords |
markdown
rst
sphinx
sybil
testing
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
|Build Status| |codecov| |PyPI|
sybil-extras
============
Add ons for `Sybil <http://sybil.readthedocs.io>`_.
Installation
------------
.. code-block:: shell
$ pip install sybil-extras
Usage
-----
MultiEvaluator
^^^^^^^^^^^^^^
.. code-block:: python
"""Use MultiEvaluator to run multiple evaluators on the same parser."""
from sybil import Example, Sybil
from sybil.evaluators.python import PythonEvaluator
from sybil.parsers.rest.codeblock import CodeBlockParser
from sybil.typing import Evaluator
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: list[Evaluator] = [_evaluator_1, PythonEvaluator()]
multi_evaluator = MultiEvaluator(evaluators=evaluators)
parser = CodeBlockParser(language="python", evaluator=multi_evaluator)
sybil = Sybil(parsers=[parser])
pytest_collect_file = sybil.pytest()
ShellCommandEvaluator
^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
"""Use ShellCommandEvaluator to run shell commands against the code block."""
import sys
from sybil import Sybil
from sybil.parsers.rest.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 these suffixes.
tempfile_suffixes=[".example", ".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,
# Use a pseudo-terminal for running commands.
# This can be useful e.g. to get color output, but can also break
# in some environments.
use_pty=True,
)
parser = CodeBlockParser(language="python", evaluator=evaluator)
sybil = Sybil(parsers=[parser])
pytest_collect_file = sybil.pytest()
CustomDirectiveSkipParser
^^^^^^^^^^^^^^^^^^^^^^^^^
.. code-block:: python
"""Use CustomDirectiveSkipParser to skip code blocks with a custom marker."""
from sybil import Sybil
from sybil.parsers.rest.codeblock import PythonCodeBlockParser
# Similar parsers are available at
# sybil_extras.parsers.markdown.custom_directive_skip and
# sybil_extras.parsers.myst.custom_directive_skip.
from sybil_extras.parsers.rest.custom_directive_skip import (
CustomDirectiveSkipParser,
)
skip_parser = CustomDirectiveSkipParser(directive="custom-marker-skip")
code_block_parser = PythonCodeBlockParser()
sybil = Sybil(parsers=[skip_parser, code_block_parser])
pytest_collect_file = sybil.pytest()
This allows you to skip code blocks in the same way as described in
the Sybil documentation for skipping examples in
`reStructuredText <https://sybil.readthedocs.io/en/latest/rest.html#skipping-examples>`_,
`Markdown <https://sybil.readthedocs.io/en/latest/rest.html#skipping-examples>`_ ,
and `MyST <https://sybil.readthedocs.io/en/latest/myst.html#skipping-examples>`_ files,
but with custom text, e.g. ``custom-marker-skip`` replacing the word ``skip``.
.. |Build Status| image:: https://github.com/adamtheturtle/sybil-extras/actions/workflows/ci.yml/badge.svg?branch=main
:target: https://github.com/adamtheturtle/sybil-extras/actions
.. |codecov| image:: https://codecov.io/gh/adamtheturtle/sybil-extras/branch/main/graph/badge.svg
:target: https://codecov.io/gh/adamtheturtle/sybil-extras
.. |PyPI| image:: https://badge.fury.io/py/sybil-extras.svg
:target: https://badge.fury.io/py/sybil-extras
Raw data
{
"_id": null,
"home_page": null,
"name": "sybil-extras",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.10",
"maintainer_email": null,
"keywords": "markdown, rst, sphinx, sybil, testing",
"author": null,
"author_email": "Adam Dangoor <adamdangoor@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/b2/f1/c6b687e62b8deceeb47c47a9730fc40d794058e98fd43d4bbf47ca2e356b/sybil_extras-2024.10.18.tar.gz",
"platform": null,
"description": "|Build Status| |codecov| |PyPI|\n\nsybil-extras\n============\n\nAdd ons for `Sybil <http://sybil.readthedocs.io>`_.\n\nInstallation\n------------\n\n.. code-block:: shell\n\n $ pip install sybil-extras\n\nUsage\n-----\n\nMultiEvaluator\n^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n \"\"\"Use MultiEvaluator to run multiple evaluators on the same parser.\"\"\"\n\n from sybil import Example, Sybil\n from sybil.evaluators.python import PythonEvaluator\n from sybil.parsers.rest.codeblock import CodeBlockParser\n from sybil.typing import Evaluator\n\n from sybil_extras.evaluators.multi import MultiEvaluator\n\n\n def _evaluator_1(example: Example) -> None:\n \"\"\"Check that the example is long enough.\"\"\"\n minimum_length = 50\n assert len(example.parsed) >= minimum_length\n\n\n evaluators: list[Evaluator] = [_evaluator_1, PythonEvaluator()]\n multi_evaluator = MultiEvaluator(evaluators=evaluators)\n parser = CodeBlockParser(language=\"python\", evaluator=multi_evaluator)\n sybil = Sybil(parsers=[parser])\n\n pytest_collect_file = sybil.pytest()\n\nShellCommandEvaluator\n^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n \"\"\"Use ShellCommandEvaluator to run shell commands against the code block.\"\"\"\n\n import sys\n\n from sybil import Sybil\n from sybil.parsers.rest.codeblock import CodeBlockParser\n\n from sybil_extras.evaluators.shell_evaluator import ShellCommandEvaluator\n\n evaluator = ShellCommandEvaluator(\n args=[sys.executable, \"-m\", \"mypy\"],\n # The code block is written to a temporary file\n # with these suffixes.\n tempfile_suffixes=[\".example\", \".py\"],\n # Pad the temporary file with newlines so that the\n # line numbers in the error messages match the\n # line numbers in the source document.\n pad_file=True,\n # Don't write any changes back to the source document.\n # This option is useful when running a linter or formatter\n # which modifies the code.\n write_to_file=False,\n # Use a pseudo-terminal for running commands.\n # This can be useful e.g. to get color output, but can also break\n # in some environments.\n use_pty=True,\n )\n parser = CodeBlockParser(language=\"python\", evaluator=evaluator)\n sybil = Sybil(parsers=[parser])\n\n pytest_collect_file = sybil.pytest()\n\nCustomDirectiveSkipParser\n^^^^^^^^^^^^^^^^^^^^^^^^^\n\n.. code-block:: python\n\n \"\"\"Use CustomDirectiveSkipParser to skip code blocks with a custom marker.\"\"\"\n\n from sybil import Sybil\n from sybil.parsers.rest.codeblock import PythonCodeBlockParser\n\n # Similar parsers are available at\n # sybil_extras.parsers.markdown.custom_directive_skip and\n # sybil_extras.parsers.myst.custom_directive_skip.\n from sybil_extras.parsers.rest.custom_directive_skip import (\n CustomDirectiveSkipParser,\n )\n\n skip_parser = CustomDirectiveSkipParser(directive=\"custom-marker-skip\")\n code_block_parser = PythonCodeBlockParser()\n\n sybil = Sybil(parsers=[skip_parser, code_block_parser])\n\n pytest_collect_file = sybil.pytest()\n\nThis allows you to skip code blocks in the same way as described in\nthe Sybil documentation for skipping examples in\n`reStructuredText <https://sybil.readthedocs.io/en/latest/rest.html#skipping-examples>`_,\n`Markdown <https://sybil.readthedocs.io/en/latest/rest.html#skipping-examples>`_ ,\nand `MyST <https://sybil.readthedocs.io/en/latest/myst.html#skipping-examples>`_ files,\nbut with custom text, e.g. ``custom-marker-skip`` replacing the word ``skip``.\n\n.. |Build Status| image:: https://github.com/adamtheturtle/sybil-extras/actions/workflows/ci.yml/badge.svg?branch=main\n :target: https://github.com/adamtheturtle/sybil-extras/actions\n.. |codecov| image:: https://codecov.io/gh/adamtheturtle/sybil-extras/branch/main/graph/badge.svg\n :target: https://codecov.io/gh/adamtheturtle/sybil-extras\n.. |PyPI| image:: https://badge.fury.io/py/sybil-extras.svg\n :target: https://badge.fury.io/py/sybil-extras\n",
"bugtrack_url": null,
"license": "The MIT License Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
"summary": "Additions to Sybil, the documentation testing tool.",
"version": "2024.10.18",
"project_urls": {
"Source": "https://github.com/adamtheturtle/sybil-extras"
},
"split_keywords": [
"markdown",
" rst",
" sphinx",
" sybil",
" testing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0180f8a4f182971e9f5fdceae437152b0d7b0c92de00ed56a68f07f7678a998e",
"md5": "bfa08da6397e629ff96b424bd746ea75",
"sha256": "adb76a783b4e8bfa15c21ef5a66afec3c989bf583bb52294fb448d4421b0b9c4"
},
"downloads": -1,
"filename": "sybil_extras-2024.10.18-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "bfa08da6397e629ff96b424bd746ea75",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.10",
"size": 11909,
"upload_time": "2024-10-18T00:43:11",
"upload_time_iso_8601": "2024-10-18T00:43:11.486314Z",
"url": "https://files.pythonhosted.org/packages/01/80/f8a4f182971e9f5fdceae437152b0d7b0c92de00ed56a68f07f7678a998e/sybil_extras-2024.10.18-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b2f1c6b687e62b8deceeb47c47a9730fc40d794058e98fd43d4bbf47ca2e356b",
"md5": "fca8bd3003135f0fdedbf6a21dec95b2",
"sha256": "1d3fa585c852958c27a8cafadf50d75c8abbf6793be0c4c1d06aff57bb2c59ae"
},
"downloads": -1,
"filename": "sybil_extras-2024.10.18.tar.gz",
"has_sig": false,
"md5_digest": "fca8bd3003135f0fdedbf6a21dec95b2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.10",
"size": 24660,
"upload_time": "2024-10-18T00:43:12",
"upload_time_iso_8601": "2024-10-18T00:43:12.591962Z",
"url": "https://files.pythonhosted.org/packages/b2/f1/c6b687e62b8deceeb47c47a9730fc40d794058e98fd43d4bbf47ca2e356b/sybil_extras-2024.10.18.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-18 00:43:12",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "adamtheturtle",
"github_project": "sybil-extras",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "sybil-extras"
}