Skip to content

Make the documented docstring and README examples executable #84

Description

@tschm

Subcategory: executable documentation
Score: 4 → 9

Problem

The package documents examples nobody verifies. interrogate reports 100%
docstring coverage (63/63) — but coverage measures whether a docstring exists,
not whether what it claims is still true.

Six ​```python example blocks live in src docstrings:

  • src/pycharting/api/interface.py — 3 (in plot, stop_server, get_server_status)
  • src/pycharting/core/server.py — 2 (incl. find_free_port)
  • src/pycharting/__init__.py — 1

All six are markdown fences rather than >>> doctests, so doctest never sees
them. The template's own check agrees, by skipping:

SKIPPED [1] .rhiza/tests/sync/test_docstrings.py:123: No doctests were found in any module

The README is the same story: of 7 Python fences, 6 carry +RHIZA_SKIP
(lines 78, 107, 139, 174, 219, 229), leaving exactly one machine-verified
Python example in the entire project.

This is the failure with the longest half-life in a repo — an example goes stale,
keeps rendering perfectly, and the person who finds out is a newcomer at the
worst possible moment.

Files to change

  • src/pycharting/api/interface.py (docstrings of plot, stop_server, get_server_status)
  • src/pycharting/core/server.py (docstrings of find_free_port, create_app)
  • src/pycharting/__init__.py (module docstring)
  • README.md — review the 6 +RHIZA_SKIP fences and un-skip those that can run

done when

  • The src docstring examples are >>> doctests with expected output.
  • make rhiza-test runs .rhiza/tests/sync/test_docstrings.py instead of
    skipping it with "No doctests were found in any module".
  • uv run python -m doctest (or --doctest-modules in the pytest run) passes.
  • Each remaining +RHIZA_SKIP in the README is justified by a comment saying why
    that example cannot execute (e.g. it starts a browser).

Evidence

check_doc_examples.py --source-root src --json:

"docstrings": { "files": 10, "examples": 0,
  "notes": ["no doctest examples found — docstring coverage says nothing about
             whether the docstrings are true, and here there is nothing to check"] }

Found by /rhiza:quality (full mode, rhiza v0.18.8).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions