Skip to content

Use sybil for doctests - #81

Merged
hagenw merged 3 commits into
mainfrom
use-sybil
Apr 15, 2026
Merged

Use sybil for doctests#81
hagenw merged 3 commits into
mainfrom
use-sybil

Conversation

@hagenw

@hagenw hagenw commented Apr 15, 2026

Copy link
Copy Markdown
Member

Replaces jupyter-sphinx with sybil for testing usage documentation.

@sourcery-ai

sourcery-ai Bot commented Apr 15, 2026

Copy link
Copy Markdown

Reviewer's Guide

Replaces jupyter-sphinx/pytest-doctestplus based documentation tests with Sybil-based doctest collection for usage.rst, configures Sphinx and matplotlib for plot rendering, and adjusts development/pytest configuration accordingly.

Sequence diagram for Sybil-based doctest collection of usage.rst

sequenceDiagram
    actor Developer
    participant pytest
    participant Sybil
    participant DocTestParser
    participant PythonCodeBlockParser
    participant usage_rst as usage_rst
    participant namespace

    Developer->>pytest: run tests
    pytest->>Sybil: call pytest_collect_file
    Sybil->>Sybil: apply patterns usage.rst
    Sybil->>usage_rst: open and read content
    Sybil->>DocTestParser: parse doctest blocks
    Sybil->>PythonCodeBlockParser: parse python code blocks
    DocTestParser-->>Sybil: doctest examples
    PythonCodeBlockParser-->>Sybil: code block examples
    Sybil->>namespace: call setup imports
    namespace-->>Sybil: namespace with audresample and plot_signal
    Sybil-->>pytest: pytest items for doctests
    loop run doctests
        pytest->>namespace: execute doctest example
    end
Loading

Flow diagram for pytest and Sybil doctest execution

flowchart TD
    A[Developer runs pytest] --> B[pytest configuration
addopts: -p no:doctest]
    B --> C[pytest test discovery]
    C --> D[Sybil pytest_collect_file in docs_conftest]
    D --> E[Sybil parses usage.rst
via DocTestParser and PythonCodeBlockParser]
    E --> F[Sybil calls imports setup
populate namespace]
    F --> G[pytest runs generated doctest items]
    G --> H[Tests include calls to audresample and plot_signal]
    H --> I[matplotlib uses Agg backend
no GUI windows]
    I --> J[Test results reported by pytest]
Loading

File-Level Changes

Change Details Files
Switch documentation doctest infrastructure from jupyter-sphinx/pytest-doctestplus to Sybil-based collection for usage.rst.
  • Remove jupyter-sphinx and pytest-doctestplus from development dependencies and pytest configuration.
  • Disable the built-in pytest doctest plugin via -p no:doctest.
  • Add Sybil as a development dependency and wire it into pytest via a docs-specific conftest.
pyproject.toml
docs/conftest.py
Configure Sphinx and matplotlib to support plotting in documentation while keeping copybutton behavior consistent with doctest prompts.
  • Replace jupyter_sphinx extension with matplotlib.sphinxext.plot_directive in Sphinx extensions.
  • Configure sphinx-copybutton to ignore doctest prompts when copying code.
  • Set matplotlib plot_directive options for included figures and output formats.
docs/conf.py
Introduce a Sybil-based doctest harness for usage documentation, including plotting utilities and doctest namespace setup.
  • Set matplotlib to use a non-interactive backend for doctests.
  • Provide a helper plot_signal function for use within usage.rst doctests.
  • Expose audresample and plot_signal into the doctest namespace via a Sybil setup function.
  • Configure Sybil to parse doctest-style and Python code block examples from usage.rst and integrate with pytest collection.
docs/conftest.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

sourcery-ai[bot]

This comment was marked as resolved.

@hagenw
hagenw merged commit 06f6bd7 into main Apr 15, 2026
20 checks passed
@hagenw
hagenw deleted the use-sybil branch April 15, 2026 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant