The WidgetBrowser includes a Sphinx extension to embed a widget browser inside generated docs to show a demo of a widget.
In the conf.py configuration file Sphinx uses add the following lines after extensions is declared:
try:
import widgetbrowser
extensions.append("widgetbrowser.sphinx_ext")
except ImportError:
pass
It is recommended to first try to import widgetbrowser to see if it is installed so users can build the docs regardless if WidgetBrowser is installed otr not. If it isn’t, Sphinx will just emitt warnings when it finds the widgetbrowser directive it doesn’t understand.
To insert a widget browser a special reStructuredText directive is used which looks like this:
.. widgetbrowser:: tw.forms.samples.AddUserForm
:tabs: source, demo
:size: x-large
And produces this: