Skip to content

Documentation for _repr_pretty_ is confusing #12992

Open

Description

@terrdavis

The documentation for _repr_pretty_ at the end of the Rich Display section is confusing. It was never clear to me that this particular method was applicable in a different context than the _ipython_display_ and other _repr_* methods.

Though the paragraph starts with

To customize how the REPL pretty-prints your object[...]

the the notebook/QTConsole-specific methods use the same naming convention, and the entire rest of the section is dedicated non-REPL usage.

I would like to update the documentation to make the distinction clearer. Here are a couple possible improvements:

  1. Create separate sub-sections for REPL and non-REPL display methods;
  2. Put _repr_pretty_ first, and reword the next section to say that the other methods are available in addition to _repr_pretty_ when using IPython outside of the REPL.

Would it be possible to backport this change to other versions as well?

Activity

  1. Carreau commented on May 28, 2021

    @Carreau
    Member

    Hi there, if you send a PR I'm happy to try to merge it, if our bot can backport it without much difficulties, I'm happy to include it in earlier version as well.

  2. MrMino commented on May 30, 2021

    @MrMino
    Member

    @terrdavis if you have any questions on how to edit docs and generate them locally to test it I can help.

    Can't move this forward myself atm unfortunately.

  3. terrdavis commented on Jun 7, 2021

    @terrdavis
    ContributorAuthor

    I'm continuing the discussion from the #13008 since it is already merged.

    I still have the following questions:

    • when are the mimebundle and ipython_display methods available? (for notebook & Qt console)
    • can repr_pretty also return metadata?
    • (not a queston) The cross-reference in this section is pointing to the python docs. I just found the relevant section of the Sphinx docs, so I'll fix this once my other questions are answered.
    • Since I will need to make another PR, what's the best way to make these changes easy to backport?
  4. MrMino commented on Jun 28, 2021

    @MrMino
    Member

    @terrdavis For the first two questions - I'll have to look into it, I haven't used those in a long time.

    Don't worry about the backport. If we decide it needs one, we'll do it. WRT. docs there isn't much you can do anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions