Skip to content

ENH capture 'repr's of last expression #540

@lucyleeow

Description

@lucyleeow

Relates to #396 (pretty html rendering) which can be implemented in 2 steps:

  1. (this issue) eval() last line if it is an expression. This removes the need to use print() to output the value of expressions.
  2. Capture html output if there is a __repr_html__. This allows nice rendering of e.g. pandas dataframes, plots and reports (currently implemented via a 'image' scraper in nilearn, nistats, mne)

There has been discussion at #421 (and a WIP PR #422) about using nbconvert to execute code blocks, which would address both issues above, however there were concerns about adding dependencies and no work around was agreed upon.

The plan for this issue would be to implement the same 'exec/eval' logic from jupyter-sphinx (as suggested by @maartenbreddels) in execute_code_block(). Thoughts welcome.

(cc @GaelVaroquaux)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions