pawamoy / markdown-exec

Utilities to execute code blocks in Markdown files.
https://pawamoy.github.io/markdown-exec
ISC License
111 stars 8 forks source link

Mkdocstrings use - Allow printing other object than `str` #7

Closed hameye closed 2 years ago

hameye commented 2 years ago

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
pawamoy commented 2 years ago

Hello, thank you very much for the report! I was able to confirm the bug :slightly_smiling_face:

pawamoy commented 2 years ago

Should be fixed in 0.7.1 :slightly_smiling_face: