Add Python Doctests
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.2k
- Forks
- 1k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 66
Description
In the current main branch we have 32 python code blocks in guide and 17 in src:
rg '```python' guide/ | wc -l
32
rg '```python' src/ | wc -l
17
As the project grows, it might become increasingly hard to check if those blocks are correct and up to date.
Adding python doctest or similar to nox and the CI can guarantee the scalability. With those checks, some categories of issues like https://github.com/PyO3/pyo3/issues/3639 would not exist.
Requirements
- Have a way to skip tests (
+SKIP,no_run) - Being able to run in
.md,.pyand.rsfiles - Hide any setup/teardown code in rendered documentation
- Don't burden the CI 🤖
Some examples have two code blocks, one for the code and the other for the output. We may need to change them to adhere to doctest syntax or write our own plugin to check their validity.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the Python blocks in guide/ and src/ and the existing nox and CI configuration. Determine how doctest or a custom plugin can handle .md, .py, and .rs files, skips, separate output blocks, and hidden setup or teardown code. Done means the documented requirements are supported without an excessive CI burden.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- ci-cd, documentation, testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100