tooltips#

Create the tooltips of the keys and hand them to sphinx-tippy.

to_tooltip(description: str) → str[source]#

Convert a schema description to the HTML shown in its tooltip.

Inline literals become code, and so does interpreted text in single backticks. Projects that document Python usually render the latter as cross-references, which Sphinx shows as code, and Markdown renderers of the schema show it as code as well. A role prefix is dropped, and so are the ~ and ! modifiers of a reference. A reference with an explicit title shows only the title. Paragraphs separated by a blank line become separate paragraphs.

>>> to_tooltip("Arguments for ``pytest``, such as ``-n auto``.")
'<p>Arguments for <code>pytest</code>, such as <code>-n auto</code>.</p>'
>>> to_tooltip("Requires `host`.")
'<p>Requires <code>host</code>.</p>'
>>> to_tooltip("Run :program:`pwa` with :py:obj:`~module.Settings`.")
'<p>Run <code>pwa</code> with <code>Settings</code>.</p>'
>>> to_tooltip("First.\n\nSecond.")
'<p>First.</p><p>Second.</p>'