Skip to content

docs: document and validate interactive Python examples - #1981

Open
iamnicocr wants to merge 1 commit into
python:mainfrom
iamnicocr:docs-1134-doctest-examples
Open

iamnicocr wants to merge 1 commit into
python:mainfrom
iamnicocr:docs-1134-doctest-examples

Conversation

@iamnicocr

Copy link
Copy Markdown

Summary

  • Added a "Testing interactive examples" section to the documentation style guide.
  • Documented how to use doctest to validate interactive Python examples.
  • Included executable examples demonstrating deterministic outputs and the ELLIPSIS option for variable output.
  • Enabled the sphinx.ext.doctest extension and configured explicit testing of selected examples.

Motivation

Interactive code examples should remain correct as Python evolves. This contribution provides practical guidance for writing testable examples and introduces a way to validate them using Sphinx's doctest builder.

Testing

  • Sphinx doctest builder — 4 tests passed, 0 test failures.
  • Sphinx HTML build — Completed successfully.
  • Documentation lint (sphinxlint) — Passed.
  • git diff --check — Passed.

The doctest build reported four warnings about missing generated files referenced by versions.rst. The added Python examples passed without failures.

Scope

This change adds executable documentation examples and Sphinx test configuration. It does not modify the CPython interpreter or integrate doctest execution into GitHub CI.

Related issue

Refs #1134

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 CPython devguide | 🛠️ Build #35898884 | 📁 Comparing 218afdf against latest (8c852bd)

  🔍 Preview build  

1 file changed
± documentation/style-guide/index.html

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