Skip to content

Commit

Permalink
deploy: 3b6c700
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Nov 3, 2024
0 parents commit 414c682
Show file tree
Hide file tree
Showing 92 changed files with 56,037 additions and 0 deletions.
Empty file added .nojekyll
Empty file.
1 change: 1 addition & 0 deletions CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs.fastht.ml
2 changes: 2 additions & 0 deletions api/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
These are the source notebooks for FastHTML.

835 changes: 835 additions & 0 deletions api/cli.html

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions api/cli.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Command Line Tools


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/cli.py#L15"
target="_blank" style="float:right; font-size:smaller">source</a>

### railway_link

> railway_link ()
*Link the current directory to the current project’s Railway service*

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/cli.py#L33"
target="_blank" style="float:right; font-size:smaller">source</a>

### railway_deploy

> railway_deploy (name:str, mount:<function bool_arg>=True)
*Deploy a FastHTML app to Railway*

<table>
<thead>
<tr class="header">
<th></th>
<th><strong>Type</strong></th>
<th><strong>Default</strong></th>
<th><strong>Details</strong></th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>name</td>
<td>str</td>
<td></td>
<td>The project name to deploy</td>
</tr>
<tr class="even">
<td>mount</td>
<td>bool_arg</td>
<td>True</td>
<td>Create a mounted volume at /app/data?</td>
</tr>
</tbody>
</table>
1,117 changes: 1,117 additions & 0 deletions api/components.html

Large diffs are not rendered by default.

330 changes: 330 additions & 0 deletions api/components.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,330 @@
# Components


<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->

``` python
from lxml import html as lx
from pprint import pprint
```

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/jupyter.py#L57"
target="_blank" style="float:right; font-size:smaller">source</a>

### show

> show (ft, *rest)
*Renders FT Components into HTML within a Jupyter notebook.*

``` python
sentence = P(Strong("FastHTML is ", I("Fast")))

# When placed within the `show()` function, this will render
# the HTML in Jupyter notebooks.
show(sentence)
```

<p>
<strong>FastHTML is <i>Fast</i></strong></p>

``` python
# Called without the `show()` function, the raw HTML is displayed
sentence
```

``` html
<p>
<strong>FastHTML is <i>Fast</i></strong></p>
```

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/components.py#L61"
target="_blank" style="float:right; font-size:smaller">source</a>

### attrmap_x

> attrmap_x (o)
------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/components.py#L73"
target="_blank" style="float:right; font-size:smaller">source</a>

### ft_html

> ft_html (tag:str, *c, id=None, cls=None, title=None, style=None,
> attrmap=None, valmap=None, ft_cls=None, auto_id=None, **kwargs)
``` python
ft_html('a', **{'@click.away':1})
```

``` html
<a @click.away="1"></a>
```

``` python
ft_html('a', {'@click.away':1})
```

``` html
<a @click.away="1"></a>
```

``` python
c = Div(id='someid')
```

``` python
ft_html('a', id=c)
```

``` html
<a id="someid" name="someid"></a>
```

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/components.py#L89"
target="_blank" style="float:right; font-size:smaller">source</a>

### ft_hx

> ft_hx (tag:str, *c, target_id=None, hx_vals=None, hx_target=None,
> id=None, cls=None, title=None, style=None, accesskey=None,
> contenteditable=None, dir=None, draggable=None, enterkeyhint=None,
> hidden=None, inert=None, inputmode=None, lang=None, popover=None,
> spellcheck=None, tabindex=None, translate=None, hx_get=None,
> hx_post=None, hx_put=None, hx_delete=None, hx_patch=None,
> hx_trigger=None, hx_swap=None, hx_swap_oob=None, hx_include=None,
> hx_select=None, hx_select_oob=None, hx_indicator=None,
> hx_push_url=None, hx_confirm=None, hx_disable=None,
> hx_replace_url=None, hx_disabled_elt=None, hx_ext=None,
> hx_headers=None, hx_history=None, hx_history_elt=None,
> hx_inherit=None, hx_params=None, hx_preserve=None, hx_prompt=None,
> hx_request=None, hx_sync=None, hx_validate=None, **kwargs)
``` python
ft_hx('a', hx_vals={'a':1})
```

``` html
<a hx-vals='{"a": 1}'></a>
```

``` python
ft_hx('a', hx_target=c)
```

``` html
<a hx-target="#someid"></a>
```

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/components.py#L110"
target="_blank" style="float:right; font-size:smaller">source</a>

### File

> File (fname)
*Use the unescaped text in file `fname` directly*

For tags that have a `name` attribute, it will be set to the value of
`id` if not provided explicitly:

``` python
Form(Button(target_id='foo', id='btn'),
hx_post='/', target_id='tgt', id='frm')
```

``` html
<form hx-post="/" hx-target="#tgt" id="frm" name="frm"><button hx-target="#foo" id="btn" name="btn"></button></form>
```

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/components.py#L137"
target="_blank" style="float:right; font-size:smaller">source</a>

### fill_form

> fill_form (form:fastcore.xml.FT, obj)
*Fills named items in `form` using attributes in `obj`*

``` python
@dataclass
class TodoItem:
title:str; id:int; done:bool; details:str; opt:str='a'

todo = TodoItem(id=2, title="Profit", done=True, details="Details", opt='b')
check = Label(Input(type="checkbox", cls="checkboxer", name="done", data_foo="bar"), "Done", cls='px-2')
form = Form(Fieldset(Input(cls="char", id="title", value="a"), check, Input(type="hidden", id="id"),
Select(Option(value='a'), Option(value='b'), name='opt'),
Textarea(id='details'), Button("Save"),
name="stuff"))
form = fill_form(form, todo)
assert '<textarea id="details" name="details">Details</textarea>' in to_xml(form)
form
```

``` html
<form><fieldset name="stuff"> <input value="Profit" id="title" class="char" name="title">
<label class="px-2"> <input type="checkbox" name="done" data-foo="bar" class="checkboxer" checked="1">
Done</label> <input type="hidden" id="id" name="id" value="2">
<select name="opt"><option value="a"></option><option value="b" selected="1"></option></select><textarea id="details" name="details">Details</textarea><button>Save</button></fieldset></form>
```

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/components.py#L144"
target="_blank" style="float:right; font-size:smaller">source</a>

### fill_dataclass

> fill_dataclass (src, dest)
*Modifies dataclass in-place and returns it*

``` python
nt = TodoItem('', 0, False, '')
fill_dataclass(todo, nt)
nt
```

TodoItem(title='Profit', id=2, done=True, details='Details', opt='b')

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/components.py#L150"
target="_blank" style="float:right; font-size:smaller">source</a>

### find_inputs

> find_inputs (e, tags='input', **kw)
*Recursively find all elements in `e` with `tags` and attrs matching
`kw`*

``` python
inps = find_inputs(form, id='title')
test_eq(len(inps), 1)
inps
```

[input((),{'value': 'Profit', 'id': 'title', 'class': 'char', 'name': 'title'})]

You can also use lxml for more sophisticated searching:

``` python
elem = lx.fromstring(to_xml(form))
test_eq(elem.xpath("//input[@id='title']/@value"), ['Profit'])
```

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/components.py#L164"
target="_blank" style="float:right; font-size:smaller">source</a>

### **getattr**

> __getattr__ (tag)
------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/components.py#L172"
target="_blank" style="float:right; font-size:smaller">source</a>

### html2ft

> html2ft (html, attr1st=False)
*Convert HTML to an `ft` expression*

``` python
h = to_xml(form)
hl_md(html2ft(h), 'python')
```

``` python
Form(
Fieldset(
Input(value='Profit', id='title', name='title', cls='char'),
Label(
Input(type='checkbox', name='done', data_foo='bar', checked='1', cls='checkboxer'),
'Done',
cls='px-2'
),
Input(type='hidden', id='id', name='id', value='2'),
Select(
Option(value='a'),
Option(value='b', selected='1'),
name='opt'
),
Textarea('Details', id='details', name='details'),
Button('Save'),
name='stuff'
)
)
```

``` python
hl_md(html2ft(h, attr1st=True), 'python')
```

``` python
Form(
Fieldset(name='stuff')(
Input(value='Profit', id='title', name='title', cls='char'),
Label(cls='px-2')(
Input(type='checkbox', name='done', data_foo='bar', checked='1', cls='checkboxer'),
'Done'
),
Input(type='hidden', id='id', name='id', value='2'),
Select(name='opt')(
Option(value='a'),
Option(value='b', selected='1')
),
Textarea('Details', id='details', name='details'),
Button('Save')
)
)
```

------------------------------------------------------------------------

<a
href="https://github.com/AnswerDotAI/fasthtml/blob/main/fasthtml/components.py#L205"
target="_blank" style="float:right; font-size:smaller">source</a>

### sse_message

> sse_message (elm, event='message')
*Convert element `elm` into a format suitable for SSE streaming*

``` python
print(sse_message(Div(P('hi'), P('there'))))
```

event: message
data: <div>
data: <p>hi</p>
data: <p>there</p>
data: </div>
Loading

0 comments on commit 414c682

Please sign in to comment.