Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improvements to the display.py module #846

Closed
edublancas opened this issue Aug 29, 2023 · 4 comments · Fixed by #861
Closed

improvements to the display.py module #846

edublancas opened this issue Aug 29, 2023 · 4 comments · Fixed by #861
Assignees

Comments

@edublancas
Copy link

we added a display.py module to centralize the way to show feedback to the user because we have to support two frontends: Jupyter (which supports displaying HTML) and the terminal (only supports plain text)

the Message class allows creating an object that correctly displays its value in HTML if it's running in Jupyter or in plain text if running in the terminal, and it allows adding an optional CSS style (which is only visible in Jupyter).

The limitation happens when we want to display a link in the message. this happens when we want to point users to certain sections in our docs: if we add the HTML link to a Message instance, it'll display correctly in Jupyter but it won't in the terminal.

We can do something like this:

# to keep backward compatibility
Message("some plain text message")

# new API
Message(["go to our", Link("home", "https://ploomber.io"), "page"])

then, internally, the plain text representation can resolve to:

go to our home (https://ploomber.io) page

and the HTML one to:

go to our <a href="[url](https://ploomber.io)">home</a> page
@bbeat2782
Copy link

bbeat2782 commented Sep 5, 2023

Acceptance Criteria

  1. Modify code so that Message class takes both str and list of str as input and decides the form of text representation depending on jupyter notebook / terminal.
  2. Ensure all previous test cases pass and add test function for testing Message(["go to our", Link("home", "https://ploomber.io"), "page"]) this kind of input
  3. Update developer docs to explain the change

@bbeat2782 bbeat2782 mentioned this issue Sep 5, 2023
4 tasks
@edublancas
Copy link
Author

I forgot to mention something: let's update our developer docs as well, there is a section that talks about the display.py module so let's put some examples of this new API!

@bbeat2782
Copy link

Are you referring to this part?

@edublancas
Copy link
Author

yes!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants