holoviz / holoviz/param

Provide better ansi color codes. __doc__ strings are hard to read and not very "modern".

Open
#570 9 comments 2 reactions 0 assignees View on GitHub
type-feature
Dominant language
Python
Stars
521
Forks
86
Avg merge
1d 13h
Merged PRs (30d)
35

Description

The param `__doc__` string is powerful. But it is hard to read due to the colors chosen.

The blue on a black background is especially hard to read. But also the red can also be hard to read. And the green just does not look *modern*.

As a consequence I am not really finding my self using the `__doc__` string. Which makes it harder to use the HoloViz ecosystem. Especially hvplot and HoloViews where a lot of needed information is in the `__doc__` string and not on their web sites or something you can find via *intellisense* in your editor.

Can you read the blue below? 😄

![image](https://user-images.githubusercontent.com/42288570/142147484-c77e4f0d-199a-48ea-8758-383c50c20f08.png)

```python
from panel.template.fast.list import FastListTemplate
import param
import panel as pn
import ansiconv

ACCENT_COLOR = "#0072B5"
pn.state.sizing_mode="stretch_width"

class ClassificationPlot(param.Parameterized):
"""The ClassificationPlot plots the output of a classification, i.e. the *labels*
and their *score*.
"""
output_json = param.List(doc="""
The ouput of the classification""")
options = param.Dict(constant=True, doc="""
The configuration used to construct the plot""")
color = param.Color(ACCENT_COLOR, doc="""
The colors of the bars""")
theme = param.Selector(default="default", objects=["default", "dark"], doc="""
The theme, i.e. 'default' or 'dark'. This is automatically set from pn.state.session_args""")

plot = ClassificationPlot()
def to_html(txt):
html = ansiconv.to_html(txt)
css = ansiconv.base_css()

html = f"""
{css}

{html}

"""
return pn.Column(pn.pane.HTML(html, width=1200, sizing_mode="fixed"), height=500, scroll=True)

card = pn.layout.Card(
to_html(plot.__doc__), header="ClassificationPlot", sizing_mode="stretch_width", collapsed=False
)

FastListTemplate(
title="ClassificationPlot", main=[card], accent_base_color=ACCENT_COLOR, header_background=ACCENT_COLOR
).servable()
```

## Additional Context

We should be able to get a lot of inspiration from [Rich](https://github.com/willmcgugan/rich). That output is very readable.

![image](https://user-images.githubusercontent.com/42288570/142147984-608069e0-489c-4be6-b88e-004d0b59be4a.png)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.