|
1 | 1 | """Get rich tool tips in your sphinx documentation!""" |
| 2 | + |
2 | 3 | from __future__ import annotations |
3 | 4 |
|
4 | 5 | import json |
@@ -125,9 +126,19 @@ def compile_config(app: Sphinx): |
125 | 126 | props = dict( |
126 | 127 | {"placement": "auto-start", "maxWidth": 500, "interactive": False}, **updates |
127 | 128 | ) |
128 | | - if set(props.keys()) - {"placement", "maxWidth", "interactive", "theme"}: |
| 129 | + |
| 130 | + supported_properties = { |
| 131 | + "placement", |
| 132 | + "maxWidth", |
| 133 | + "interactive", |
| 134 | + "theme", |
| 135 | + "delay", |
| 136 | + "duration", |
| 137 | + } |
| 138 | + |
| 139 | + if set(props.keys()) - supported_properties: |
129 | 140 | raise ExtensionError( |
130 | | - "tippy_props can only contain keys 'placement', 'maxWidth', 'interactive'" |
| 141 | + "tippy_props can only contain keys '%s'" % "', '".join(supported_properties) |
131 | 142 | ) |
132 | 143 | allowed_placements = { |
133 | 144 | "auto", |
@@ -163,6 +174,14 @@ def compile_config(app: Sphinx): |
163 | 174 | if not (props["theme"] is None or isinstance(props["theme"], str)): |
164 | 175 | raise ExtensionError("tippy_props['theme'] must be None or a string") |
165 | 176 | props["theme"] = f"'{props['theme']}'" if props["theme"] else "null" |
| 177 | + if "delay" in props: |
| 178 | + if not (props["delay"] is None or isinstance(props["delay"], list)): |
| 179 | + raise ExtensionError("tippy_props['delay'] must be None or a list") |
| 180 | + props["delay"] = props["delay"] if props["delay"] else "null" |
| 181 | + if "duration" in props: |
| 182 | + if not (props["duration"] is None or isinstance(props["duration"], list)): |
| 183 | + raise ExtensionError("tippy_props['duration'] must be None or a list") |
| 184 | + props["duration"] = props["duration"] if props["duration"] else "null" |
166 | 185 | app.env.tippy_config = TippyConfig( # type: ignore[attr-defined] |
167 | 186 | props=props, |
168 | 187 | custom_tips=app.config.tippy_custom_tips, |
|
0 commit comments