Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Update tooltip styles in codemirror.css and handle docstrings differently based on module in complete.py (#272)

Myles Scolnick8f3a4d84648a
diff --git a/frontend/src/css/codemirror.css b/frontend/src/css/codemirror.css
index c016e5d9b5..da47151eb9 100644
--- a/frontend/src/css/codemirror.css
+++ b/frontend/src/css/codemirror.css
@@ -26,7 +26,6 @@
/* -- Tooltips: code completion and type hints -- */
.cm .cm-tooltip {
- font-family: var(--monospace-font);
font-size: 0.875rem;
border: none;
box-shadow: var(--light-shadow);
@@ -46,11 +45,18 @@
overflow: auto;
/* Respect newlines. */
- white-space: pre-wrap;
border-radius: 4px;
padding: 0.625rem 0.875rem;
}
+.cm .cm-tooltip code {
+ font-size: 0.8125rem;
+}
+
+.cm .cm-tooltip .external-docs {
+ font-size: 0.8125rem;
+}
+
/* Hover tooltips get highest priority in display. */
.cm .cm-tooltip.cm-tooltip-hover {
z-index: 1000;
diff --git a/marimo/_runtime/complete.py b/marimo/_runtime/complete.py
index f8e4f3b154..db2189c31e 100644
--- a/marimo/_runtime/complete.py
+++ b/marimo/_runtime/complete.py
@@ -1,6 +1,7 @@
# Copyright 2023 Marimo. All rights reserved.
from __future__ import annotations
+import html
import queue
from typing import cast
@@ -76,9 +77,14 @@ def _get_docstring(completion: jedi.api.classes.BaseName) -> str:
).text
if body:
- # aggressively treat docstrings as markdown. this does mostly okay for
- # most docstrings, and makes marimo docstrings much easier to read.
- body = _md(body, apply_markdown_class=False).text
+ # for marimo docstrings, treat them as markdown
+ # for other modules, treat them as plain text
+ if completion.module_name.startswith("marimo"):
+ body = _md(body, apply_markdown_class=False).text
+ else:
+ # TODO: this would look better parsed as RST
+ # for non-marimo modules
+ body = "<pre class='external-docs'>" + html.escape(body) + "</pre>"
if signature_text and body:
docstring = signature_text + "\n\n" + body