sybil-extras


Namesybil-extras JSON
Version 2024.9.22.1 PyPI version JSON
download
home_pageNone
SummaryAdditions to Sybil, the documentation testing tool.
upload_time2024-09-22 21:00:18
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseThe 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,
    )
    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/84/11/8ac80cfa0dbcc877fd5e2367ad48f67082dd29e4b2ca579e6d90a92bdaa8/sybil_extras-2024.9.22.1.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    )\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.9.22.1",
    "project_urls": {
        "Source": "https://github.com/adamtheturtle/sybil-extras"
    },
    "split_keywords": [
        "markdown",
        " rst",
        " sphinx",
        " sybil",
        " testing"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d837ba049a5fa768e3b1c0bcb2ca88969e81d1215480411068a978b71d8d23fa",
                "md5": "89999907548bf40f6b8b27f32ba09abc",
                "sha256": "cd87bc4cb7ec53be08f19fbe2ddd8cf181702cec5ddb608cb0ac0df2bb8d03c2"
            },
            "downloads": -1,
            "filename": "sybil_extras-2024.9.22.1-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "89999907548bf40f6b8b27f32ba09abc",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.10",
            "size": 10825,
            "upload_time": "2024-09-22T21:00:16",
            "upload_time_iso_8601": "2024-09-22T21:00:16.294174Z",
            "url": "https://files.pythonhosted.org/packages/d8/37/ba049a5fa768e3b1c0bcb2ca88969e81d1215480411068a978b71d8d23fa/sybil_extras-2024.9.22.1-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "84118ac80cfa0dbcc877fd5e2367ad48f67082dd29e4b2ca579e6d90a92bdaa8",
                "md5": "187973a6108ffea02e6088ea8b9ed2e7",
                "sha256": "24ec45eb5901e199102f473e8725e58946b46e60e488c81623d73905be26d645"
            },
            "downloads": -1,
            "filename": "sybil_extras-2024.9.22.1.tar.gz",
            "has_sig": false,
            "md5_digest": "187973a6108ffea02e6088ea8b9ed2e7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 22652,
            "upload_time": "2024-09-22T21:00:18",
            "upload_time_iso_8601": "2024-09-22T21:00:18.105089Z",
            "url": "https://files.pythonhosted.org/packages/84/11/8ac80cfa0dbcc877fd5e2367ad48f67082dd29e4b2ca579e6d90a92bdaa8/sybil_extras-2024.9.22.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-22 21:00:18",
    "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"
}
        
Elapsed time: 8.96466s