Skip to content

Auto-translate doctests to pure Python, with import statements #35791

@mkoeppe

Description

@mkoeppe

I think we would be able to generate import statements from the # optional (or # needs - #35779) annotations.

The necessary cross-referencing information is going to be in sage.features.sagemath.
See:

This would also have the huge advantage to support users that want to use sage as a normal python package without loading the sage environment.

+1.

I could imagine that the code blocks in the formatted HTML could offers tabs for different views, as is done for example in https://setuptools.pypa.io/en/latest/userguide/package_discovery.html: The example in monolithic Sage (goes through preparser, no imports), and the example in plain Python (some prettified version of the preparsed example + imports). This would also address @williamstein's comment (https://groups.google.com/g/sage-devel/c/utA0N1it0Eo/m/79aD4-RQAAAJ)

Originally posted by @mkoeppe in #35750 (comment)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions