Skip to content

Include doctests from files #9659

@HaoZeke

Description

@HaoZeke

Is your feature request related to a problem? Please describe.
I've been working with .. doctest:: for a while now and some snippets are a little too long to be comfortably put in the documentation.

Naturally there are unit tests but sometimes (mostly for demonstrating benchmarks) it is desirable to have a class or something defined over multiple lines with sensitive indentation be part of the doctest.

Currently this means carefully editing it in a .py file and then putting it in the rst.

Describe the solution you'd like
Allow .. include:: to work with .. doctest::

Describe alternatives you've considered
Doug Hellmann has a rather involved alternative using cog discussed here but I'd rather not go that far.

Additional context
The motivating context is this NumPy document which had an indent bug preventing us from doctests.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions