Skip to content

Commit

Permalink
fixes #558
Browse files Browse the repository at this point in the history
  • Loading branch information
jph00 committed Oct 31, 2024
1 parent 9049867 commit 8122730
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
4 changes: 2 additions & 2 deletions fasthtml/_modidx.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,7 @@
'fasthtml.js.SortableJS': ('api/js.html#sortablejs', 'fasthtml/js.py'),
'fasthtml.js.dark_media': ('api/js.html#dark_media', 'fasthtml/js.py'),
'fasthtml.js.light_media': ('api/js.html#light_media', 'fasthtml/js.py')},
'fasthtml.jupyter': { 'fasthtml.jupyter.FT._repr_markdown_': ('api/jupyter.html#ft._repr_markdown_', 'fasthtml/jupyter.py'),
'fasthtml.jupyter.HTMX': ('api/jupyter.html#htmx', 'fasthtml/jupyter.py'),
'fasthtml.jupyter': { 'fasthtml.jupyter.HTMX': ('api/jupyter.html#htmx', 'fasthtml/jupyter.py'),
'fasthtml.jupyter.JupyUvi': ('api/jupyter.html#jupyuvi', 'fasthtml/jupyter.py'),
'fasthtml.jupyter.JupyUvi.__init__': ('api/jupyter.html#jupyuvi.__init__', 'fasthtml/jupyter.py'),
'fasthtml.jupyter.JupyUvi.start': ('api/jupyter.html#jupyuvi.start', 'fasthtml/jupyter.py'),
Expand All @@ -126,6 +125,7 @@
'fasthtml.jupyter.is_port_free': ('api/jupyter.html#is_port_free', 'fasthtml/jupyter.py'),
'fasthtml.jupyter.nb_serve': ('api/jupyter.html#nb_serve', 'fasthtml/jupyter.py'),
'fasthtml.jupyter.nb_serve_async': ('api/jupyter.html#nb_serve_async', 'fasthtml/jupyter.py'),
'fasthtml.jupyter.render_ft': ('api/jupyter.html#render_ft', 'fasthtml/jupyter.py'),
'fasthtml.jupyter.show': ('api/jupyter.html#show', 'fasthtml/jupyter.py'),
'fasthtml.jupyter.wait_port_free': ('api/jupyter.html#wait_port_free', 'fasthtml/jupyter.py'),
'fasthtml.jupyter.ws_client': ('api/jupyter.html#ws_client', 'fasthtml/jupyter.py')},
Expand Down
10 changes: 6 additions & 4 deletions fasthtml/jupyter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/api/06_jupyter.ipynb.

# %% auto 0
__all__ = ['nb_serve', 'nb_serve_async', 'is_port_free', 'wait_port_free', 'show', 'htmx_config_port', 'JupyUvi', 'HTMX',
'ws_client']
__all__ = ['nb_serve', 'nb_serve_async', 'is_port_free', 'wait_port_free', 'show', 'render_ft', 'htmx_config_port', 'JupyUvi',
'HTMX', 'ws_client']

# %% ../nbs/api/06_jupyter.ipynb
import asyncio, socket, time, uvicorn
Expand Down Expand Up @@ -59,8 +59,10 @@ def show(*s):
if IN_NOTEBOOK: return _show(*s, Script('htmx.process(document.body)'))
return _show(*s)

@patch
def _repr_markdown_(self:FT): return to_xml(Div(self, Script('if (window.htmx) htmx.process(document.body)')))
# %% ../nbs/api/06_jupyter.ipynb
def render_ft():
@patch
def _repr_markdown_(self:FT): return to_xml(Div(self, Script('if (window.htmx) htmx.process(document.body)')))

# %% ../nbs/api/06_jupyter.ipynb
def htmx_config_port(port=8000):
Expand Down
20 changes: 15 additions & 5 deletions nbs/api/06_jupyter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,28 @@
{
"cell_type": "code",
"execution_count": null,
"id": "6a962b54",
"id": "654b36bb",
"metadata": {},
"outputs": [],
"source": [
"#| export\n",
"def show(*s):\n",
" \"Same as fasthtml.components.show, but also adds `htmx.process()`\"\n",
" if IN_NOTEBOOK: return _show(*s, Script('htmx.process(document.body)'))\n",
" return _show(*s)\n",
"\n",
"@patch\n",
"def _repr_markdown_(self:FT): return to_xml(Div(self, Script('if (window.htmx) htmx.process(document.body)')))"
" return _show(*s)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6a962b54",
"metadata": {},
"outputs": [],
"source": [
"#| export\n",
"def render_ft():\n",
" @patch\n",
" def _repr_markdown_(self:FT): return to_xml(Div(self, Script('if (window.htmx) htmx.process(document.body)')))"
]
},
{
Expand Down

0 comments on commit 8122730

Please sign in to comment.