Parts of doctest exposed as library