pawamoy/markdown-exec

Mkdocstrings use - Allow printing other object than `str`

hameye opened this issue ยท 2 comments

Hi, first thanks for this package and the mkdocstrings suite in general !

Is your feature request related to a problem? Please describe.
Executing code that is supposed to output numpy array does not work.

Describe the solution you'd like
To be allowed to output other kind of objects than str.

Describe alternatives you've considered
I tried converting objects to str as a workaround, but the rendering is not satisfying enough and writing print(str(obj)) in the python code is a bit misleading for future reader of the documentation

Additional context
Code

import numpy as np

xyz = np.array([
    [0,   0,   2,   5,   0,   1,   2,   0,   4,   3,   1,   2,   4],  # noqa
    [0,   0,   2,   5,   0,   1,   2,   0,   4,   3,   1,   2,   4],  # noqa
    [0,  -2,  -4,   1,  -5,   0,  -3,  -3,  -2,   2,  -3,  -2,   0]   # noqa
])

print(xyz)

Result in documentation :

TypeError: sequence item 0: expected str instance, numpy.ndarray found

Hello, thank you very much for the report! I was able to confirm the bug ๐Ÿ™‚

Should be fixed in 0.7.1 ๐Ÿ™‚