#!/usr/bin/env python3 from nicegui import ui, wp from contextlib import contextmanager from icecream import ic import inspect from executing import Source from nicegui.elements.element import Element import sys import docutils.core # add docutils css to webpage wp.head_html += docutils.core.publish_parts('', writer_name='html')['stylesheet'] @contextmanager def example(): callFrame = inspect.currentframe().f_back.f_back begin = callFrame.f_lineno with ui.row(): with ui.card(): yield callFrame = inspect.currentframe().f_back.f_back end = callFrame.f_lineno code = inspect.getsource(sys.modules[__name__]) code = code.splitlines()[begin:end] code.insert(0, '```python') code.append('```') code = '\n'.join(code) ui.markdown(code) def describe(element: Element): doc = element.__init__.__doc__ html = docutils.core.publish_parts(doc, writer_name='html')['html_body'] html = html.replace('
', '